org.apache.avalon.excalibur.util
Class StackIntrospector

java.lang.Object
  |
  +--org.apache.avalon.excalibur.util.StackIntrospector

public final class StackIntrospector
extends java.lang.Object

A set of utilities to inspect current stack frame.

Version:
CVS $Revision: 1.4 $ $Date: 2001/12/11 09:53:37 $
Author:
Sylvain Wallez, Stuart Roebuck, Peter Donald

Method Summary
static java.lang.Class getCallerClass(java.lang.Class clazz)
          Find the caller of the passed in Class.
static java.lang.Class getCallerClass(int index)
          Find the caller of the passed in Class.
static java.lang.String getCallerMethod(java.lang.Class clazz)
          Get the name of the method that called specified class.
static java.lang.String getCallerMethod(int index)
          Get the name of the method is at specified index in call stack.
static java.lang.String[] getCallerStack(java.lang.Class clazz, int count)
          Return the call stack that called specified Class as an array of Strings.
static java.lang.String[] getCallStackAsStringArray()
          Return the current call stack as a String array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getCallerClass

public static final java.lang.Class getCallerClass(int index)
                                            throws java.lang.SecurityException
Find the caller of the passed in Class. May return null if caller not found on execution stack
Parameters:
clazz - the Class to search for on stack to find caller of
Returns:
the Class of object that called parrameter class
Throws:
java.lang.SecurityException - if an existing SecurityManager disallows construction of another SecurityManager and thus blocks method results

getCallerClass

public static final java.lang.Class getCallerClass(java.lang.Class clazz)
                                            throws java.lang.SecurityException
Find the caller of the passed in Class. May return null if caller not found on execution stack
Parameters:
clazz - the Class to search for on stack to find caller of
Returns:
the Class of object that called parrameter class
Throws:
java.lang.SecurityException - if an existing SecurityManager disallows construction of another SecurityManager and thus blocks method results

getCallerMethod

public static final java.lang.String getCallerMethod(int index)
Get the name of the method is at specified index in call stack.
Returns:
The method path name in the form "the.package.MyClass.method(MyClass:121)"

getCallerMethod

public static final java.lang.String getCallerMethod(java.lang.Class clazz)
Get the name of the method that called specified class.
Returns:
The method path name in the form "the.package.MyClass.method(MyClass:121)" or null if unable to determine caller.

getCallerStack

public static final java.lang.String[] getCallerStack(java.lang.Class clazz,
                                                      int count)
Return the call stack that called specified Class as an array of Strings. The maximum size of call-stack is specified by count parameter.

This can be useful for debugging code to determine where calls to a method are coming from.

Parameters:
clazz - the last class on the stack you are not interested in!
count - the number of stack entries to return.
Returns:
An array of method names in the form "the.package.MyClass.method(MyClass:121)"

getCallStackAsStringArray

public static final java.lang.String[] getCallStackAsStringArray()
Return the current call stack as a String array.

This can be useful for debugging code to determine where calls to a method are coming from.

Returns:
The array of strings containing methods in the form "the.package.MyClass.method(MyClass:121)"


Copyright © 2001 Apache Jakarta Project. All Rights Reserved.