public String [ ] getProperties ( String key ) { // Try to get the callers class name and method name by throwing an exception an searching the stack frames. String className = null ; String methodName = null ; /* Java 1.4 onwards only. try { throw new Exception(); } catch (Exception e) { StackTraceElement[] stack = e.getStackTrace(); // Check that the stack trace contains at least two elements, one for this method and one for the caller. if (stack.length >= 2) { className = stack[1].getClassName(); methodName = stack[1].getMethodName(); } }*/ return getProperties ( className , methodName , key ) ; }
Looks up an array property value relative to the environment callers class and method . The default environment will be checked for a matching array property if defaults are being used . In order to work out the callers class and method this method throws an exception and then searches one level up its stack frames .