|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Throwable
java.lang.Exception
com.cosylab.util.CommonException
public class CommonException
This is the basic checked exceptions for the Java projects. In addition to
normal Java checked exceptions it provides information about the computer
where the exception has occured, as well as instance information about the
object, throwing the exception. It also contains hooks for integration with
other Java or framework serviecs, in the form of JavaHelp ID string and
list of available Swing actions. Several important parameters that are
determined at construction time, such as message, instance that is throwing
the exception and the possible exception cause (if the exceptions are
chained). Other parameters (such as helpID and actions) can be set after
construction with their respective property setter methods. Most of the
parameters are automatically set in the constructors of
CommonException. If the derived exception wishes to override
the parameters (such as thread, username, host etc), it may reset them in
the derived constructor.
| Field Summary | |
|---|---|
protected javax.swing.Action[] |
actions
|
java.lang.String |
caughtIn
DOCUMENT ME! |
protected java.lang.String |
helpID
|
protected static java.lang.String |
host
|
protected java.lang.Object |
instance
|
protected java.lang.Thread |
thread
|
protected long |
timestamp
|
protected java.lang.String |
username
|
protected java.util.HashMap |
values
|
| Constructor Summary | |
|---|---|
protected |
CommonException()
Create a new instance of CommonException. |
|
CommonException(java.lang.Object instance,
java.lang.String s)
Create an instance of CommonException with a with a
specified message string. |
|
CommonException(java.lang.Object instance,
java.lang.String message,
java.lang.Throwable t)
Create an instance of CommonException by specifying both
the string message and a Throwable object that represents
the nested exception. |
| Method Summary | |
|---|---|
void |
caughtIn(java.lang.Object target,
java.lang.String method)
Call this method if the exception is caught. |
javax.swing.Action[] |
getActions()
Returns a list of suggested actions that can be added to the GUI. |
java.lang.String |
getCaughtIn()
Returns the string description of where the exception has been caught or null if it has not been caught. |
java.lang.String |
getHelpID()
Returns the help identifier for this exception. |
java.lang.String |
getHost()
Return the host this exception was generated on, if the JVM has access to such data. |
java.lang.Object |
getInstance()
Return the data about the instance which raised the exception. |
java.lang.Throwable |
getParent()
Return the parent exception that caused this exception to be thrown. |
java.lang.Thread |
getThread()
Returns the thread of execution in which the constructor of this exception was invoked. |
long |
getTimestamp()
Returns the timestamp of the instantiation of this exception. |
java.lang.String |
getUsername()
Returns the currently logged in user. |
java.lang.Object |
getValue(java.lang.String key)
Returns the value stored under a given key in the map of values. |
java.util.Map |
getValues()
Returns a hashmap that can hold any key-value pairs that contain internal state of the system or specifically the Object
instance raising this exception. |
protected void |
initialize()
Initializes the exception by filling in the host, timestamp, username, thread information. |
void |
putValue(java.lang.String key,
java.lang.Object value)
A shortcut to getValues().put(Object key, Object value). |
void |
setActions(javax.swing.Action[] actions)
Sets the actions returned by this exception. |
void |
setHelpID(java.lang.String helpID)
Sets the JavaHelp id under which the help for this specific exception instance may be looked up. |
| Methods inherited from class java.lang.Throwable |
|---|
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.cosylab.util.CommonThrowable |
|---|
getMessage |
| Field Detail |
|---|
protected static java.lang.String host
protected java.lang.Thread thread
protected java.lang.Object instance
protected java.util.HashMap values
protected long timestamp
protected java.lang.String helpID
protected javax.swing.Action[] actions
protected java.lang.String username
public java.lang.String caughtIn
| Constructor Detail |
|---|
protected CommonException()
CommonException. This constructor
should normally not be used since it carries no additional exception
data.
public CommonException(java.lang.Object instance,
java.lang.String s)
CommonException with a with a
specified message string. The construction is delegated to
super.
instance - identifier of the instance throwing this exceptions - message to be printed together with the exception type when
the toString() is called.
java.lang.NullPointerException - DOCUMENT ME!
public CommonException(java.lang.Object instance,
java.lang.String message,
java.lang.Throwable t)
CommonException by specifying both
the string message and a Throwable object that represents
the nested exception.
instance - identifier of the instance throwing this exceptionmessage - a string message passed to supert - an instance of Throwable that caused this to be
thrown, can be null
java.lang.NullPointerException - DOCUMENT ME!| Method Detail |
|---|
public void caughtIn(java.lang.Object target,
java.lang.String method)
caughtIn in interface CommonThrowabletarget - Object in which this exception was caughtmethod - method name without parenthesis of prefixed class namepublic java.lang.String getCaughtIn()
null if it has not been caught.
getCaughtIn in interface CommonThrowablepublic java.lang.String getHost()
getHost in interface CommonThrowablepublic java.lang.Throwable getParent()
getParent in interface CommonThrowablepublic java.lang.Thread getThread()
getThread in interface CommonThrowablepublic long getTimestamp()
System.currentTimeMillis().
getTimestamp in interface CommonThrowablepublic java.util.Map getValues()
Object
instance raising this exception. Such data may help in debugging.
Note! Try to store serialized vaues not to introduce memory leaks.
getValues in interface CommonThrowableprotected void initialize()
public void putValue(java.lang.String key,
java.lang.Object value)
getValues().put(Object key, Object value).
Convenience method. Also converts value to string, not to produce
memory leak.
putValue in interface CommonThrowablekey - key under which the value will be stored in the hashtablevalue - value for the key, should have toString()
overriden to allow for a more informative displaypublic javax.swing.Action[] getActions()
CommonThrowable
getActions in interface CommonThrowableCommonThrowable.getActions()public java.lang.String getHelpID()
CommonThrowable
getHelpID in interface CommonThrowableCommonThrowable.getHelpID()public java.lang.Object getInstance()
CommonThrowableIdentifiable interface, it should return the
Identifiable of its logically most "proximate"
Identifiable instance. Note that while instances of
CoreException must provide at least the proximate
Identifiable, instances of AssertionFailed
may return null in this method.
getInstance in interface CommonThrowableCommonThrowable.getInstance()public java.lang.String getUsername()
CommonThrowable
getUsername in interface CommonThrowableCommonThrowable.getUsername()public java.lang.Object getValue(java.lang.String key)
CommonThrowable
getValue in interface CommonThrowablekey - the key to look up
null if no value is
stored under this keyCommonThrowable.getValue(String)public void setActions(javax.swing.Action[] actions)
actions - actions to displaypublic void setHelpID(java.lang.String helpID)
helpID - the JavaHelp identification
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||