org.crosswire.common.util
Class CallContext

java.lang.Object
  extended by java.lang.SecurityManager
      extended by org.crosswire.common.util.CallContext

public final class CallContext
extends SecurityManager

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 [ dmsmith555 at yahoo dot com]
See Also:
for license details.
The copyright to this program is held by it's authors.

Field Summary
private static int CALL_CONTEXT_OFFSET
          Offset needed to represent the caller of the method that called this method.
private static CallContext resolver
           
 
Fields inherited from class java.lang.SecurityManager
inCheck
 
Constructor Summary
private CallContext()
          Prevent instansiation
 
Method Summary
 Class getCallingClass()
          When called from a method it will return the class calling that method.
 Class getCallingClass(int i)
          When called from a method it will return the i-th class calling that method, up the call chain.
protected  Class[] getClassContext()
           
static CallContext instance()
          Singleton accessor
 
Methods inherited from class java.lang.SecurityManager
checkAccept, checkAccess, checkAccess, checkAwtEventQueueAccess, checkConnect, checkConnect, checkCreateClassLoader, checkDelete, checkExec, checkExit, checkLink, checkListen, checkMemberAccess, checkMulticast, checkMulticast, checkPackageAccess, checkPackageDefinition, checkPermission, checkPermission, checkPrintJobAccess, checkPropertiesAccess, checkPropertyAccess, checkRead, checkRead, checkRead, checkSecurityAccess, checkSetFactory, checkSystemClipboardAccess, checkTopLevelWindow, checkWrite, checkWrite, classDepth, classLoaderDepth, currentClassLoader, currentLoadedClass, getInCheck, getSecurityContext, getThreadGroup, inClass, inClassLoader
 
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 instansiation

Method Detail

instance

public static CallContext instance()
Singleton accessor


getClassContext

protected Class[] getClassContext()
Overrides:
getClassContext in class SecurityManager

getCallingClass

public Class getCallingClass()
When called from a method it will return the class calling that method.


getCallingClass

public 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

Throws:
ArrayIndexOutOfBoundsException - if the index is not valid

Copyright ยจ 2003-2006