|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jasig.portal.lang.ThrowableHelper
public final class ThrowableHelper
The ThrowableHelper class defines a set of utility
methods for handling common error management operations in a
fashion which takes advantage of the J2SDK 1.4 constructs while
maintaining J2SDK 1.3 compatibility.
| Method Summary | |
|---|---|
static Throwable |
create(Class throwableClass,
Class client,
String propertyName,
String[] args,
Throwable cause)
Creates the specified Throwable object with the
internationalized error code and arguments. |
static ThrowableHandler |
getDefaultHandler(String className)
Returns a constructed instance of the default handler. |
static String |
getInternationalizedMessage(Class client,
String error)
Returns an internationalized error message which can be reconstructed into a localized error message with the getLocalizedMessage method call. |
static String |
getInternationalizedMessage(Class client,
String error,
String[] objects)
Returns an internationalized error message which can be reconstructed into a localized error message with the getLocalizedMessage method call. |
static String |
getLocalizedMessage(String i18nMessage)
Returns the localized error message associated with the specified internationalized error message constructed with the getInternationalizedMessage method. |
static String |
getLocalizedMessage(String i18nMessage,
Locale locale)
Returns the localized error message associated with the specified internationalized error message constructed with the getInternationalizedMessage method. |
static String |
getLocalizedMessage(Throwable throwable)
Returns the localized string associated with the argument. |
static String |
getLocalizedMessage(Throwable throwable,
Locale locale)
Returns the localized string associated with the argument in the specified locale, if possible. |
static void |
handle(Class client,
String message,
String[] objects,
Throwable cause)
Handles the throwable condition specified in the parameters. |
static void |
handle(Class client,
String message,
String[] objects,
Throwable cause,
ThrowableHandler handler)
Handles the throwable condition specified in the parameters. |
static void |
handle(Throwable cause)
Handles the throwable condition specified in the parameter. |
static void |
initCause(Throwable throwable,
Throwable cause)
Initizlizes the chained cause of the throwable if possible using the J2SDK 1.4 constructs. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static final ThrowableHandler getDefaultHandler(String className)
ThrowableHandler interface and have an
accessible default constructor.
className - name of the throwable handler class
public static final String getInternationalizedMessage(Class client,
String error)
getLocalizedMessage method call.
client - class of the client making this callerror - error property name of the error condition
public static final String getInternationalizedMessage(Class client,
String error,
String[] objects)
getLocalizedMessage method call.
client - class of the client making this callerror - error property name of the error conditionobjects - string objects which should be stored for the
message
NullPointerException - if client, or error parameters are
nullpublic static final String getLocalizedMessage(String i18nMessage)
getInternationalizedMessage method. The default
locale is used.
i18nMessage - internationalized error message
nullpublic static final String getLocalizedMessage(Throwable throwable)
throwable - object whose message is to be localized
Throwable
public static final String getLocalizedMessage(Throwable throwable,
Locale locale)
throwable - object whose message is to be localizedlocale - locale to localized the message
Throwable
public static final String getLocalizedMessage(String i18nMessage,
Locale locale)
getInternationalizedMessage method. The locale of
for the translation is picked up from the current session.
i18nMessage - internationalized error messagelocale - locale to translate the message
null
public static final void initCause(Throwable throwable,
Throwable cause)
throwable - throwable whose cause should be setcause - throwable which caused the throwable condition
public static final Throwable create(Class throwableClass,
Class client,
String propertyName,
String[] args,
Throwable cause)
Throwable object with the
internationalized error code and arguments. If the cause object
is not null, the specified object's initCause
method will be invoked reflectively to enable the standard
chaining constructs. The specified error code is an
internationalized error property value which must be defined in
a resource bundle associated with the client, specificifically
the code will perform a ResourceBundle.getBundle( ) to resolve the resource.
Invoking this method is equivalent to creating the
Throwable with an internationalized message and
then invoking ThrowableHelper.initCause, e.g.,:
Throwable someCause = ...
String i18nMessage = ThrowableHelper.getInternationalizedMessage(
MyApplication.class,
"myapplication.some_error_code",
new String[]{ "32", "1024" }
);
IllegalArgumentException iae = new IllegalArgumentException(
i18nMessage
);
ThrowableHelper.initCause(
iae,
someCause
);
throwableClass - throwable object to be constructedclient - class file of the clientpropertyName - internationalized error code property name
defined in the client's resouce bundleargs - arguments for the localized messagecause - cause of the created exception, or
null
public static final void handle(Throwable cause)
cause - throwable condition which should be handled
public static final void handle(Class client,
String message,
String[] objects,
Throwable cause)
client - client performing the handlingcause - throwable condition which should be handledmessage - associated with handling the errorobjects - associated with the error message
public static final void handle(Class client,
String message,
String[] objects,
Throwable cause,
ThrowableHandler handler)
null the default handler
is used; otherwise, the specified handler is used to process
this request.
client - client performing the handlingcause - throwable condition which should be handledmessage - associated with handling the errorobjects - associated with the error messagehandler - which should be executed instead of the default
handler
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||