|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.empire.commons.ErrorObject
public abstract class ErrorObject
This class holds and provides information about the last error that occured on an object.
In order to use this class you must derive your class from Error Object.
If a method fails then you must set the error by calling one of the error(...) functions.
The method usually indicates failure by returning false.
You may then retrieve error information by calling one of the function defined by the ErrorObject.ObjectErrorInfo
interface.
All classes of the empire framework are derived from this class.
This class is thread save so each thread may have it's own error information for a particular object.
Nested Class Summary | |
---|---|
protected static class |
ErrorObject.ObjectErrorInfo
This class is internally used by the ErrorObject to provide thread-safe access to the error information. |
Constructor Summary | |
---|---|
ErrorObject()
Constructs an ErrorObject object. |
|
ErrorObject(ErrorInfo other)
Constructs a ErrorObject object copying the Error information of another object. |
Method Summary | |
---|---|
void |
clearError()
Clears the error for this object. |
protected void |
clearErrorInfo()
Clears the ErrorInfo. |
protected boolean |
error(ErrorInfo other)
Copies the error set on another object to this object. |
protected boolean |
error(ErrorType errType)
Sets the error. |
protected boolean |
error(ErrorType errType,
java.lang.Object param)
Sets the specified error and and the message. |
protected boolean |
error(ErrorType errType,
java.lang.Object[] params)
Sets an error from an error code an an array of parameters |
protected boolean |
error(ErrorType errType,
java.lang.Object param1,
java.lang.Object param2)
Sets the specified error and two messages. |
protected boolean |
error(ErrorType errType,
java.lang.Throwable exptn)
Sets the specified error and the corresponding error message on this object. |
protected boolean |
error(java.lang.Throwable exptn)
Sets the last error and the error message: ERR_EXCEPTION. |
protected ErrorObject.ObjectErrorInfo |
getErrorInfo(boolean create)
getErrorInfo |
java.lang.String |
getErrorMessage()
Returns the message associated with the last error. |
java.lang.Object[] |
getErrorParams()
Returns the parameters used to build the error text. |
java.lang.String |
getErrorSource()
Returns the parameters used to build the error text. |
ErrorType |
getErrorType()
Returns the last error code. |
static java.lang.String |
getMessage(ErrorInfo error)
Returns the message associated with an error. |
boolean |
hasError()
Returns wether or not an error is set. |
protected boolean |
internalSetError(ErrorType errType,
java.lang.Object[] params,
ErrorInfo source)
Sets the last error and the corresponding error message on this object. |
static boolean |
isExceptionsEnabled()
Returns wether or not Exceptions will be thrown on failure. If disabled (default) the functions' return values will indicate success or failure |
static void |
setExceptionsEnabled(boolean enableExceptions)
Use this to enable or disable Exceptions. If exceptionsEnabled is false no exceptions will be thrown. Instead the functions' return values will indicate success or failure |
protected boolean |
success()
returns true |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ErrorObject()
public ErrorObject(ErrorInfo other)
other
- the source error informationMethod Detail |
---|
public static boolean isExceptionsEnabled()
public static void setExceptionsEnabled(boolean enableExceptions)
enableExceptions
- true to enable exceptions or false to disablepublic static java.lang.String getMessage(ErrorInfo error)
error
- the error information for which to obtain an error message
protected ErrorObject.ObjectErrorInfo getErrorInfo(boolean create)
protected void clearErrorInfo()
public final boolean hasError()
hasError
in interface ErrorInfo
public final ErrorType getErrorType()
getErrorType
in interface ErrorInfo
public final java.lang.String getErrorSource()
getErrorSource
in interface ErrorInfo
public final java.lang.Object[] getErrorParams()
getErrorParams
in interface ErrorInfo
public final void clearError()
public final java.lang.String getErrorMessage()
protected boolean internalSetError(ErrorType errType, java.lang.Object[] params, ErrorInfo source)
errType
- the type of error to set.params
- array of parameters for the error message if any.source
- object from which this error originated from.
protected final boolean success()
protected final boolean error(ErrorType errType, java.lang.Object[] params)
errType
- the type of error to set.params
- array of parameters for the error message if any.
protected final boolean error(ErrorType errType)
protected final boolean error(ErrorType errType, java.lang.Object param)
errType
- the type of error to set.param
- parameter for the error message.
protected final boolean error(ErrorType errType, java.lang.Object param1, java.lang.Object param2)
errType
- the type of error to set.param1
- parameter for the error message.param2
- parameter for the error message.
protected final boolean error(ErrorType errType, java.lang.Throwable exptn)
errType
- the type of error to set.exptn
- Exception from witch the error message is copied.
protected final boolean error(java.lang.Throwable exptn)
exptn
- Exception from witch the error message is copied.
protected final boolean error(ErrorInfo other)
other
- the object from which to copy the error.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |