Class ProfileStack


  • public class ProfileStack
    extends Object
    This class defines a data structure that may be used to hold information about a thread stack trace.
    • Field Detail

      • LINE_NUMBER_UNKNOWN

        public static final int LINE_NUMBER_UNKNOWN
        The line number that will be used for stack frames in which the line number is unknown but it is not a native method.
        See Also:
        Constant Field Values
      • LINE_NUMBER_NATIVE

        public static final int LINE_NUMBER_NATIVE
        The line number that will be used for stack frames in which the line number is unknown because it is a native method.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ProfileStack

        public ProfileStack​(StackTraceElement[] stackElements)
        Creates a new profile stack with the provided information.
        Parameters:
        stackElements - The stack trace elements to use to create this profile stack.
    • Method Detail

      • getNumFrames

        public int getNumFrames()
        Retrieves the number of frames in this stack.
        Returns:
        The number of frames in this stack.
      • getClassNames

        public String[] getClassNames()
        Retrieves the class names in this stack.
        Returns:
        The class names in this stack.
      • getClassName

        public String getClassName​(int depth)
        Retrieves the class name from the specified frame in the stack.
        Parameters:
        depth - The depth of the frame to retrieve, with the first frame being frame zero.
        Returns:
        The class name from the specified frame in the stack.
      • getMethodNames

        public String[] getMethodNames()
        Retrieves the method names in this stack.
        Returns:
        The method names in this stack.
      • getMethodName

        public String getMethodName​(int depth)
        Retrieves the method name from the specified frame in the stack.
        Parameters:
        depth - The depth of the frame to retrieve, with the first frame being frame zero.
        Returns:
        The method name from the specified frame in the stack.
      • getLineNumbers

        public int[] getLineNumbers()
        Retrieves the line numbers in this stack.
        Returns:
        The line numbers in this stack.
      • getLineNumber

        public int getLineNumber​(int depth)
        Retrieves the line number from the specified frame in the stack.
        Parameters:
        depth - The depth of the frame for which to retrieve the line number.
        Returns:
        The line number from the specified frame in the stack.
      • hashCode

        public int hashCode()
        Retrieves the hash code for this profile stack. It will be the sum of the hash codes for the class and method name and line number for the first frame.
        Overrides:
        hashCode in class Object
        Returns:
        The hash code for this profile stack.
      • equals

        public boolean equals​(Object o)
        Indicates whether to the provided object is equal to this profile stack.
        Overrides:
        equals in class Object
        Parameters:
        o - The object for which to make the determination.
        Returns:
        true if the provided object is a profile stack object with the same set of class names, method names, and line numbers as this profile stack, or false if not.
      • write

        public void write​(ASN1Writer writer)
                   throws IOException
        Encodes and writes this profile stack to the capture file.
        Parameters:
        writer - The writer to use.
        Throws:
        IOException - if an error occurs while writing.
      • decode

        public static ProfileStack decode​(ASN1Reader reader)
                                   throws IOException
        Decodes the contents of the provided element as a profile stack.
        Parameters:
        reader - The ASN.1 reader to read the encoded profile stack information from.
        Returns:
        The decoded profile stack.
        Throws:
        IOException - If the element could not be decoded for some reason.