IMC Epclient 5.0.3

at.spardat.enterprise.exc
Class BaseException

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byjava.lang.RuntimeException
              extended byat.spardat.enterprise.exc.BaseException
All Implemented Interfaces:
INotification, java.io.Serializable
Direct Known Subclasses:
AppException, SysException

public abstract class BaseException
extends java.lang.RuntimeException
implements INotification, java.io.Serializable

This class supports the notification of application or system level exceptions. Since this class works much the same as class Notification, please have a look there for the description of the API.

What makes this class different from Notification is the fact that you can throw an instance of subclasses of BaseException. Furthermore you may set a detail Throwable at construction time, which should indicate a more detailed (often technical) reason why you are creating and throwing an BaseException.

This class must be sublassed outside the framework.

Author:
YSD, 21.05.2003 19:29:23
See Also:
Serialized Form

Field Summary
protected  Notification notification_
          The wrapped notification object
protected  boolean showToEndUser_
          Indicates if this exception may be shown to the end user or not.
 
Fields inherited from interface at.spardat.enterprise.exc.INotification
R_ABORT, R_ABORT_RETRY_IGNORE, R_CANCEL, R_IGNORE, R_NO, R_OK, R_OK_CANCEL, R_RETRY, R_RETRY_CANCEL, R_YES, R_YES_NO, R_YES_NO_CANCEL, T_ERROR, T_INFORMATION, T_QUESTION, T_WARNING
 
Constructor Summary
protected BaseException()
          For internal use only.
  BaseException(java.lang.Throwable detail, java.lang.String message, java.util.Locale l, java.lang.Object[] params)
          Constructs and sets the message from a format string as defined in java.text.MessageFormat.
 
Method Summary
 boolean containsCode(int code)
          Returns true if this or any recursively nested detail BaseExceptions code equals code.
 int getCode()
          Returns the code.
 java.lang.Throwable getDetail()
          Returns the detail throwable.
 java.lang.String getFirstNonEmptyMessage(boolean withClassNamePraefix)
          This method takes into account that BaseExceptions might be nested and the outermost exceptions might have empty messages.
 java.lang.String getMessage()
          Returns a fully descriptive text of this notification.
 java.lang.String getMessage(boolean withClassNamePraefix)
          Returns the message of this, optionally praefixed by classname and a colon.
 java.lang.String getOwnStackTrace()
          Returns the result of calling printStackTrace on super.
 int getReaction()
          Returns the permissible user reaction to the notification which is one of the constants starting with R_.
 java.lang.String getShortMessage()
          Returns a short text explaining this notification.
 at.spardat.enterprise.exc.StackTrace getStackOfThis()
          Returns the stack trace of this with a corrected header.
 int getType()
          Returns the type of this notification, that is one of the constants with praefix T_.
 void prepareMigration()
          This method should be called if this is about to leave the JVM and therefore must be serialized.
 void printStackTrace()
          Prints this to System.err.
 void printStackTrace(java.io.PrintStream s)
          Prints this to the provided PrintStream including the stacktrace and the information of all contained exceptions.
 void printStackTrace(java.io.PrintWriter s)
          Prints this to the provided PrintWriter including the stacktrace and the information of all contained exceptions.
 BaseException setMessage(java.lang.String message)
          Constructs and sets the message to the provided value.
 BaseException setMessage(java.lang.String messageFmt, java.lang.Object param1)
          Sets the message of this from a one parameter java.text.MessageFormat compatible string.
 BaseException setMessage(java.lang.String messageFmt, java.lang.Object param1, java.lang.Object param2)
          Sets the message of this from a one parameter java.text.MessageFormat compatible string.
 boolean showToEndUser()
          Indicates if this exception may be directly displayed to the end user.
 java.lang.String toString()
          Returns a String which contains the class name, message and code of this exception/notification.
 BaseException truncateSubclasses()
          Creates a AppException or SysException from this that has the property that this and all contained BaseExceptions are instances of AppException or SysException, but not subclasses of them.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

notification_

protected Notification notification_
The wrapped notification object


showToEndUser_

protected boolean showToEndUser_
Indicates if this exception may be shown to the end user or not. This is just a hint for the presentation layer to decide if it should wrap this in another exception.

Constructor Detail

BaseException

protected BaseException()
For internal use only.


BaseException

public BaseException(java.lang.Throwable detail,
                     java.lang.String message,
                     java.util.Locale l,
                     java.lang.Object[] params)
Constructs and sets the message from a format string as defined in java.text.MessageFormat. The required parameters must be contained in the params array.

Parameters:
detail - detail exception.
message - string that either is a java.text.MessageFormat or not, depending on params.
l - a java.util.Locale to format locale dependent data types or null if the params do not contain local specifics.
params - the parameters of the message. If not null, message is expected to be a string compliant to MessageFormat.
Method Detail

getCode

public int getCode()
Returns the code. The code should be used to discrimitate among different kinds of exceptions/notifications.

Specified by:
getCode in interface INotification

containsCode

public boolean containsCode(int code)
Returns true if this or any recursively nested detail BaseExceptions code equals code.

Parameters:
code - the code to be checked for equality with the code of this or any contained BaseException.

getType

public int getType()
Description copied from interface: INotification
Returns the type of this notification, that is one of the constants with praefix T_. If no type is set, this defaults to T_ERROR.

Specified by:
getType in interface INotification
See Also:
INotification.getType()

getReaction

public int getReaction()
Description copied from interface: INotification
Returns the permissible user reaction to the notification which is one of the constants starting with R_. You will get a bit or combination of constants. If you did set a constant that combines some others, like R_YES_NO, the bit or combination of R_YES and R_NO is returned.

Specified by:
getReaction in interface INotification
See Also:
INotification.getReaction()

getShortMessage

public java.lang.String getShortMessage()
Description copied from interface: INotification
Returns a short text explaining this notification. This text is optional. If not set, it defaults to a text derived from type. The returned String is never null.

Specified by:
getShortMessage in interface INotification
See Also:
INotification.getShortMessage()

getMessage

public java.lang.String getMessage()
Description copied from interface: INotification
Returns a fully descriptive text of this notification. The returned text is never null.

Specified by:
getMessage in interface INotification
See Also:
INotification.getMessage()

getFirstNonEmptyMessage

public java.lang.String getFirstNonEmptyMessage(boolean withClassNamePraefix)
This method takes into account that BaseExceptions might be nested and the outermost exceptions might have empty messages. It searches the detail list down until it finds a non-empty message and returns it.

Parameters:
withClassNamePraefix - indicates, if the message should be praefixed by the classname and a colon.
Returns:
the first non-empty message in the BaseException-detail-list or the empty-string if all messages are empty.

getMessage

public java.lang.String getMessage(boolean withClassNamePraefix)
Returns the message of this, optionally praefixed by classname and a colon.

Parameters:
withClassNamePraefix - indicates that a classname praefix is required.
Returns:
non-null String

getDetail

public java.lang.Throwable getDetail()
Returns the detail throwable. The returned value is null if no detail has been set or this has been migrated and the detail is not an BaseException.

See Also:
prepareMigration()

showToEndUser

public boolean showToEndUser()
Indicates if this exception may be directly displayed to the end user.


prepareMigration

public void prepareMigration()
This method should be called if this is about to leave the JVM and therefore must be serialized. We expect that the recipient JVM is able to deserialize an BaseException, but not necessarely any other contained detail exception. Therefore, if the detail-throwable is not an BaseException, it is converted to a String[] and stored as String[]. getDetail() will return null afterwards.

This method does nothing if there is no detail-throwable. If the detail itself is an BaseException, the method is called recursively.

The end effect of calling this method is, to summarize the words above, that any contained exception, directly or indirectly, is morphed to a String[] if it is not an BaseException.


toString

public java.lang.String toString()
Returns a String which contains the class name, message and code of this exception/notification.

See Also:
Object.toString()

printStackTrace

public void printStackTrace()
Prints this to System.err.

See Also:
Throwable.printStackTrace()

printStackTrace

public void printStackTrace(java.io.PrintStream s)
Prints this to the provided PrintStream including the stacktrace and the information of all contained exceptions.

See Also:
Throwable.printStackTrace(java.io.PrintStream)

printStackTrace

public void printStackTrace(java.io.PrintWriter s)
Prints this to the provided PrintWriter including the stacktrace and the information of all contained exceptions.

See Also:
Throwable.printStackTrace(java.io.PrintWriter)

getOwnStackTrace

public java.lang.String getOwnStackTrace()
Returns the result of calling printStackTrace on super.


getStackOfThis

public at.spardat.enterprise.exc.StackTrace getStackOfThis()
Returns the stack trace of this with a corrected header. The header may have changed since we have saved the stack in the constructor.


truncateSubclasses

public BaseException truncateSubclasses()
Creates a AppException or SysException from this that has the property that this and all contained BaseExceptions are instances of AppException or SysException, but not subclasses of them.

This (the target object) is destroyed and must not be used anymore!!! This method must not be called from outside the framework!!!


setMessage

public BaseException setMessage(java.lang.String messageFmt,
                                java.lang.Object param1,
                                java.lang.Object param2)
Sets the message of this from a one parameter java.text.MessageFormat compatible string.

Parameters:
messageFmt - format string as defined in java.text.MessageFormat.
param1 - message parameter
param2 - message parameter
Returns:
this

setMessage

public BaseException setMessage(java.lang.String messageFmt,
                                java.lang.Object param1)
Sets the message of this from a one parameter java.text.MessageFormat compatible string.

Parameters:
messageFmt - format string as defined in java.text.MessageFormat.
param1 - message parameter
Returns:
this

setMessage

public BaseException setMessage(java.lang.String message)
Constructs and sets the message to the provided value.

Parameters:
message - text to set
Returns:
this

IMC Epclient 5.0.3