org.crosswire.common.util
Class CallContext

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

public 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.

Distribution Licence:
JSword is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
The License is available on the internet here, or by writing to: Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
The copyright to this program is held by it's authors.

Version:
$Id: CallContext.java,v 1.4 2005/03/06 20:21:59 dmsmith Exp $
Author:
DM Smith [ dmsmith555 at yahoo dot com]
See Also:
Licence

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-2004