org.crosswire.common.util

## Class CallContext

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

-     public final class CallContext
      extends Object

  This singleton class provides a way for a method to determine which class called it.

  It has been tested to work in command line and WebStart environments.

  Author:
    DM Smith
  See Also:
    `The GNU Lesser General Public License for details.`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private static int` | `CALL_CONTEXT_OFFSET` Offset needed to represent the caller of the method that called this method.
    `private static CallContext` | `resolver`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `private` | `CallContext()` Prevent instantiation

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Class<?>` | `getCallingClass()` When called from a method it will return the class calling that method.
    `static Class<?>` | `getCallingClass(int i)` When called from a method it will return the i-th class calling that method, up the call chain.
    `static CallContext` | `instance()` Singleton accessor

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

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

- - ### Field Detail

    - #### CALL_CONTEXT_OFFSET

          private static final int CALL_CONTEXT_OFFSET

      Offset needed to represent the caller of the method that called this method.
      See Also:
        Constant Field Values

    - #### resolver

          private static CallContext resolver

  - ### Constructor Detail

    - #### CallContext

          private CallContext()

      Prevent instantiation

  - ### Method Detail

    - #### instance

          public static CallContext instance()

      Singleton accessor
      Returns:
        this singleton

    - #### getCallingClass

          public static Class<?> getCallingClass()

      When called from a method it will return the class calling that method.
      Returns:
        the immediate calling class

    - #### getCallingClass

          public static Class<?> getCallingClass(int i)

      When called from a method it will return the i-th class calling that method, up the call chain. If used with a -1 it will return the class making the call -2 and -3 will return this class
      Parameters:
        `i` - the i-th coller
      Returns:
        the desired calling class
      Throws:
        `ArrayIndexOutOfBoundsException` - if the index is not valid