Package com.singularsys.jep.walkers
Class DoNothingVisitor
java.lang.Object
com.singularsys.jep.walkers.DoNothingVisitor
- All Implemented Interfaces:
JepComponent
,ParserVisitor
,Serializable
- Direct Known Subclasses:
DeepCopyVisitor
,SubstitutionVisitor
A Visitor which visits each node of an expression tree and does nothing.
This visitor is intended as a base class for other visitors which
manipulate expressions.
This class will always leave the original expression intact, but may reuse unchanged parts of the expression.
- Since:
- 3.3 number of children no longer needs to be the same
- Author:
- Rich Morris Created on 16-Nov-2003
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected FunctionTable
Convenience reference to the FunctionTableprotected Jep
Jep instanceprotected NodeFactory
Convenience reference to the NodeFactoryprotected OperatorTableI
Convenience reference to the OperatorTableIprotected VariableTable
Convenience reference to the VariableTable -
Constructor Summary
ConstructorDescriptionConstructor to use with JepComponent mechanism, init method must be called. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
childrenHaveChanged
(Node node, Node[] children) Tests if the children of a node have changedprotected Node
copyChildrenIfNeeded
(Node node, Node[] children) Sets the children of a node if they have changed from its current children.Gets a light-weight instance suitable for using in multiple threads.void
Initialize the component.visit
(ASTConstant node, Object data) Visit a constant node.visit
(ASTFunNode node, Object data) Visit a function node.Visit an operator node.visit
(ASTVarNode node, Object data) Visit a variable node.protected Node[]
visitChildren
(Node node, Object data) Gets the result of visiting children of an array of nodes.Used to recursively visit the children of a node.
-
Field Details
-
jep
Jep instance -
nf
Convenience reference to the NodeFactory -
vt
Convenience reference to the VariableTable -
ft
Convenience reference to the FunctionTable -
ot
Convenience reference to the OperatorTableI
-
-
Constructor Details
-
DoNothingVisitor
public DoNothingVisitor()Constructor to use with JepComponent mechanism, init method must be called. -
DoNothingVisitor
-
-
Method Details
-
getLightWeightInstance
Description copied from interface:JepComponent
Gets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstance
in interfaceJepComponent
- Returns:
- this
-
init
Description copied from interface:JepComponent
Initialize the component. This method is called whenever a component is added to Jep. Hence, it allows components to keep track of the other components they may rely on.- Specified by:
init
in interfaceJepComponent
- Parameters:
j
- the current Jep instance
-
visit
- Throws:
JepException
-
visitNode
Used to recursively visit the children of a node.- Parameters:
node
- Node to visitdata
- user specified data- Returns:
- a Node with the modified tree
- Throws:
JepException
-
visitChildren
Gets the result of visiting children of an array of nodes.- Parameters:
node
- current node being visiteddata
- user specified data- Returns:
- an array of results from visiting each child of the node.
- Throws:
JepException
-
visit
Visit a constant node. Can be overridden by subclasses.- Specified by:
visit
in interfaceParserVisitor
- Throws:
JepException
-
visit
Visit a variable node. Can be overridden by subclasses.- Specified by:
visit
in interfaceParserVisitor
- Throws:
JepException
-
visit
Visit a function node. Can be overridden by subclasses.- Specified by:
visit
in interfaceParserVisitor
- Throws:
JepException
-
visit
Visit an operator node. Can be overridden by subclasses.- Specified by:
visit
in interfaceParserVisitor
- Throws:
JepException
-
copyChildrenIfNeeded
Sets the children of a node if they have changed from its current children.- Throws:
JepException
-
childrenHaveChanged
Tests if the children of a node have changed- Parameters:
node
- the original nodechildren
- the new set of children.- Returns:
- true if the children have changed, false otherwise
-
getNodeFactory
-
getOperatorTable
-
getVariableTable
-
getFunctionTable
-