Spatial DataBlade
JAVA API v8.21

com.ibm.spatial.util
Class ErrorReporter

java.lang.Object
  extended by com.ibm.spatial.util.ErrorReporter

public class ErrorReporter
extends java.lang.Object

This class contains methods to report errors from inside the API code.


Field Summary
static int ERROR
          Fatal error
static int EXCEPTION
           
static int RECOVERABLE_ERROR
          Recoverable error
static int RUNTIME
           
static int WARNING
          Warning
 
Constructor Summary
ErrorReporter()
           
ErrorReporter(ErrorHandler handler, MessageProvider messages, MessageProvider implementationMessages)
           
 
Method Summary
static java.lang.StringBuffer formatEventLocation(java.lang.StringBuffer buf, EventLocation location, boolean writeClassInfo)
          Append EventLocation info to the message buffer specified by buf.
static java.lang.String formatMessage(int msgCode, MessageProvider provider, java.lang.Object[] args, EventLocation location, boolean writeClassInfo)
          Returns a formatted error message.
 ErrorHandler getHandler()
          Returns the current error handler.
 boolean getWriteClassInfo()
          Rerturns the value of the writeClassInfo flag.
 void reportError(int errorType, int msgCode, java.lang.Object[] args, EventLocation location)
          Reports an error of type errorType.
 void reportRuntimeError(int errorType, int msgCode, java.lang.Object[] args, EventLocation location)
          Reports a runtime error.
 void setHandler(ErrorHandler handler)
          Sets the error handler.
 void setWriteClassInfo(boolean flag)
          If flag is true, then this object will prepend error messages with the class and method name where the error occured, if this information exists; otherwise the class information is not written to the error message.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR

public static final int ERROR
Fatal error

See Also:
Constant Field Values

RECOVERABLE_ERROR

public static final int RECOVERABLE_ERROR
Recoverable error

See Also:
Constant Field Values

WARNING

public static final int WARNING
Warning

See Also:
Constant Field Values

RUNTIME

public static final int RUNTIME
See Also:
Constant Field Values

EXCEPTION

public static final int EXCEPTION
See Also:
Constant Field Values
Constructor Detail

ErrorReporter

public ErrorReporter()

ErrorReporter

public ErrorReporter(ErrorHandler handler,
                     MessageProvider messages,
                     MessageProvider implementationMessages)
Method Detail

setHandler

public void setHandler(ErrorHandler handler)
Sets the error handler.

Parameters:
handler - The new error handler.
See Also:
getHandler()

getHandler

public ErrorHandler getHandler()
Returns the current error handler.

Returns:
The current error handler.
See Also:
setHandler(com.ibm.spatial.ErrorHandler)

setWriteClassInfo

public void setWriteClassInfo(boolean flag)
If flag is true, then this object will prepend error messages with the class and method name where the error occured, if this information exists; otherwise the class information is not written to the error message.

Parameters:
flag - If true, then the class information will be prepended to the error message; otherwise, the class information will not be present in the error message.
See Also:
getWriteClassInfo()

getWriteClassInfo

public boolean getWriteClassInfo()
Rerturns the value of the writeClassInfo flag. See setWriteClassInfo for the flag definition.

Returns:
the value of the writeClassInfo flag
See Also:
setWriteClassInfo(boolean)

reportError

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

Parameters:
errorType - The type of the error
msgCode - The error message code
args - Arguments for error message text
location - The error location information
Throws:
SpatialException - A SpatialException is thrown depending on the decision taken by the error handler.
java.lang.IllegalArgumentException - if an unknown error type is passed in errorType.

reportRuntimeError

public void reportRuntimeError(int errorType,
                               int msgCode,
                               java.lang.Object[] args,
                               EventLocation location)
Reports a runtime error. Assembles the appropriate error message by assembling the message template specified by msgCode with the arguments stored in args, and the location information from location.

Parameters:
errorType - The type of the error
msgCode - The error message code. Legal values are:
  • Messages.MSG_INVALID_PARAM
  • Messages.MSG_SUBS_OUT_OF_RANGE
  • Messages.MSG_ASSERT_FAILURE
  • Messages.MSG_ASSERT_FAILURE_WITH_ID
  • Messages.MSG_UNSUPPORTED
args - Arguments for error message text
location - The error location information
Throws:
java.lang.RuntimeException - A subclass of RuntimeException
java.lang.IllegalArgumentException - in case the message code is not a legal runtime error code.

formatMessage

public static java.lang.String formatMessage(int msgCode,
                                             MessageProvider provider,
                                             java.lang.Object[] args,
                                             EventLocation location,
                                             boolean writeClassInfo)
Returns a formatted error message.

Parameters:
msgCode - message code
args - array of Object to be used as arguments for message formatting
location - the event location
Returns:
the message string

formatEventLocation

public static java.lang.StringBuffer formatEventLocation(java.lang.StringBuffer buf,
                                                         EventLocation location,
                                                         boolean writeClassInfo)
Append EventLocation info to the message buffer specified by buf.

The format of the returned data is: "entityId.subentityId(line:column): ".

Parameters:
buf - message buffer
location - the event location to format in the message buffer
Returns:
the message buffer

Spatial DataBlade
JAVA API v8.21


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