org.crosswire.common.util

## Class StackTrace

- java.lang.Object
- - org.crosswire.common.util.StackTrace

-     public final class StackTrace
      extends Object

  Unscramble the current stack, and present the data from it to the user in various forms. This code is slightly dodgy in that it makes use of the way exceptions print their stack traces, however it is probably a safe enough assumption for the moment.
  Author:
    Joe Walker
  See Also:
    `The GNU Lesser General Public License for details.`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `StackTrace.AbstractStackIterator<T>` Base class for the real enumeration implementations below

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private String[]` | `classNames` Array containing the class names
    `private String[]` | `fileNames` Array containing the file names
    `private int[]` | `lineNumbers` Array containing the line numbers
    `private String[]` | `methodNames` Array containing the method names

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StackTrace()` Generate a stack trace an model it
    `StackTrace(Throwable ex)` We already have an Exception that we'd like to model

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `countStackElements()` How many stack elements are there?
    `Class<?>` | `getClass(int level)` Get the Class that owns the function
    `int` | `getClassCount()` Get the count of classes
    `String` | `getClassName(int level)` Get the name of a class
    `Iterator<String>` | `getClassNameElements()` To iterate over the class names
    `String` | `getFileName(int level)` Get the name of a file
    `String` | `getFullFunctionName(int level)` Get the name of a function including class name
    `Iterator<String>` | `getFullFunctionNameElements()` To iterate over the full function names
    `String` | `getFunctionName(int level)` Get the name of a function
    `Iterator<String>` | `getFunctionNameElements()` To iterate over the function names
    `int` | `getLineNumber(int level)` Get the line number within a file
    `private void` | `init(Throwable exception, int discard)` Create a stack trace of the code at this point

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### classNames

          private String[] classNames

      Array containing the class names

    - #### methodNames

          private String[] methodNames

      Array containing the method names

    - #### fileNames

          private String[] fileNames

      Array containing the file names

    - #### lineNumbers

          private int[] lineNumbers

      Array containing the line numbers

  - ### Constructor Detail

    - #### StackTrace

          public StackTrace()

      Generate a stack trace an model it

    - #### StackTrace

          public StackTrace(Throwable ex)

      We already have an Exception that we'd like to model
      Parameters:
        `ex` - The Exception to model

  - ### Method Detail

    - #### init

          private void init(Throwable exception,
                  int discard)

      Create a stack trace of the code at this point
      Parameters:
        `exception` - The Throwable containing the Stack Trace
        `discard` - The number of uppermost stack frames to ignore

    - #### countStackElements

          public int countStackElements()

      How many stack elements are there?
      Returns:
        the number of stack elements

    - #### getFunctionName

          public String getFunctionName(int level)

      Get the name of a function
      Parameters:
        `level` - Number of calling function
      Returns:
        the function name

    - #### getFullFunctionName

          public String getFullFunctionName(int level)

      Get the name of a function including class name
      Parameters:
        `level` - Number of calling function
      Returns:
        the full function name

    - #### getClassName

          public String getClassName(int level)

      Get the name of a class
      Parameters:
        `level` - Number of calling function
      Returns:
        the class name

    - #### getFileName

          public String getFileName(int level)

      Get the name of a file
      Parameters:
        `level` - Number of calling function
      Returns:
        the file name

    - #### getLineNumber

          public int getLineNumber(int level)

      Get the line number within a file
      Parameters:
        `level` - Number of calling function
      Returns:
        the line number

    - #### getClassCount

          public int getClassCount()

      Get the count of classes
      Returns:
        the number of classes

    - #### getClass

          public Class<?> getClass(int level)

      Get the Class that owns the function
      Parameters:
        `level` - Number of calling function
      Returns:
        the function owner

    - #### getClassNameElements

          public Iterator<String> getClassNameElements()

      To iterate over the class names
      Returns:
        an iterator of class names

    - #### getFunctionNameElements

          public Iterator<String> getFunctionNameElements()

      To iterate over the function names
      Returns:
        an iterator of function names

    - #### getFullFunctionNameElements

          public Iterator<String> getFullFunctionNameElements()

      To iterate over the full function names
      Returns:
        an iterator of full function names