Class DoNothingVisitor

java.lang.Object
com.singularsys.jep.walkers.DoNothingVisitor
All Implemented Interfaces:
JepComponent, ParserVisitor, Serializable
Direct Known Subclasses:
DeepCopyVisitor, SubstitutionVisitor

public class DoNothingVisitor extends Object implements ParserVisitor, JepComponent
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 Details

    • jep

      protected Jep jep
      Jep instance
    • nf

      protected NodeFactory nf
      Convenience reference to the NodeFactory
    • vt

      protected VariableTable vt
      Convenience reference to the VariableTable
    • ft

      protected FunctionTable ft
      Convenience reference to the FunctionTable
    • ot

      protected OperatorTableI ot
      Convenience reference to the OperatorTableI
  • Constructor Details

    • DoNothingVisitor

      public DoNothingVisitor()
      Constructor to use with JepComponent mechanism, init method must be called.
    • DoNothingVisitor

      public DoNothingVisitor(Jep j)
  • Method Details

    • getLightWeightInstance

      public JepComponent getLightWeightInstance()
      Description copied from interface: JepComponent
      Gets a light-weight instance suitable for using in multiple threads.
      Specified by:
      getLightWeightInstance in interface JepComponent
      Returns:
      this
    • init

      public void init(Jep j)
      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 interface JepComponent
      Parameters:
      j - the current Jep instance
    • visit

      public Node visit(Node node) throws JepException
      Throws:
      JepException
    • visitNode

      public Node visitNode(Node node, Object data) throws JepException
      Used to recursively visit the children of a node.
      Parameters:
      node - Node to visit
      data - user specified data
      Returns:
      a Node with the modified tree
      Throws:
      JepException
    • visitChildren

      protected Node[] visitChildren(Node node, Object data) throws JepException
      Gets the result of visiting children of an array of nodes.
      Parameters:
      node - current node being visited
      data - user specified data
      Returns:
      an array of results from visiting each child of the node.
      Throws:
      JepException
    • visit

      public Object visit(ASTConstant node, Object data) throws JepException
      Visit a constant node. Can be overridden by subclasses.
      Specified by:
      visit in interface ParserVisitor
      Throws:
      JepException
    • visit

      public Object visit(ASTVarNode node, Object data) throws JepException
      Visit a variable node. Can be overridden by subclasses.
      Specified by:
      visit in interface ParserVisitor
      Throws:
      JepException
    • visit

      public Object visit(ASTFunNode node, Object data) throws JepException
      Visit a function node. Can be overridden by subclasses.
      Specified by:
      visit in interface ParserVisitor
      Throws:
      JepException
    • visit

      public Object visit(ASTOpNode node, Object data) throws JepException
      Visit an operator node. Can be overridden by subclasses.
      Specified by:
      visit in interface ParserVisitor
      Throws:
      JepException
    • copyChildrenIfNeeded

      protected Node copyChildrenIfNeeded(Node node, Node[] children) throws JepException
      Sets the children of a node if they have changed from its current children.
      Throws:
      JepException
    • childrenHaveChanged

      protected boolean childrenHaveChanged(Node node, Node[] children)
      Tests if the children of a node have changed
      Parameters:
      node - the original node
      children - the new set of children.
      Returns:
      true if the children have changed, false otherwise
    • getNodeFactory

      public NodeFactory getNodeFactory()
    • getOperatorTable

      public OperatorTableI getOperatorTable()
    • getVariableTable

      public VariableTable getVariableTable()
    • getFunctionTable

      public FunctionTable getFunctionTable()