Class TextTreeRenderer

  • All Implemented Interfaces:
    TreeRenderer

    @Experimental
    public class TextTreeRenderer
    extends Object
    implements TreeRenderer
    A simple recursive printer. Output looks like so:
    
     +- LocalVariableDeclaration
        +- Type
        |  +- PrimitiveType
        +- VariableDeclarator
           +- VariableDeclaratorId
           +- VariableInitializer
              +- 1 child not shown
    
     
    or
    
     └─ LocalVariableDeclaration
        ├─ Type
        │  └─ PrimitiveType
        └─ VariableDeclarator
           ├─ VariableDeclaratorId
           └─ 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 Detail

      • 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 by appendBoundaryForNodeLn(Node, Appendable, String).
    • Method Detail

      • renderSubtree

        public void renderSubtree​(Node node,
                                  Appendable out)
                           throws IOException
        Description copied from interface: TreeRenderer
        Appends 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:
        renderSubtree in interface TreeRenderer
        Parameters:
        node - Node to render
        out - Object onto which the output is appended
        Throws:
        IOException - If an IO error occurs while appending to the output
      • appendNodeInfoLn

        protected void appendNodeInfoLn​(Appendable out,
                                        Node node)
                                 throws IOException
        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