public class PrintVisitor extends ErrorCatchingVisitor
XJep j = ...; Node in = ...; j.print(in,"x");
XJep.print(Node),
XJep.print(Node, PrintStream),
XJep.println(Node),
XJep.println(Node, PrintStream),
XJep.toString(Node)| Modifier and Type | Class and Description |
|---|---|
static interface |
PrintVisitor.PrintRulesI
This interface specifies the method needed to implement a special print rule.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
COMPLEX_I
Print Complex as 3+2 i
|
protected NumberFormat |
format
The NumberFormat object used to print numbers.
|
static int |
FULL_BRACKET
All brackets are printed.
|
protected int |
mode
The current mode for printing.
|
protected StringBuffer |
sb |
| Constructor and Description |
|---|
PrintVisitor()
Creates a visitor to create and print string representations of an expression tree.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addSpecialRule(Operator op,
PrintVisitor.PrintRulesI rules)
Adds a special print rule to be added for a given operator.
|
void |
append(String s)
Add a string to buffer.
|
String |
formatValue(Object val)
Returns a formated version of the value.
|
void |
formatValue(Object val,
StringBuffer sb1)
Appends a formatted versions of val to the string buffer.
|
int |
getMaxLen() |
int |
getMode()
Return the current print mode.
|
boolean |
getMode(int testmode) |
void |
print(Node node)
Prints on System.out.
|
void |
print(Node node,
PrintStream out)
Prints the tree descending from node with lots of brackets
or specified stream.
|
void |
println(Node node)
Prints on System.out.
|
void |
println(Node node,
PrintStream out)
Prints the tree descending from node with a newline at end.
|
void |
setMaxLen(int i)
Sets the maximum length printed per line.
|
void |
setMode(int mode,
boolean flag)
Set printing mode.
|
void |
setNumberFormat(NumberFormat format) |
String |
toString(Node node)
returns a String representation of the equation.
|
Object |
visit(ASTConstant node,
Object data) |
Object |
visit(ASTFunNode node,
Object data) |
Object |
visit(ASTVarNode node,
Object data) |
acceptCatchingErrors, addError, clearErrors, getError, getErrorsMessage, hasErrorsacceptChildrenAsArray, visit, visitpublic static final int FULL_BRACKET
public static final int COMPLEX_I
protected StringBuffer sb
protected int mode
protected NumberFormat format
public PrintVisitor()
public void print(Node node, PrintStream out)
XJep.println(Node, PrintStream)public void print(Node node)
public void println(Node node, PrintStream out)
public void println(Node node)
public void append(String s)
public void addSpecialRule(Operator op, PrintVisitor.PrintRulesI rules)
public Object visit(ASTFunNode node, Object data) throws ParseException
visit in interface ParserVisitorvisit in class DoNothingVisitorParseExceptionpublic Object visit(ASTVarNode node, Object data) throws ParseException
visit in interface ParserVisitorvisit in class DoNothingVisitorParseExceptionpublic Object visit(ASTConstant node, Object data)
visit in interface ParserVisitorvisit in class DoNothingVisitorpublic void formatValue(Object val, StringBuffer sb1)
val - The value to formatsb1 - The StingBuffer to append topublic int getMode()
public boolean getMode(int testmode)
public void setMode(int mode,
boolean flag)
mode - which flags to change, typically FULL_BRACKETflag - whether to switch this mode on or offpublic void setNumberFormat(NumberFormat format)
public void setMaxLen(int i)
i - the maximum lengthpublic int getMaxLen()
Copyright © 2018. All rights reserved.