Class StackTrace


  • public abstract class StackTrace
    extends Object
    Class for providing StackTrace functionality.
    Since:
    20.06
    Author:
    cp 2000.08.02
    • Constructor Detail

      • StackTrace

        public StackTrace()
    • Method Detail

      • getCallerStackFrame

        public static StackTrace.StackFrame getCallerStackFrame()
        Get the StackFrame information for the caller of the current method.
        Returns:
        the StackFrame information for the caller of the current method
      • getStackFrame

        public static StackTrace.StackFrame getStackFrame()
        Get the StackFrame information for the current method.
        Returns:
        the StackFrame information for the current method
      • getStackFrames

        public static StackTrace.StackFrame[] getStackFrames()
        Iterate the StackFrame information for all callers, going from the inside outwards, and starting with the caller of this method.
        Returns:
        an Iterator of StackFrames
      • getStackTrace

        public static String getStackTrace()
        Build a stack trace for the current thread.
        Returns:
        a String containing a printable stack trace
      • getStackTrace

        public static String getStackTrace​(Throwable e)
        Build a stack trace for the passed exception that does not include the exception description itself.
        Parameters:
        e - a Throwable object that contains stack trace information
        Returns:
        a String containing a printable stack trace
      • getDeepMessage

        public static String getDeepMessage​(Throwable t,
                                            String sDelim)
        Extract a throwable's message, and all causal messages.
        Parameters:
        t - the throwable
        sDelim - the delimiter to include between messages
        Returns:
        the concatenated messages
      • printStackTrace

        public static String printStackTrace​(Throwable e)
        Build a stack trace for the passed exception.
        Parameters:
        e - a Throwable object that contains stack trace information
        Returns:
        a String containing a printable stack trace
      • ensureBigDecimal

        public static BigDecimal ensureBigDecimal​(Number num)
        Ensure the specified Number is a BigDecimal value or convert it into a new BigDecimal object.
        Parameters:
        num - a Number object
        Returns:
        a BigDecimal object that is equal to the passed in Number
      • getExpression

        public static String getExpression​(String sMethod)
        Get the source code expression from the method that called the specified method.
        Parameters:
        sMethod - the first method on the stack after the method whose source code is desired
        Returns:
        null on any failure, otherwise the expression
      • getStackTrace

        public static String getStackTrace​(Thread t)
        Print stack trace for running thread.
        Parameters:
        t - thread
        Returns:
        thread stack trace or empty string if thread is not running