|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jasig.portal.lang.StackTrace
public final class StackTrace
The StackTrace
object represents a single stack frame
of information. The entire set of stack frames is represented as an
array of StackTrace
object.
Nested Class Summary | |
---|---|
private static class |
StackTrace.ParseState
The ParseState class holds the current parsing
state. |
Field Summary | |
---|---|
private static int |
DEFAULT_STACK_TRACE_ARRAY_SIZE
Default size of the stack trace array buffer. |
private java.lang.String |
mClassName
Holder for the class name. |
private java.lang.String |
mFileName
Holder for the source file name. |
private int |
mLineNumber
Holder for the line number. |
private java.lang.String |
mMethodName
Holder for the method name. |
private static int |
NATIVE_METHOD
Moniker for native method. |
private static int |
PRIME
Prime number used to calculate hash code. |
Constructor Summary | |
---|---|
private |
StackTrace(java.lang.String className,
java.lang.String methodName,
java.lang.String fileName,
int lineNumber)
Hidden constructor for the StackTrace object. |
Method Summary | |
---|---|
private static StackTrace |
convertElement(java.lang.Object element)
Converts a J2SDK 1.4 StackTraceElement object
to a StackTrace object. |
(package private) static StackTrace[] |
convertStackTrace(java.lang.Object[] stackTrace)
Converts a JDK 1.4 stack trace to this object. |
private static boolean |
eq(java.lang.Object a,
java.lang.Object b)
Returns true if the two objects are
equal. |
boolean |
equals(java.lang.Object obj)
Returns true |
java.lang.String |
getClassName()
Returns the name of the class. |
java.lang.String |
getFileName()
Returns the name of the source file. |
int |
getLineNumber()
Returns the line number in the source file. |
java.lang.String |
getMethodName()
Returns the name of the method. |
static StackTrace[] |
getStackTrace()
Returns the stack trace elements of the client. |
static StackTrace |
getStackTrace(int index)
Returns the specified stack trace element if it exists. |
static StackTrace[] |
getStackTrace(java.lang.Throwable throwable)
Returns all StackTrace s in an array of the
specified throwable. |
(package private) static StackTrace[] |
getStackTrace(java.lang.Throwable throwable,
java.lang.String stackTrace)
Returns all StackTrace s in an array. |
int |
hashCode()
Returns a hash code value for this stack trace element. |
boolean |
isNativeMethod()
Returns true if method is implemented
natively. |
private static StackTrace |
parseStackTrace(StackTrace.ParseState state)
Parse the first class name from the specified stack trace starting at the specified index. |
private static java.lang.Object[] |
parseStackTrace(java.lang.String stackTrace)
Parses a stack trace into individual stack frames. |
private static StackTrace[] |
parseStackTrace(java.lang.Throwable throwable,
java.lang.String stackTrace)
Returns an array of StackTrace objects representing
the Throwable argument. |
java.lang.String |
toString()
Returns a representation of the stack frame element. |
static java.lang.String |
toString(StackTrace[] elements)
Returns a string representation of the stack trace elements. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final int DEFAULT_STACK_TRACE_ARRAY_SIZE
private static final int NATIVE_METHOD
private static final int PRIME
private java.lang.String mFileName
private java.lang.String mClassName
private java.lang.String mMethodName
private int mLineNumber
Constructor Detail |
---|
private StackTrace(java.lang.String className, java.lang.String methodName, java.lang.String fileName, int lineNumber)
StackTrace
object.
className
- class name in the stack framemethodName
- method name in the stack framefileName
- file name in the stack framelineNumber
- line number in the stack frameMethod Detail |
---|
public final java.lang.String getFileName()
"Unknown"
will
be returned.
public final java.lang.String getClassName()
public final java.lang.String getMethodName()
public final int getLineNumber()
-1
will be returned. If the parser determines the method is a
native, a -2 is returned.
public final boolean isNativeMethod()
true
if method is implemented
natively.
true
is native method; otherwise
false
public static final StackTrace[] getStackTrace(java.lang.Throwable throwable)
StackTrace
s in an array of the
specified throwable.
throwable
- throwable being parsed
StackTrace
s
java.lang.NullPointerException
- if throwable is null
java.lang.NullPointerException
- if stackTrace is null
java.lang.IllegalArgumentException
- if stackTrace is an empty
stringstatic final StackTrace[] getStackTrace(java.lang.Throwable throwable, java.lang.String stackTrace)
StackTrace
s in an array. This method
is used by the Chained*
concrete classes to avoid
a circular dependency. The throwable, and its string output
must both be specified. Both are required because the throwable
could be a com.sct.pipeline.lang.ChainedException
which would result in a circular dependency if a
printStackTrace
was used in this method to
retrieve the trace information. Invoke this method in the
following fashion:
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(
stringWriter
);
Throwable t = new Throwable();
t.printStackTrace(
printWriter
);
printWriter.close();
StackTrace[] frames = getStackTraceElements(
t,
stringWriter.toString()
);
throwable
- throwable being parsedstackTrace
- string output of
throwable.printStackTrace
StackTrace
s
java.lang.NullPointerException
- if throwable is null
java.lang.NullPointerException
- if stackTrace is null
java.lang.IllegalArgumentException
- if stackTrace is an empty stringpublic static final StackTrace[] getStackTrace()
public static final StackTrace getStackTrace(int index)
null
is returned.
index
- index of the stack trace element to return
null
static final StackTrace[] convertStackTrace(java.lang.Object[] stackTrace)
stackTrace
- array of JDK 1.4 stack trace objects
StackTrace
objectsprivate static final StackTrace convertElement(java.lang.Object element)
StackTraceElement
object
to a StackTrace
object.
element
- StackTraceElement
object
StackTrace
objectprivate static final StackTrace[] parseStackTrace(java.lang.Throwable throwable, java.lang.String stackTrace)
StackTrace
objects representing
the Throwable
argument.
throwable
- stackTrace
-
StackTrace
objectsprivate static final java.lang.Object[] parseStackTrace(java.lang.String stackTrace)
stackTrace
- stack trace to parse
public final java.lang.String toString()
toString
in class java.lang.Object
public static final java.lang.String toString(StackTrace[] elements)
elements
- stack trace elements to stringify
public boolean equals(java.lang.Object obj)
true if the specified object is another
StackTrace instance representing the same
execution point as this instance. Two stack trace elements
a and b are equal if and only if:
equals(a.getFileName(), b.getFileName()) &&
a.getLineNumber() == b.getLineNumber()) &&
equals(a.getClassName(), b.getClassName()) &&
equals(a.getMethodName(), b.getMethodName())
where equals is defined as:
static boolean equals(Object a, Object b) {
return a==b || (a != null && a.equals(b));
}
- Overrides:
equals
in class java.lang.Object
- Parameters:
obj
- the object to be compared with this stack trace
element
- Returns:
true
if the specified object is another
StackTrace instance representing the same
execution point as this instance; otherwise false
private static final boolean eq(java.lang.Object a, java.lang.Object b)
true
if the two objects are
equal. Equality is defined as either object identity or if
a.equals(b)
if a
is not
null
.
a
- left hand side argumentb
- right hand side argument
true
if the two are equal; otherwise
false
public int hashCode()
hashCode
in class java.lang.Object
private static final StackTrace parseStackTrace(StackTrace.ParseState state)
state
- parsing state
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |