Spatial DataBlade
JAVA API v8.21

com.ibm.spatial
Class SpatialManager

java.lang.Object
  extended by com.ibm.spatial.SpatialManager

public class SpatialManager
extends java.lang.Object

SpatialManager contains convenience methods for managing geometry objects.

SpatialManager implements a logging facade. An application can activate logging by using the methods setLogWriter and setLogLevel.

This class also implements error message formatting and reporting.

SpatialManager is safe for concurrent access by multiple threads.


Constructor Summary
SpatialManager()
           
 
Method Summary
static void assertSM(boolean cond, java.lang.String className, java.lang.String methodName)
          Assertion failure reporting.
static void assertSM(boolean cond, java.lang.String className, java.lang.String methodName, int id)
          Assertion failure reporting.
static java.lang.String buildNumber()
          Returns a product build number.
static java.lang.String buildTime()
          Returns a product build date and time string (non-localized!)
static java.lang.String buildVersion()
          Returns a product build version string.
static ErrorHandler getErrorHandler()
          Returns the current error handler.
static ErrorReporter getErrorReporter()
          Returns the current error reporter.
static EventLocation getEventLocation(java.lang.String className, java.lang.String methodName)
          Returns a code locator to use when reporting errors.
static java.util.Locale getLocale()
           Note: this method is used internally and may be changed in future implementations without notice.
static Logger getLogger()
          Returns the current logger.
static LogHandler getLogHandler()
          Returns the cuurent log handler.
static int getLogLevel()
          Returns the current logging level.
static java.io.Writer getLogWriter()
          Returns the current log Writer.
static MessageProvider getMessageProvider()
          Returns the current message provider.
static void indexOutOfRange(java.lang.String idxName, int idxValue, int minValue, int maxValue, java.lang.String className, java.lang.String methodName)
          Prepares an error message and reports an index out of range error.
static void invalidArg(java.lang.String argName, int argValue, java.lang.String className, java.lang.String methodName)
          Prepares an error message and reports an invalid argument error.
static void invalidArg(java.lang.String argName, java.lang.String argValue, java.lang.String className, java.lang.String methodName)
          Prepares an error message and reports an invalid argument error.
static java.lang.String releaseVersion()
          Returns a product release version string.
static void reportError(java.lang.Exception exception, java.lang.String className, java.lang.String methodName)
          Report an error caused by exception.
static void reportError(int msgCode)
          Report a fatal error with a message indicated by msgCode.
static void reportError(int msgCode, int errorType, java.lang.Object[] args, EventLocation location)
          Report an error of type errorType.
static void reportError(int msgCode, java.lang.Object[] args)
          Report a fatal error.
static void reportError(int msgCode, java.lang.Object[] args, EventLocation location)
          Report a fatal error.
static void reportError(int msgCode, java.lang.Object[] args, java.lang.String className, java.lang.String methodName)
          Report a fatal error.
static void reportError(int msgCode, java.lang.String className, java.lang.String methodName)
          Report a fatal error.
static void setErrorHandler(ErrorHandler handler)
          Sets the error handler.
static void setLocale(java.util.Locale locale)
           Note: this method is used internally and may be changed in future implementations without notice.
static void setLogger(Logger logger)
          Sets the current logger.
static void setLogLevel(int level)
          Sets the current logging level.
static void setLogWriter(java.lang.String fileName)
          Sets the current log Writer.
static void setLogWriter(java.io.Writer writer)
          Sets the current log Writer.
static void unsupported()
          Prepares an error message and reports an unsupported operation error.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpatialManager

public SpatialManager()
Method Detail

setLocale

public static void setLocale(java.util.Locale locale)
                      throws SpatialException

Note: this method is used internally and may be changed in future implementations without notice. Applications should not use this method.

Parameters:
locale - A Java Locale object.
Throws:
SpatialException - Throws an exception (using the previous or default locale) if the requested locale is not supported.
See Also:
SpatialException

getLocale

public static java.util.Locale getLocale()

Note: this method is used internally and may be changed in future implementations without notice. Applications should not use this method.

Returns:
the current locale

setErrorHandler

public static void setErrorHandler(ErrorHandler handler)
Sets the error handler.

Parameters:
handler - The new error handler.

getErrorHandler

public static ErrorHandler getErrorHandler()
Returns the current error handler.

Returns:
The current error handler, or null if none has been registered.
See Also:
setErrorHandler(com.ibm.spatial.ErrorHandler)

getMessageProvider

public static MessageProvider getMessageProvider()
Returns the current message provider.

Returns:
The current MessageProvider.

setLogger

public static void setLogger(Logger logger)
Sets the current logger.

Note: this method is used internally and may be changed in future implementations without notice. Applications should not use this method.

Parameters:
logger - A new logger to be registered with this SpatialManager.
See Also:
getLogger()

getLogger

public static Logger getLogger()
Returns the current logger.

Returns:
The default logger.
See Also:
setLogger(com.ibm.spatial.util.Logger)

setLogLevel

public static void setLogLevel(int level)
Sets the current logging level. The level values should be set according to levels defined by the Logger class.

Parameters:
level - the logging level
See Also:
Logger

getLogLevel

public static int getLogLevel()
Returns the current logging level.

Returns:
the current logging level.
See Also:
setLogLevel(int)

getLogHandler

public static LogHandler getLogHandler()
Returns the cuurent log handler.

Note: this method is used internally and may be changed in future implementations without notice. Applications should not use this method.

Returns:
the current log handler

setLogWriter

public static void setLogWriter(java.lang.String fileName)
                         throws java.io.IOException
Sets the current log Writer.

Parameters:
fileName - A name for the log file. If fileName is null, then the log is written to the standard error stream with the default character encoding.
Throws:
java.io.IOException - if the specified file can't be opened or if some other I/O error occurs.
See Also:
getLogWriter()

setLogWriter

public static void setLogWriter(java.io.Writer writer)
Sets the current log Writer. If writer is null, then the log is written to the standard error stream with the default character encoding.

Parameters:
writer - an object extending java.io.Writer
See Also:
getLogWriter()

getLogWriter

public static java.io.Writer getLogWriter()
Returns the current log Writer.

Returns:
The current log Writer, or null if none has been registered.
See Also:
setLogWriter(java.lang.String)

getErrorReporter

public static ErrorReporter getErrorReporter()
Returns the current error reporter.

Note: this method is used internally and may be changed in future implementations without notice. Applications should not use this method.

Returns:
The current error reporter.

reportError

public static void reportError(java.lang.Exception exception,
                               java.lang.String className,
                               java.lang.String methodName)
                        throws SpatialException
Report an error caused by exception. If logging is turned on, the exception is logged at a Logger.SEVERE level, then the exception is thrown.

Parameters:
exception - The exception generated by the caller.
className - The name of the class where the error occurred
methodName - The name of the method where the error occurred
Throws:
SpatialException - a SpatialException wrapping the exception passed as argument

reportError

public static void reportError(int msgCode)
                        throws SpatialException
Report a fatal error with a message indicated by msgCode. Log the error at a Logger.SEVERE level.

Parameters:
msgCode - The error message code
Throws:
SpatialException - A SpatialException is thrown on error.

reportError

public static void reportError(int msgCode,
                               java.lang.Object[] args)
                        throws SpatialException
Report a fatal error. Assemble the appropriate error message by formatting the message template given by msgCode and arguments stored in args.

Parameters:
msgCode - The error message code
args - Arguments for error message text
Throws:
SpatialException - A SpatialException is thrown on error.

reportError

public static void reportError(int msgCode,
                               java.lang.String className,
                               java.lang.String methodName)
                        throws SpatialException
Report a fatal error. Assemble the appropriate error message by formatting the message template given by msgCode, the source class name, and the source method name.

Parameters:
msgCode - The error message code
className - The class name where the error occurred
methodName - The method name where the error occurred
Throws:
SpatialException - A SpatialException is thrown on error.

reportError

public static void reportError(int msgCode,
                               java.lang.Object[] args,
                               java.lang.String className,
                               java.lang.String methodName)
                        throws SpatialException
Report a fatal error. Assemble the appropriate error message by formatting the message template given by msgCode with arguments stored in args, the source class name, and the source method name.

Parameters:
msgCode - The error message code
args - Arguments for error message text
className - The class name where the error occurred
methodName - The method name where the error occurred
Throws:
SpatialException - A SpatialException is thrown on error.

reportError

public static void reportError(int msgCode,
                               java.lang.Object[] args,
                               EventLocation location)
                        throws SpatialException
Report a fatal error. Assemble the appropriate error message by formatting the message template given by msgCode with the arguments stored in args, and the location information from location.

Parameters:
msgCode - The error message code
args - Arguments for error message text
location - The error location information
Throws:
SpatialException - A SpatialException is thrown on error.

reportError

public static void reportError(int msgCode,
                               int errorType,
                               java.lang.Object[] args,
                               EventLocation location)
                        throws SpatialException
Report an error of type errorType. Assemble the appropriate error message by formatting the message template given by msgCode with the arguments stored in args, and the location information from location.

An error may be of one of the following types:

Parameters:
msgCode - The error message code
errorType - The type of the error. An error type can be:
args - Arguments for error message text
location - The error location information
Throws:
SpatialException - A SpatialException is thrown on error.

assertSM

public static void assertSM(boolean cond,
                            java.lang.String className,
                            java.lang.String methodName,
                            int id)
Assertion failure reporting. Use where several assertions are verified in a single method and differentiate them by the id argument.

Parameters:
cond - a boolean expression which is asserted to be true; if false, then a SpatialException with error code Messages.MSG_ASSERT_FAILURE_WITH_ID is thrown
className - the class name
methodName - the method name
id - a numerical id, to identify several assertions in a single method.
Throws:
java.lang.RuntimeException

assertSM

public static void assertSM(boolean cond,
                            java.lang.String className,
                            java.lang.String methodName)
Assertion failure reporting. Use where a single assertion is verified in a method and is uniquely identified by the class and method names.

Parameters:
cond - a boolean expression which is asserted to be true; if false, then a SpatialException with error code Messages.MSG_ASSERT_FAILURE_WITH_ID is thrown
className - the class name
methodName - the method name
Throws:
java.lang.RuntimeException

indexOutOfRange

public static void indexOutOfRange(java.lang.String idxName,
                                   int idxValue,
                                   int minValue,
                                   int maxValue,
                                   java.lang.String className,
                                   java.lang.String methodName)
Prepares an error message and reports an index out of range error.

Parameters:
idxName - the name of the index
idxValue - the value of the index
minValue - the minimum legal value of the index
maxValue - the maximum legal value of the index
className - the class name
methodName - the method name
Throws:
java.lang.IndexOutOfBoundsException

invalidArg

public static void invalidArg(java.lang.String argName,
                              java.lang.String argValue,
                              java.lang.String className,
                              java.lang.String methodName)
Prepares an error message and reports an invalid argument error.

Parameters:
argName - the name of the invalid argument
argValue - the value of the invalid argument
className - the class name
methodName - the method name
Throws:
java.lang.IllegalArgumentException

invalidArg

public static void invalidArg(java.lang.String argName,
                              int argValue,
                              java.lang.String className,
                              java.lang.String methodName)
Prepares an error message and reports an invalid argument error.

Parameters:
argName - the name of the invalid argument
argValue - the value of the invalid argument
className - the class name
methodName - the method name
Throws:
java.lang.IllegalArgumentException

unsupported

public static void unsupported()
Prepares an error message and reports an unsupported operation error.

Throws:
java.lang.UnsupportedOperationException

getEventLocation

public static EventLocation getEventLocation(java.lang.String className,
                                             java.lang.String methodName)

Returns a code locator to use when reporting errors.

This is a convenience method here only the entity and subentity are initialized.

Parameters:
className - the class name, used to initialize the entity id
methodName - the method name, used to initialize the subentity id
Returns:
a reference to an EventLocation which has been initialized with the argument values
See Also:
EventLocation

releaseVersion

public static java.lang.String releaseVersion()
Returns a product release version string.

Returns:
product version

buildVersion

public static java.lang.String buildVersion()
Returns a product build version string. A build version may be different from a release version when the build is for testing purposes.

Returns:
product build version

buildNumber

public static java.lang.String buildNumber()
Returns a product build number.

Returns:
a string object containing the current build number

buildTime

public static java.lang.String buildTime()
Returns a product build date and time string (non-localized!)

Returns:
a string object containing the build time

Spatial DataBlade
JAVA API v8.21


Licensed Materials - Property of IBM
Copyright IBM Corp. 2002, 2012 All Rights Reserved.