Package com.singularsys.extensions.djep
Class DPrintVisitor
- java.lang.Object
-
- com.singularsys.jep.PrintVisitor
-
- com.singularsys.extensions.djep.DPrintVisitor
-
- All Implemented Interfaces:
JepComponent
,ParserVisitor
,java.io.Serializable
public class DPrintVisitor extends PrintVisitor
An extension of PrintVisitor which will print the equations of a variable if required. The behaviours of this class is determined by two modes PRINT_PARTIAL_EQNS and PRINT_VARIABLE_EQNS. When a variable or partial derivative is encountered then its equation may be printed. By default equations for PartialDerivatives are printed but equations for normal derivatives are not. TODO might want to print eqn for y=sin(x) but not x=3- Author:
- Rich Morris Created on 26-Feb-2004
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.singularsys.jep.PrintVisitor
PrintVisitor.NullPrintVisitor, PrintVisitor.PrintRulesI, PrintVisitor.StdElePrintRule, PrintVisitor.StdListPrintRule
-
-
Field Summary
Fields Modifier and Type Field Description static int
PRINT_PARTIAL_EQNS
static int
PRINT_VARIABLE_EQNS
-
Fields inherited from class com.singularsys.jep.PrintVisitor
COMPLEX_I, format, fp, FULL_BRACKET, FunctionArgSep, FunLBracket, FunRBracket, LBracket, mode, NULL_PRINT_VISITOR, ot, RBracket, sb, specialFunRules, specialRules, specialVarName
-
-
Constructor Summary
Constructors Constructor Description DPrintVisitor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
testLeft(Operator top, Node lhs)
Test if brackets are necessary around left hand side.boolean
testMid(Operator top, Node rhs)
Test if brackets are needed around a middle argumentx + (y) + z
boolean
testRight(Operator top, Node rhs)
Tests if brackets are necessary around the RHS child of a operator.java.lang.Object
visit(ASTVarNode node, java.lang.Object data)
Prints the variable or its equation.-
Methods inherited from class com.singularsys.jep.PrintVisitor
addSpecialRule, addSpecialRule, addSpecialVarName, append, formatValue, formatValue, getFunArgSep, getFunLBracket, getFunRBracket, getLBracket, getLightWeightInstance, getMaxLen, getMode, getMode, getRBracket, init, print, print, printBrackets, println, println, printNoBrackets, printWrap, setFunArgSep, setFunLBracket, setFunRBracket, setLBracket, setMaxLen, setMode, setNumberFormat, setRBracket, toString, visit, visit, visit, visitBinary, visitUnary
-
-
-
-
Field Detail
-
PRINT_PARTIAL_EQNS
public static final int PRINT_PARTIAL_EQNS
- See Also:
- Constant Field Values
-
PRINT_VARIABLE_EQNS
public static final int PRINT_VARIABLE_EQNS
- See Also:
- Constant Field Values
-
-
Method Detail
-
visit
public java.lang.Object visit(ASTVarNode node, java.lang.Object data) throws JepException
Prints the variable or its equation. Depends on the state of the flags and whether the variable has an equation.- Specified by:
visit
in interfaceParserVisitor
- Overrides:
visit
in classPrintVisitor
- Throws:
JepException
-
testLeft
public boolean testLeft(Operator top, Node lhs)
Description copied from class:PrintVisitor
Test if brackets are necessary around left hand side.- Overrides:
testLeft
in classPrintVisitor
- Parameters:
top
- The current operator being printed.lhs
- The node on the left hand side.- Returns:
- True if a bracket is necessary, false otherwise.
-
testMid
public boolean testMid(Operator top, Node rhs)
Description copied from class:PrintVisitor
Test if brackets are needed around a middle argumentx + (y) + z
- Overrides:
testMid
in classPrintVisitor
- Parameters:
top
- The current operator being printed.rhs
- The node on the middle of a chain.- Returns:
- True if a bracket is necessary, false otherwise.
-
testRight
public boolean testRight(Operator top, Node rhs)
Description copied from class:PrintVisitor
Tests if brackets are necessary around the RHS child of a operator.- Overrides:
testRight
in classPrintVisitor
- Parameters:
top
- The operator.rhs
- The right hand side node.- Returns:
- True if brackets are necessary, false otherwise.
-
-