Package com.senzing.sdk.core
Class SzCoreUtilities
java.lang.Object
com.senzing.sdk.core.SzCoreUtilities
Provides utility functions that are useful when implementing
the Senzing SDK interfaces from the
com.senzing.sdk
package. This is functionality leveraged by the "core" implementation
that is made visible to aid in other implementations.
None of the functionality provided here is required to use the
SzCoreEnvironment class, but may be useful if creating an
alternate implementation of SzEnvironment.- Since:
- 4.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringconfigToString(SzConfig config) Converts the specifiedSzConfigto aStringvia itsSzConfig.export()method while handling anySzEnvironmentDestroyedExceptionexception by returning a message indicating the environment is destroyed as well as anySzExceptionby returning the result from that exception'sThrowable.getMessage()with a prefix.static StringcreateConfigComment(String configDefinition) Produce an auto-generated configuration comment describing a configuration.static SzExceptioncreateSzException(int errorCode, String message) Creates the appropriateSzExceptioninstance for the specified error code.
-
Method Details
-
createSzException
Creates the appropriateSzExceptioninstance for the specified error code.If there is a failure in creating the
SzExceptioninstance, then a genericSzExceptionis created with the specified parameters and "caused by" exception describing the failure.- Parameters:
errorCode- The error code to use to determine the specific type for theSzExceptioninstance.message- The error message to associate with the exception.- Returns:
- A new instance of
SzException(or one of its derived classes) for the specified error code and message. - Since:
- 4.0.0
-
createConfigComment
Produce an auto-generated configuration comment describing a configuration. This is useful when implementing theSzConfigManager.registerConfig(String)function.This function will not fail on an invalid configuration, but rather will simply return an empty-string for the comment.
- Parameters:
configDefinition- The JSONStringconfiguration definition.- Returns:
- The auto-generated comment, which may be empty-string if an auto-generated comment could not be inferred.
- Since:
- 4.0.0
-
configToString
Converts the specifiedSzConfigto aStringvia itsSzConfig.export()method while handling anySzEnvironmentDestroyedExceptionexception by returning a message indicating the environment is destroyed as well as anySzExceptionby returning the result from that exception'sThrowable.getMessage()with a prefix.This method is made available so implementations of
SzConfigcan easily overrideObject.toString()while consistently handling common exceptions that may be thrown.- Parameters:
config- TheSzConfigto convert to aString.- Returns:
- The
Stringrepresentation obtained from theSzConfigviaSzConfig.export()or an error message if a failure occurs. - Since:
- 4.2.0
-