Class StackTraceScanner


  • public final class StackTraceScanner
    extends java.lang.Object
    This class allows you to scan the stacktrace for different stuff.
    Since:
    1.4.1 (24.01.2014)
    Author:
    oliver
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.StackTraceElement find​(java.lang.Class<?> clazz, java.lang.reflect.Method method)
      Find the given method on the stack trace.
      static java.lang.StackTraceElement find​(java.lang.Class<?> clazz, java.lang.String methodName)
      Find the given method on the stack trace.
      static java.lang.StackTraceElement find​(java.lang.String classname, java.lang.String methodName)
      Find the given method on the stack trace.
      static java.lang.StackTraceElement find​(org.aspectj.lang.Signature signature)
      Find the given signature on the stack trace.
      static java.lang.StackTraceElement findConstructor​(java.lang.Class<?> clazz)
      Find the constructor of the given class on the stack trace.
      static java.lang.Class<?> getCallerClass()
      Gets the caller class by examing the stacktrace.
      static java.lang.Class<?> getCallerClass​(java.util.regex.Pattern... excluded)
      Gets the caller class by examing the stacktrace.
      static java.lang.Class<?> getCallerClass​(java.util.regex.Pattern[] excludedMethods, java.lang.Class<?>... excludedClasses)
      Gets the caller class by examing the stacktrace.
      static java.lang.StackTraceElement getCallerOf​(java.lang.Class<?> clazz, java.lang.reflect.Method method)
      Gets the caller of the given method.
      static java.lang.StackTraceElement getCallerOf​(java.lang.Class<?> clazz, java.lang.reflect.Method method, java.util.regex.Pattern... excluded)
      Gets the caller of the given method.
      static java.lang.StackTraceElement getCallerOf​(java.lang.Class<?> clazz, java.lang.String methodName)
      Gets the caller of the given method.
      static java.lang.StackTraceElement getCallerOf​(java.lang.Class<?> clazz, java.lang.String methodName, java.util.regex.Pattern... excluded)
      Gets the caller of the given method.
      static java.lang.StackTraceElement getCallerOf​(java.lang.String classname, java.lang.String methodName)
      Gets the caller of the given method.
      static java.lang.StackTraceElement getCallerOf​(java.lang.String classname, java.lang.String methodName, java.util.regex.Pattern... excluded)
      Gets the caller of the given method.
      static java.lang.StackTraceElement getCallerOf​(org.aspectj.lang.Signature signature)
      Gets the caller of the given signature.
      static java.lang.StackTraceElement getCallerOf​(org.aspectj.lang.Signature signature, java.util.regex.Pattern... excluded)
      Gets the caller of the given signature.
      static java.lang.StackTraceElement getCallerOfConstructor​(java.lang.Class<?> clazz)
      Gets the caller of a constructor.
      static java.lang.StackTraceElement getCallerOfConstructor​(java.lang.Class<?> clazz, java.util.regex.Pattern... excluded)
      Gets the caller of a constructor.
      static java.lang.StackTraceElement[] getCallerStackTrace()
      Gets the caller stack trace of the method or constructor which calls it.
      static java.lang.StackTraceElement[] getCallerStackTrace​(java.util.regex.Pattern... excluded)
      Gets the caller stack trace of the method or constructor which calls it.
      static java.lang.StackTraceElement[] getCallerStackTrace​(java.util.regex.Pattern[] excludedMethods, java.lang.Class<?>... excludedClasses)
      Gets the caller stack trace of the method or constructor which calls it.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • findConstructor

        public static java.lang.StackTraceElement findConstructor​(java.lang.Class<?> clazz)
        Find the constructor of the given class on the stack trace.
        Parameters:
        clazz - the clazz
        Returns:
        the stack trace element
      • find

        public static java.lang.StackTraceElement find​(org.aspectj.lang.Signature signature)
        Find the given signature on the stack trace.
        Parameters:
        signature - the signature
        Returns:
        the stack trace element
      • find

        public static java.lang.StackTraceElement find​(java.lang.Class<?> clazz,
                                                       java.lang.reflect.Method method)
        Find the given method on the stack trace.
        Parameters:
        clazz - the clazz
        method - the method
        Returns:
        the stack trace element
      • find

        public static java.lang.StackTraceElement find​(java.lang.Class<?> clazz,
                                                       java.lang.String methodName)
        Find the given method on the stack trace.
        Parameters:
        clazz - the clazz
        methodName - the method name
        Returns:
        the stack trace element
      • find

        public static java.lang.StackTraceElement find​(java.lang.String classname,
                                                       java.lang.String methodName)
        Find the given method on the stack trace.
        Parameters:
        classname - the classname
        methodName - the method name
        Returns:
        the stack trace element
      • getCallerOfConstructor

        public static java.lang.StackTraceElement getCallerOfConstructor​(java.lang.Class<?> clazz)
        Gets the caller of a constructor.
        Parameters:
        clazz - the clazz
        Returns:
        the caller of constructor
      • getCallerOfConstructor

        public static java.lang.StackTraceElement getCallerOfConstructor​(java.lang.Class<?> clazz,
                                                                         java.util.regex.Pattern... excluded)
        Gets the caller of a constructor.
        Parameters:
        clazz - the clazz
        excluded - the excluded
        Returns:
        the caller of constructor
      • getCallerOf

        public static java.lang.StackTraceElement getCallerOf​(org.aspectj.lang.Signature signature)
        Gets the caller of the given signature.
        Parameters:
        signature - the signature
        Returns:
        the caller of
      • getCallerOf

        public static java.lang.StackTraceElement getCallerOf​(java.lang.Class<?> clazz,
                                                              java.lang.reflect.Method method)
        Gets the caller of the given method.
        Parameters:
        clazz - the clazz
        method - the method
        Returns:
        the caller of
      • getCallerOf

        public static java.lang.StackTraceElement getCallerOf​(java.lang.Class<?> clazz,
                                                              java.lang.String methodName)
        Gets the caller of the given method.
        Parameters:
        clazz - the clazz
        methodName - the method name
        Returns:
        the caller of
      • getCallerOf

        public static java.lang.StackTraceElement getCallerOf​(java.lang.String classname,
                                                              java.lang.String methodName)
        Gets the caller of the given method.
        Parameters:
        classname - the classname
        methodName - the method name
        Returns:
        the caller of
      • getCallerOf

        public static java.lang.StackTraceElement getCallerOf​(org.aspectj.lang.Signature signature,
                                                              java.util.regex.Pattern... excluded)
        Gets the caller of the given signature.
        Parameters:
        signature - the signature
        excluded - the excluded
        Returns:
        the caller of
      • getCallerOf

        public static java.lang.StackTraceElement getCallerOf​(java.lang.Class<?> clazz,
                                                              java.lang.reflect.Method method,
                                                              java.util.regex.Pattern... excluded)
        Gets the caller of the given method.
        Parameters:
        clazz - the clazz
        method - the method
        excluded - a list of filters which should be not considered as caller
        Returns:
        the caller of
      • getCallerOf

        public static java.lang.StackTraceElement getCallerOf​(java.lang.Class<?> clazz,
                                                              java.lang.String methodName,
                                                              java.util.regex.Pattern... excluded)
        Gets the caller of the given method.
        Parameters:
        clazz - the clazz
        methodName - the method name
        excluded - a list of filters which should be not considered as caller
        Returns:
        the caller of
      • getCallerOf

        public static java.lang.StackTraceElement getCallerOf​(java.lang.String classname,
                                                              java.lang.String methodName,
                                                              java.util.regex.Pattern... excluded)
        Gets the caller of the given method.
        Parameters:
        classname - the classname
        methodName - the method name
        excluded - a list of filters which should be not considered as caller
        Returns:
        the caller of
      • getCallerClass

        public static java.lang.Class<?> getCallerClass()
        Gets the caller class by examing the stacktrace.
        Returns:
        the caller class
      • getCallerClass

        public static java.lang.Class<?> getCallerClass​(java.util.regex.Pattern... excluded)
        Gets the caller class by examing the stacktrace.
        Parameters:
        excluded - a list of filters which should be not considered as caller
        Returns:
        the caller of
      • getCallerClass

        public static java.lang.Class<?> getCallerClass​(java.util.regex.Pattern[] excludedMethods,
                                                        java.lang.Class<?>... excludedClasses)
        Gets the caller class by examing the stacktrace.
        Parameters:
        excludedMethods - the excluded methods
        excludedClasses - the excluded classes
        Returns:
        the caller class
      • getCallerStackTrace

        public static java.lang.StackTraceElement[] getCallerStackTrace()
        Gets the caller stack trace of the method or constructor which calls it.
        Returns:
        the caller stack trace
        Since:
        1.4.2 (17.05.2014)
      • getCallerStackTrace

        public static java.lang.StackTraceElement[] getCallerStackTrace​(java.util.regex.Pattern... excluded)
        Gets the caller stack trace of the method or constructor which calls it.
        Parameters:
        excluded - a list of filters which should be not considered as caller
        Returns:
        the caller stack trace
        Since:
        1.4.2 (17.05.2014)
      • getCallerStackTrace

        public static java.lang.StackTraceElement[] getCallerStackTrace​(java.util.regex.Pattern[] excludedMethods,
                                                                        java.lang.Class<?>... excludedClasses)
        Gets the caller stack trace of the method or constructor which calls it.
        Parameters:
        excludedMethods - the excluded methods
        excludedClasses - the excluded classes
        Returns:
        the caller stack trace
        Since:
        1.4.2 (17.05.2014)