|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.singularsys.jep.PrintVisitor
public class PrintVisitor
Prints an expression. Prints the expression with lots of brackets. ((-1.0)/sqrt((1.0-(x^2.0)))). To use
Jep j = ...; Node in = ...; j.print(in, "x");
Jep.print(Node)
,
Jep.print(Node, PrintStream)
,
Jep.println(Node)
,
Jep.println(Node, PrintStream)
,
Jep.toString(Node)
,
Serialized FormNested Class Summary | |
---|---|
static interface |
PrintVisitor.PrintRulesI
This interface specifies the method needed to implement a special print rule. |
Field Summary | |
---|---|
static int |
COMPLEX_I
Print Complex as 3+2 i |
protected java.text.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 java.lang.StringBuffer |
sb
|
Constructor Summary | |
---|---|
PrintVisitor()
Creates a visitor to create and print string representations of an expression tree. |
Method Summary | |
---|---|
void |
addSpecialRule(Operator op,
PrintVisitor.PrintRulesI rules)
Adds a special print rule to be added for a given operator. |
void |
append(java.lang.String s)
Add a string to buffer. |
java.lang.String |
formatValue(java.lang.Object val)
Returns a formatted version of the value. |
void |
formatValue(java.lang.Object val,
java.lang.StringBuffer sb1)
Appends a formatted versions of val to the string buffer. |
JepComponent |
getLightWeightInstance()
Gets a light-weight instance suitable for using in multiple threads. |
int |
getMaxLen()
|
int |
getMode()
Return the current print mode. |
boolean |
getMode(int testmode)
|
void |
init(Jep jep)
Initialize the component. |
void |
print(Node node)
Prints on System.out. |
void |
print(Node node,
java.io.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,
java.io.PrintStream out)
Prints the tree descending from node with a newline at end. |
void |
printWrap(java.lang.StringBuffer sb,
java.io.PrintStream out)
Utility method to print a wrapped version of the output. |
void |
setMaxLen(int i)
Sets the maximum length printed per line. |
void |
setMode(int mode,
boolean flag)
Set printing mode. |
void |
setNumberFormat(java.text.NumberFormat format)
|
java.lang.String |
toString(Node node)
Returns a String representation of the equation. |
java.lang.Object |
visit(ASTConstant node,
java.lang.Object data)
|
java.lang.Object |
visit(ASTFunNode node,
java.lang.Object data)
prints a standard function: fun(arg, arg) |
java.lang.Object |
visit(ASTOpNode node,
java.lang.Object data)
|
java.lang.Object |
visit(ASTVarNode node,
java.lang.Object data)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int FULL_BRACKET
public static final int COMPLEX_I
protected transient java.lang.StringBuffer sb
protected int mode
protected java.text.NumberFormat format
Constructor Detail |
---|
public PrintVisitor()
Method Detail |
---|
public void init(Jep jep)
JepComponent
init
in interface JepComponent
jep
- the current Jep instancepublic void print(Node node, java.io.PrintStream out)
Jep.println(Node, PrintStream)
public void printWrap(java.lang.StringBuffer sb, java.io.PrintStream out)
sb
- the StringBuffer to printout
- the output streampublic void print(Node node)
public void println(Node node, java.io.PrintStream out)
public void println(Node node)
public java.lang.String toString(Node node)
public void append(java.lang.String s)
public void addSpecialRule(Operator op, PrintVisitor.PrintRulesI rules)
public java.lang.Object visit(ASTFunNode node, java.lang.Object data) throws JepException
visit
in interface ParserVisitor
JepException
public java.lang.Object visit(ASTOpNode node, java.lang.Object data) throws JepException
visit
in interface ParserVisitor
JepException
public java.lang.Object visit(ASTVarNode node, java.lang.Object data) throws JepException
visit
in interface ParserVisitor
JepException
public java.lang.Object visit(ASTConstant node, java.lang.Object data) throws JepException
visit
in interface ParserVisitor
JepException
public void formatValue(java.lang.Object val, java.lang.StringBuffer sb1)
val
- The value to formatsb1
- The StringBuffer to append topublic java.lang.String formatValue(java.lang.Object val)
public 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(java.text.NumberFormat format)
public void setMaxLen(int i)
i
- the maximum lengthpublic int getMaxLen()
public JepComponent getLightWeightInstance()
JepComponent
getLightWeightInstance
in interface JepComponent
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |