public StackTraceElement getStackTraceElement ( Class stackClass ) { Stopwatch s = stackTraceTimer . start ( ) ; Throwable t = new Throwable ( ) ; StackTraceElement [ ] stArray = t . getStackTrace ( ) ; int stackSize = stArray . length ; StackTraceElement st = null ; for ( int i = 0 ; i < stackSize ; i ++ ) { boolean found = false ; while ( stArray [ i ] . getClassName ( ) . equals ( stackClass . getName ( ) ) ) { ++ i ; found = true ; } if ( found ) { st = stArray [ i ] ; } } s . stop ( ) ; return st ; }
Gets the starting calling stack trace element of a given stack which matches the given class name . Given the wrapper class name the match continues until the last stack trace element of the wrapper class is matched .