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
FieldsModifier and TypeFieldDescriptionprotected FunctionTableConvenience reference to the FunctionTableprotected JepJep instanceprotected NodeFactoryConvenience reference to the NodeFactoryprotected OperatorTableIConvenience reference to the OperatorTableIprotected VariableTableConvenience reference to the VariableTable -
Constructor Summary
ConstructorsConstructorDescriptionConstructor to use with JepComponent mechanism, init method must be called. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanchildrenHaveChanged(Node node, Node[] children) Tests if the children of a node have changedprotected NodecopyChildrenIfNeeded(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.voidInitialize 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:JepComponentGets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstancein interfaceJepComponent- Returns:
- this
-
init
Description copied from interface:JepComponentInitialize 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:
initin 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:
visitin interfaceParserVisitor- Throws:
JepException
-
visit
Visit a variable node. Can be overridden by subclasses.- Specified by:
visitin interfaceParserVisitor- Throws:
JepException
-
visit
Visit a function node. Can be overridden by subclasses.- Specified by:
visitin interfaceParserVisitor- Throws:
JepException
-
visit
Visit an operator node. Can be overridden by subclasses.- Specified by:
visitin 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
-