Package com.singularsys.extensions.xjep
Class CommandVisitor
- java.lang.Object
-
- com.singularsys.jep.walkers.DoNothingVisitor
-
- com.singularsys.extensions.xjep.CommandVisitor
-
- All Implemented Interfaces:
JepComponent
,ParserVisitor
,java.io.Serializable
public class CommandVisitor extends DoNothingVisitor
Executes commands like diff and eval embedded in expression trees. For example you could doeval(diff(x ^ 3, x), x, 2)
to differentiate x^3 and then substitute x=2 to get the value 12. To use doJep j = ...; Node in = ...; TreeUtils tu = new TreeUtils(j); CommandVisitor cv = new CommandVisitor(tu); Node out = cv.process(in);
Commands to be executed must implementCommandVisitorI
andPostfixMathCommandI
. SeeParserVisitor
for details on the VisitorPattern.- Author:
- R Morris Created on 19-Jun-2003
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CommandVisitor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Node
process(Node node)
Descends the tree processing all diff, eval and simplify optionsjava.lang.Object
visit(ASTFunNode node, java.lang.Object data)
Visit a function node.java.lang.Object
visit(ASTOpNode node, java.lang.Object data)
Visit a operator node.-
Methods inherited from class com.singularsys.jep.walkers.DoNothingVisitor
childrenHaveChanged, copyChildrenIfNeeded, getFunctionTable, getLightWeightInstance, getNodeFactory, getOperatorTable, getVariableTable, init, visit, visit, visit, visitChildren, visitNode
-
-
-
-
Method Detail
-
process
public Node process(Node node) throws ParseException
Descends the tree processing all diff, eval and simplify options- Throws:
ParseException
-
visit
public java.lang.Object visit(ASTFunNode node, java.lang.Object data) throws JepException
Description copied from class:DoNothingVisitor
Visit a function node. Can be overridden by sub-classes.- Specified by:
visit
in interfaceParserVisitor
- Overrides:
visit
in classDoNothingVisitor
- Throws:
JepException
-
visit
public java.lang.Object visit(ASTOpNode node, java.lang.Object data) throws JepException
Description copied from class:DoNothingVisitor
Visit a operator node. Can be overridden by sub-classes.- Specified by:
visit
in interfaceParserVisitor
- Overrides:
visit
in classDoNothingVisitor
- Throws:
JepException
-
-