Class SzCoreUtilities

java.lang.Object
com.senzing.sdk.core.SzCoreUtilities

public final class SzCoreUtilities extends Object
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 Details

    • createSzException

      public static SzException createSzException(int errorCode, String message)
      Creates the appropriate SzException instance for the specified error code.

      If there is a failure in creating the SzException instance, then a generic SzException is 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 the SzException instance.
      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

      public static String createConfigComment(String configDefinition)
      Produce an auto-generated configuration comment describing a configuration. This is useful when implementing the SzConfigManager.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 JSON String configuration 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

      public static String configToString(SzConfig config)
      Converts the specified SzConfig to a String via its SzConfig.export() method while handling any SzEnvironmentDestroyedException exception by returning a message indicating the environment is destroyed as well as any SzException by returning the result from that exception's Throwable.getMessage() with a prefix.

      This method is made available so implementations of SzConfig can easily override Object.toString() while consistently handling common exceptions that may be thrown.

      Parameters:
      config - The SzConfig to convert to a String.
      Returns:
      The String representation obtained from the SzConfig via SzConfig.export() or an error message if a failure occurs.
      Since:
      4.2.0