public final class StackTraceTools
extends java.lang.Object
StackTraceElements.| Modifier and Type | Method and Description |
|---|---|
static java.lang.StackTraceElement[] |
headTrim(java.lang.StackTraceElement[] origStackTrace,
java.lang.Class<?> cls)
Removes all elements from the head of the stack trace that refer to the
given class.
|
static java.lang.StackTraceElement[] |
headTrim(java.lang.StackTraceElement[] stackTrace,
int trim)
Removes the given number of elements from the head (i.e. the top) of the
given stack trace and returns the result in a new array.
|
static java.lang.StackTraceElement[] |
join(java.lang.StackTraceElement[] headStackTrace,
int tailTrimOfHead,
java.lang.StackTraceElement[] tailStackTrace,
int headTrimOfTail)
Joins the two given stack traces, i.e. append the tail stack trace to the
head stack trace, and returns the result in a new array.
|
static java.lang.StackTraceElement[] |
join(java.lang.StackTraceElement[] headStackTrace,
java.lang.StackTraceElement[] tailStackTrace)
Joins the two given stack traces, i.e. append the tail stack trace to the
head stack trace, and returns the result in a new array.
|
static void |
printStackTrace()
Prints the current stack trace to
System.out. |
static java.lang.String |
stackTracesToString(java.lang.StackTraceElement[] trace)
Returns the designated stack trace as string.
|
static java.lang.String |
stackTraceToString(java.lang.Throwable throwable)
Returns the output of
Throwable.printStackTrace(PrintWriter) in a
string. |
static java.lang.StackTraceElement[] |
tailTrim(java.lang.StackTraceElement[] stackTrace,
int trim)
Removes the given number of elements from the tail (i.e. the bottom) of the
given stack trace and returns the result in a new array.
|
public static java.lang.StackTraceElement[] tailTrim(java.lang.StackTraceElement[] stackTrace,
int trim)
stackTrace - the stack trace to be trimmedtrim - the number of elements to be trimmed from the stack trace's
tailpublic static java.lang.StackTraceElement[] headTrim(java.lang.StackTraceElement[] stackTrace,
int trim)
stackTrace - the stack trace to be trimmedtrim - the number of elements to be trimmed from the stack trace's
headpublic static java.lang.StackTraceElement[] headTrim(java.lang.StackTraceElement[] origStackTrace,
java.lang.Class<?> cls)
origStackTrace - the stack trace to be trimmedcls - the class for which to remove all elements from the head of the
stack tracepublic static java.lang.StackTraceElement[] join(java.lang.StackTraceElement[] headStackTrace,
java.lang.StackTraceElement[] tailStackTrace)
headStackTrace - the stack trace to which the tail stack trace will be
appendedtailStackTrace - the stack trace that will be appended to the head
stack tracepublic static java.lang.StackTraceElement[] join(java.lang.StackTraceElement[] headStackTrace,
int tailTrimOfHead,
java.lang.StackTraceElement[] tailStackTrace,
int headTrimOfTail)
headStackTrace - the stack trace to which the tail stack trace will be
appendedtailTrimOfHead - the number of elements to be trimmed from the trail
of the head stack tracetailStackTrace - the stack trace that will be appended to the head
stack traceheadTrimOfTail - the number of elements to be trimmed from the head of
the tail stack tracepublic static java.lang.String stackTraceToString(java.lang.Throwable throwable)
Throwable.printStackTrace(PrintWriter) in a
string.throwable - the throwableThrowable.printStackTrace(PrintWriter) in a
stringpublic static java.lang.String stackTracesToString(java.lang.StackTraceElement[] trace)
trace - The stack trace to be transformed to a string.public static void printStackTrace()
System.out. This method is only
useful for debugging purposes.