Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.util
Class StackTrace

    java.lang.Object
      org.jboss.util.StackTrace

All Implemented Interfaces:
  Cloneable, Printable, Serializable

public final class StackTrace
extends Object
implements Serializable, Cloneable, Printable

Provides access to the current stack trace by parsing the output of `Throwable.printStackTrace()`.

Version:
  `$Revision: 1.1 $`
Author:
  Jason Dillon
See Also:
  Serialized Form

Nested Class Summary
`static class` | `StackTrace.Entry` A stack trace entry.
`static class` | `StackTrace.Parser` A parser which takes a standard Throwable and produces `StackTrace.Entry` objects.

Field Summary
`protected List` | `stack` List of `StackTrace.Entry` elements
`static int` | `UNLIMITED` Parse all entries

Constructor Summary
`` | `StackTrace()` Construct a `StackTrace`.
`` | `StackTrace(int level)` Construct a `StackTrace`.
`` | `StackTrace(int level, int limit)` Construct a `StackTrace`.
`protected` | `StackTrace(List stack)` Sub-trace constructor.
`` | `StackTrace(Throwable detail)` Initialize a `StackTrace`.
`` | `StackTrace(Throwable detail, int level)` Initialize a `StackTrace`.
`` | `StackTrace(Throwable detail, int level, int limit)` Initialize a `StackTrace`.

Method Summary
`static StackTrace.Entry` | `callerEntry()` Returns a stack trace entry for the calling methods current position in the stack.
`Object` | `clone()` Returns a shallow cloned copy of this object.
`static StackTrace.Entry` | `currentEntry()` Returns a stack trace entry for the current position in the stack.
`boolean` | `equals(Object obj)` Check if the given object is equals to this.
`StackTrace.Entry` | `getCallerEntry()` Returns the stack trace entry for the calling method.
`StackTrace` | `getCallerTrace()` Returns the stack trace starting at the calling method.
`StackTrace.Entry` | `getEntry(int level)` Returns the stack trace entry for the element at the given level.
`StackTrace.Entry` | `getRootEntry()` Return the root entry for this stack trace.
`StackTrace` | `getSubTrace(int level)` Returns a sub trace starting at the the given level.
`StackTrace` | `getSubTrace(int level, int limit)` Returns a sub trace starting at the the given level.
`Iterator` | `iterator()` Returns an iterator over all of the entries in the stack trace.
`void` | `print()` Print this stack trace to `System.err`.
`void` | `print(PrintStream stream)` Print this stack trace.
`void` | `print(PrintStream stream, String prefix)` Print this stack trace.
`void` | `print(PrintWriter writer)` Print this stack trace.
`void` | `print(PrintWriter writer, String prefix)` Print this stack trace.
`void` | `print(String prefix)` Print this stack trace to `System.err`.
`static StackTrace.Entry` | `rootEntry()` Returns a stack trace entry for the root calling method of the current execution thread.
`int` | `size()` Returns the number of entries (or size) of the stack trace.

Methods inherited from class java.lang.Object
`finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### UNLIMITED

    public static final int UNLIMITED

  Parse all entries

  See Also:
    Constant Field Values

### stack

    protected final List stack

  List of `StackTrace.Entry` elements

Constructor Detail

### StackTrace

    public StackTrace(Throwable detail,
                      int level,
                      int limit)

  Initialize a `StackTrace`.

Parameters:
  `detail` - Detail throwable to determine stack entries from.
  `level` - Number of levels to go down into the trace.
  `limit` - The maximum number of entries to parse (does not include skipped levels or the description). A value <= zero results in all entries being parsed.
Throws:
  `IllegalArgumentException` - Invalid level or limit.
  `NestedRuntimeException` - Failed to create Parser.
  `NestedRuntimeException` - Failed to parse stack trace.

### StackTrace

    public StackTrace(Throwable detail,
                      int level)

  Initialize a `StackTrace`.

Parameters:
  `detail` - Detail throwable to determine stack entries from.
  `level` - Number of levels to go down into the trace.
Throws:
  `IllegalArgumentException` - Invalid level.
  `NestedRuntimeException` - Failed to create Parser.
  `NestedRuntimeException` - Failed to parse stack trace.

### StackTrace

    public StackTrace(Throwable detail)

  Initialize a `StackTrace`.

Parameters:
  `detail` - Detail throwable to determine stack entries from.
Throws:
  `NestedRuntimeException` - Failed to create Parser.
  `NestedRuntimeException` - Failed to parse stack trace.

### StackTrace

    public StackTrace(int level,
                      int limit)

  Construct a `StackTrace`.

Parameters:
  `level` - Number of levels to go down into the trace.
  `limit` - The maximum number of entries to parse (does not include skipped levels or the description). A value <= zero results in all entries being parsed.

### StackTrace

    public StackTrace(int level)

  Construct a `StackTrace`.

Parameters:
  `level` - Number of levels to go down into the trace.

### StackTrace

    public StackTrace()

  Construct a `StackTrace`.

### StackTrace

    protected StackTrace(List stack)

  Sub-trace constructor.

Method Detail

### equals

    public boolean equals(Object obj)

  Check if the given object is equals to this.

  Parameters:
    `obj` - Object to test equality with.
  Returns:
    True if object is equal to this.

### clone

    public Object clone()

  Returns a shallow cloned copy of this object.

  Returns:
    A shallow cloned copy of this object.

### getEntry

    public StackTrace.Entry getEntry(int level)

  Returns the stack trace entry for the element at the given level.

  Parameters:
    `level` - Number of levels.
  Returns:
    Stack trace entry.
  Throws:
    `IndexOutOfBoundsException` - Invalid level index.

### getCallerEntry

    public StackTrace.Entry getCallerEntry()

  Returns the stack trace entry for the calling method.

  Returns:
    Stack trace entry for calling method.

### getRootEntry

    public StackTrace.Entry getRootEntry()

  Return the root entry for this stack trace.

  Returns:
    Stack trace entry for the root calling method.

### getSubTrace

    public StackTrace getSubTrace(int level)

  Returns a sub trace starting at the the given level.

  Parameters:
    `level` - Number of levels.
  Returns:
    Sub-trace.

### getSubTrace

    public StackTrace getSubTrace(int level,
                                  int limit)

  Returns a sub trace starting at the the given level.

  Parameters:
    `level` - Number of levels.
    `limit` - Limit the sub-trace. If there are less entries than the limit, the limit has no effect.
  Returns:
    Sub-trace.

### getCallerTrace

    public StackTrace getCallerTrace()

  Returns the stack trace starting at the calling method.

  Returns:
    Stack trace for calling method.

### print

    public void print(PrintWriter writer,
                      String prefix)

  Print this stack trace.

  Specified by:
    `print` in interface `Printable`
  Parameters:
    `writer` - The writer to print to.
    `prefix` - Stack trace entry prefix.

### print

    public void print(PrintWriter writer)

  Print this stack trace.

  Specified by:
    `print` in interface `Printable`
  Parameters:
    `writer` - The writer to print to.

### print

    public void print(PrintStream stream,
                      String prefix)

  Print this stack trace.

  Specified by:
    `print` in interface `Printable`
  Parameters:
    `stream` - The stream to print to.
    `prefix` - Stack trace entry prefix.

### print

    public void print(PrintStream stream)

  Print this stack trace.

  Specified by:
    `print` in interface `Printable`
  Parameters:
    `stream` - The stream to print to.

### print

    public void print(String prefix)

  Print this stack trace to `System.err`.

  Parameters:
    `prefix` - Stack trace entry prefix.

### print

    public void print()

  Print this stack trace to `System.err`.

### iterator

    public Iterator iterator()

  Returns an iterator over all of the entries in the stack trace.

  Returns:
    An iterator over all of the entries in the stack trace.

### size

    public int size()

  Returns the number of entries (or size) of the stack trace.

  Returns:
    The number of entries (or size) of the stack trace.

### currentEntry

    public static final StackTrace.Entry currentEntry()

  Returns a stack trace entry for the current position in the stack.

  The current entry refers to the method that has invoked `currentEntry()`.

  Returns:
    Current position in the stack.

### callerEntry

    public static final StackTrace.Entry callerEntry()

  Returns a stack trace entry for the calling methods current position in the stack.

  Calling method in this case refers to the method that has called the method which invoked `callerEntry()`.

  Returns:
    Calling methods current position in the stack.
  Throws:
    `IndexOutOfBoundsException` - The current entry is at bottom of the stack.

### rootEntry

    public static final StackTrace.Entry rootEntry()

  Returns a stack trace entry for the root calling method of the current execution thread.

  Returns:
    Stack trace entry for the root calling method.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002 JBoss Group, LLC. All Rights Reserved.