Class ItemTreeToolkit
- java.lang.Object
-
- org.openjdk.jmc.flightrecorder.rules.tree.ItemTreeToolkit
-
public final class ItemTreeToolkit extends Object
Toolkit for working with item trees.
-
-
Constructor Summary
Constructors Constructor Description ItemTreeToolkit()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
appendLayeredBreakdown(StringBuilder report, ITreeNode<IItem> root, int maxDepth)
Reports all encapsulation layers.static void
appendLongestBreakdown(StringBuilder report, ITreeNode<IItem> root)
Renders a report of the longest encapsulating event chain.static int
getDepth(ITreeNode<?> node)
Returns the number of ancestors the node has.static String
printTree(ITreeNode<IItem> node)
-
-
-
Method Detail
-
printTree
public static String printTree(ITreeNode<IItem> node)
- Returns:
- A String representation of the tree. Useful for debugging.
-
appendLongestBreakdown
public static void appendLongestBreakdown(StringBuilder report, ITreeNode<IItem> root)
Renders a report of the longest encapsulating event chain.If we have A -> (B->D, C->E) and B has longer duration than C, the report will be A => B => D.
- Parameters:
report
- the report to write toroot
- the root node to start from
-
appendLayeredBreakdown
public static void appendLayeredBreakdown(StringBuilder report, ITreeNode<IItem> root, int maxDepth)
Reports all encapsulation layers.If A -> (B->D, C->E), the report will show:
- Layer 1: A (100 %)
- Layer 2: B (X %), C (Y %)
- Layer 3: D (U %), E (V %)
- Parameters:
report
- the report to write toroot
- the root node to start the analysis frommaxDepth
- maximum number of layers to analyze
-
getDepth
public static int getDepth(ITreeNode<?> node)
Returns the number of ancestors the node has.- Parameters:
node
- the node for which to calculate the depth- Returns:
- the depth of the node from the root
-
-