Class ProfileStackFrame

  • All Implemented Interfaces:
    Comparable

    public class ProfileStackFrame
    extends Object
    implements Comparable
    This class defines a data structure for holding information about a stack frame captured by the Directory Server profiler. It will contain the class and method name for this frame, the set of line numbers within that method that were captured along with the number of times they were seen, as well as references to subordinate frames that were encountered.
    • Constructor Detail

      • ProfileStackFrame

        public ProfileStackFrame​(String className,
                                 String methodName)
        Creates a new profile stack frame with the provided information.
        Parameters:
        className - The class name for use in this stack frame.
        methodName - The method name for use in this stack frame.
    • Method Detail

      • getClassName

        public String getClassName()
        Retrieves the class name for this stack frame.
        Returns:
        The class name for this stack frame.
      • getMethodName

        public String getMethodName()
        Retrieves the method name for this stack frame.
        Returns:
        The method name for this stack frame.
      • getHTMLSafeMethodName

        public String getHTMLSafeMethodName()
        Retrieves the method name for this stack frame in a manner that will be safe for use in an HTML context. Currently, this simply replaces angle brackets with the appropriate HTML equivalent.
        Returns:
        The generated safe name.
      • getLineNumbers

        public HashMap<Integer,​Long> getLineNumbers()
        Retrieves the mapping between the line numbers associated with this method and the number of occurrences for each of those line numbers.
        Returns:
        The mapping between the line numbers associated with this method and the number of occurrences for each of those line numbers.
      • updateLineNumberCount

        public void updateLineNumberCount​(int lineNumber,
                                          long numOccurrences)
        Updates the count for the number of occurrences of a given stack frame for the specified line number.
        Parameters:
        lineNumber - The line number for which to update the count.
        numOccurrences - The number of times the specified line was encountered for this stack frame.
      • getTotalCount

        public long getTotalCount()
        Retrieves the total number of times that a frame with this class and method name was seen by the profiler thread.
        Returns:
        The total number of times that a frame with this class and method name was seen by the profiler thread.
      • getSubordinateFrames

        public ProfileStackFrame[] getSubordinateFrames()
        Retrieves an array containing the subordinate frames that were seen below this frame in stack traces. The elements of the array will be sorted in descending order of the number of occurrences.
        Returns:
        An array containing the subordinate frames that were seen below this frame in stack traces.
      • hasSubFrames

        public boolean hasSubFrames()
        Indicates whether this stack frame has one or more subordinate frames.
        Returns:
        true if this stack frame has one or more subordinate frames, or false if not.
      • recurseSubFrames

        public void recurseSubFrames​(ProfileStack stack,
                                     int depth,
                                     long count,
                                     HashMap<String,​HashMap<ProfileStack,​Long>> stacksByMethod)
        Recursively processes the frames of the provided stack, adding them as nested subordinate frames of this stack frame.
        Parameters:
        stack - The stack trace to use to obtain the frames.
        depth - The slot of the next frame to process in the provided array.
        count - The number of occurrences for the provided stack.
        stacksByMethod - The set of stack traces mapped from method name to their corresponding stack traces.
      • hashCode

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

        public boolean equals​(Object o)
        Indicates whether the provided object is equal to this stack frame. It will be considered equal if it is a profile stack frame with the same class and method name.
        Overrides:
        equals in class Object
        Parameters:
        o - The object for which to make the determination.
        Returns:
        true if the provided object may be considered equal to this stack frame, or false if not.
      • compareTo

        public int compareTo​(Object o)
                      throws ClassCastException
        Indicates the order of this profile stack frame relative to the provided object in a sorted list. The order will be primarily based on number of occurrences, with an equivalent number of occurrences falling back on alphabetical by class and method names.
        Specified by:
        compareTo in interface Comparable
        Parameters:
        o - The object for which to make the comparison.
        Returns:
        A negative integer if this stack frame should come before the provided object in a sorted list, a positive integer if it should come after the provided object, or zero if they should have equivalent order.
        Throws:
        ClassCastException - If the provided object is not a profile stack frame.
      • toString

        public String toString()
        Retrieves a string representation of this stack frame. It will contain the total number of matching frames, the class name, and the method name.
        Overrides:
        toString in class Object
        Returns:
        A string representation of this stack frame.