|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.bea.domingo.exception.ExceptionUtil
public final class ExceptionUtil
Utilities for manipulating and examining Throwable
s.
Field Summary | |
---|---|
static char |
INNER_CLASS_SEPARATOR_CHAR
Inner class separator character: '$' == 36 . |
static java.lang.String |
PACKAGE_SEPARATOR
The package separator String: "." . |
static char |
PACKAGE_SEPARATOR_CHAR
Package separator character: '.' == 46 . |
Method Summary | |
---|---|
static java.lang.Throwable |
getCause(java.lang.Throwable throwable)
Introspects the Throwable to obtain the cause. |
static java.lang.String |
getShortClassName(java.lang.Class clazz)
Gets the class name minus the package name from a Class . |
static java.lang.String |
getShortClassName(java.lang.Object object,
java.lang.String valueIfNull)
Gets the class name minus the package name for an Object . |
static java.lang.String |
getShortClassName(java.lang.String className)
Gets the class name minus the package name from a String. |
(package private) static java.util.List |
getStackFrameList(java.lang.Throwable t)
Produces a List of stack frames - the message is not
included. |
(package private) static java.lang.String[] |
getStackFrames(java.lang.String stackTrace)
Returns an array where each element is a line from the argument. |
protected static java.lang.String[] |
getStackFrames(java.lang.Throwable throwable)
Captures the stack trace associated with the specified Throwable object, decomposing it into a list of stack
frames. |
static java.lang.String |
getStackTrace(java.lang.Throwable throwable)
Gets the stack trace from a Throwable as a String. |
static boolean |
isCascadingThrowable()
Checks if the Throwable class has a getCause method. |
static boolean |
isCascadingThrowable(java.lang.Throwable throwable)
Checks whether this Throwable class can store a cause. |
static void |
printStackTrace(java.lang.Throwable throwable)
Prints the stack trace of a throwable to the standard error stream. |
static void |
printStackTrace(java.lang.Throwable throwable,
java.io.PrintStream out)
Prints the stack trace of a throwable to the specified stream. |
static void |
printStackTrace(java.lang.Throwable throwable,
java.io.PrintWriter out)
Prints the stack trace of a throwable to the specified writer. |
static void |
removeCommonFrames(java.util.List causeFrames,
java.util.List wrapperFrames)
Removes common frames from the cause trace given the two stack traces. |
protected static void |
trimStackFrames(java.util.List stacks)
Trims the stack frames. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char PACKAGE_SEPARATOR_CHAR
'.' == 46
.
public static final java.lang.String PACKAGE_SEPARATOR
"."
.
public static final char INNER_CLASS_SEPARATOR_CHAR
'$' == 36
.
Method Detail |
---|
public static java.lang.Throwable getCause(java.lang.Throwable throwable)
Introspects the Throwable
to obtain the cause.
The method searches for methods with specific names that return a
Throwable
object. This will pick up most wrapping
exceptions, including those from JDK 1.4, and the domingo exceptions.
The default list searched for are:
getCause()
getNextException()
getTargetException()
getException()
getSourceException()
getRootCause()
getCausedByException()
getNested()
In the absence of any such method, the object is inspected for a
detail
field assignable to a Throwable
.
If none of the above is found, returns null
.
throwable
- the throwable to introspect for a cause, may be null
Throwable
, null
if none found or null throwable inputpublic static boolean isCascadingThrowable()
Checks if the Throwable class has a getCause
method.
This is true for JDK 1.4 and above.
public static boolean isCascadingThrowable(java.lang.Throwable throwable)
Checks whether this Throwable
class can store a cause.
This method does not check whether it actually does store a cause.
throwable
- the Throwable
to examine, may be null
true
if cascading, otherwise false
public static void removeCommonFrames(java.util.List causeFrames, java.util.List wrapperFrames) throws java.lang.IllegalArgumentException
Removes common frames from the cause trace given the two stack traces.
causeFrames
- stack trace of a cause throwablewrapperFrames
- stack trace of a wrapper throwable
java.lang.IllegalArgumentException
- if either argument is nullpublic static java.lang.String getStackTrace(java.lang.Throwable throwable)
Gets the stack trace from a Throwable as a String.
The result of this method vary by JDK version as this method uses
Throwable.printStackTrace(java.io.PrintWriter)
. On JDK1.3 and
earlier, the cause exception will not be shown unless the specified
throwable alters printStackTrace.
throwable
- the Throwable
to be examined
printStackTrace(PrintWriter)
methodstatic java.lang.String[] getStackFrames(java.lang.String stackTrace)
Returns an array where each element is a line from the argument.
The end of line is determined by the value of line.separator system property.
stackTrace
- a stack trace String
static java.util.List getStackFrameList(java.lang.Throwable t)
Produces a List
of stack frames - the message is not
included. Only the trace of the specified exception is returned, any
caused by trace is stripped.
This works in most cases - it will only fail if the exception message
contains a line that starts with:
" at".
t
- is any throwable
public static java.lang.String getShortClassName(java.lang.Object object, java.lang.String valueIfNull)
Gets the class name minus the package name for an Object
.
object
- the class to get the short name for, may be nullvalueIfNull
- the value to return if null
public static java.lang.String getShortClassName(java.lang.Class clazz)
Gets the class name minus the package name from a Class
.
clazz
- the class to get the short name for.
public static java.lang.String getShortClassName(java.lang.String className)
Gets the class name minus the package name from a String.
The string passed in is assumed to be a class name - it is not checked.
className
- the className to get the short name for
public static void printStackTrace(java.lang.Throwable throwable)
throwable
- a cascading throwablepublic static void printStackTrace(java.lang.Throwable throwable, java.io.PrintStream out)
throwable
- a cascading throwableout
- PrintStream
to use for output.printStackTrace(Throwable, PrintWriter)
public static void printStackTrace(java.lang.Throwable throwable, java.io.PrintWriter out)
throwable
- a cascading throwableout
- PrintWriter
to use for output.protected static java.lang.String[] getStackFrames(java.lang.Throwable throwable)
Throwable
object, decomposing it into a list of stack
frames.
throwable
- The Throwable
.
protected static void trimStackFrames(java.util.List stacks)
stacks
- The list containing String[] elements
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |