Class TreeDumper
java.lang.Object
com.randomnoun.common.jexl.visitor.DepthFirstVisitor
com.randomnoun.common.jexl.visitor.TreeDumper
- All Implemented Interfaces:
Visitor
Dumps the syntax tree to a Writer using the location information in
each NodeToken.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor uses System.out as its output location.TreeDumper
(Writer o) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Flushes the OutputStream or Writer that this TreeDumper is using.void
printSpecials
(boolean b) Allows you to specify whether or not to print special tokens.void
Resets the position of the output "cursor" to the first line and column.void
Starts the tree dumper on the line containing the next token visited.void
Dumps the current NodeToken to the output stream being used.
-
Field Details
-
out
-
-
Constructor Details
-
TreeDumper
public TreeDumper()The default constructor uses System.out as its output location. You may specify your own Writer or OutputStream using one of the other constructors. -
TreeDumper
-
TreeDumper
-
-
Method Details
-
flushWriter
Flushes the OutputStream or Writer that this TreeDumper is using. -
printSpecials
Allows you to specify whether or not to print special tokens. -
startAtNextToken
Starts the tree dumper on the line containing the next token visited. For example, if the next token begins on line 50 and the dumper is currently on line 1 of the file, it will set its current line to 50 and continue printing from there, as opposed to printing 49 blank lines and then printing the token. -
resetPosition
Resets the position of the output "cursor" to the first line and column. When using a dumper on a syntax tree more than once, you either need to call this method or startAtNextToken() between each dump. -
visit
Dumps the current NodeToken to the output stream being used.- Specified by:
visit
in interfaceVisitor
- Overrides:
visit
in classDepthFirstVisitor
- Throws:
IllegalStateException
- if the token position is invalid relative to the current position, i.e. its location places it before the previous token.
-