Class TextTreeRenderer
java.lang.Object
net.sourceforge.pmd.util.treeexport.TextTreeRenderer
- All Implemented Interfaces:
TreeRenderer
A simple recursive printer. Output looks like so:
+- LocalVariableDeclaration
+- Type
| +- PrimitiveType
+- VariableDeclarator
+- VariableId
+- VariableInitializer
+- 1 child not shown
or
└─ LocalVariableDeclaration
├─ Type
│ └─ PrimitiveType
└─ VariableDeclarator
├─ VariableId
└─ VariableInitializer
└─ 1 child not shown
By default, just prints the structure, like shown above. You can
configure it to render nodes differently by overriding appendNodeInfoLn(Appendable, Node).-
Constructor Summary
ConstructorsConstructorDescriptionTextTreeRenderer(boolean onlyAscii, int maxLevel) Creates a new text renderer. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendBoundaryForNodeLn(Node node, Appendable out, String indentStr) protected final voidappendIndent(Appendable out, String prefix, boolean isTail) protected voidappendNodeInfoLn(Appendable out, Node node) Append info about the node.voidrenderSubtree(Node node, Appendable out) Appends the subtree rooted at the given node on the provided output writer.
-
Constructor Details
-
TextTreeRenderer
public TextTreeRenderer(boolean onlyAscii, int maxLevel) Creates a new text renderer.- Parameters:
onlyAscii- Whether to output the skeleton of the tree with only ascii characters. If false, uses unicode chars like '├'maxLevel- Max level on which to recurse. Negative means unbounded. If the max level is reached, a placeholder is dumped, like "1 child is not shown". This is controlled byappendBoundaryForNodeLn(Node, Appendable, String).
-
-
Method Details
-
renderSubtree
Description copied from interface:TreeRendererAppends the subtree rooted at the given node on the provided output writer. The implementation is free to filter out some nodes from the subtree.- Specified by:
renderSubtreein interfaceTreeRenderer- Parameters:
node- Node to renderout- Object onto which the output is appended- Throws:
IOException- If an IO error occurs while appending to the output
-
appendIndent
- Throws:
IOException
-
appendNodeInfoLn
Append info about the node. The indent has already been appended. This should end with a newline. The default just appends the name of the node, and no other information.- Throws:
IOException
-
appendBoundaryForNodeLn
protected void appendBoundaryForNodeLn(Node node, Appendable out, String indentStr) throws IOException - Throws:
IOException
-