bb.util
Class Execute.Caller

java.lang.Object
  extended by bb.util.Execute.Caller
Enclosing class:
Execute

private static class Execute.Caller
extends Object

Records information about the class that is calling Execute: its class name, method name, and whether or not it is the actual program entry point of the current Java process.

This class is multithread safe: it is immutable.


Field Summary
private  String className
           
private static String classNameCaller
           
private static String classNameExecute
           
private static String classNameThread
           
private  boolean isProgramEntryPoint
           
private  String methodName
           
 
Constructor Summary
private Execute.Caller()
          First acquires the stack trace of the current thread.
 
Method Summary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classNameThread

private static final String classNameThread

classNameCaller

private static final String classNameCaller

classNameExecute

private static final String classNameExecute

className

private final String className

methodName

private final String methodName

isProgramEntryPoint

private final boolean isProgramEntryPoint
Constructor Detail

Execute.Caller

private Execute.Caller()
                throws IllegalStateException
First acquires the stack trace of the current thread. Then confirms that the 0th element comes from Thread.getStackTrace. Next starts searching the remaining elements. The first StackTraceElement that it comes across whose class name does not equal this class's or Execute's is the class/method that is calling Execute; this element is used to assign className and methodName. Assigns true to isProgramEntryPoint if and only if methodName equals main and the StackTraceElement that methodName was taken from is the last stack trace element. (If you only checked that methodName equals main, then the caller of this class could also be merely a main that is being ultimately called by some other main which is the true program entry point.)

Throws:
IllegalStateException - if some unexpected state is encountered