Package com.singularsys.jep.walkers

# Class GenericDoNothingVisitor<D>

java.lang.Object
com.singularsys.jep.walkers.GenericDoNothingVisitor<D>

Type Parameters:
  `D` - the type of the data passed to the visit methods

All Implemented Interfaces:
  `GenericVisitor<Node,D,ParseException>`, `JepComponent`, `Serializable`

Direct Known Subclasses:
  `GenericDeepCopyVisitor`, `OverloadResolver`, `SubstitutionVisitor`

public class GenericDoNothingVisitor<D> extends Object implements GenericVisitor<Node,D,ParseException>, JepComponent
A Visitor which visits each node, typically return the original node. For function and operator nodes it visits the children, if any have changed a new node is created with the new children, otherwise the original node is returned. This allows visitors to modify trees and create a new tree This class should be extended by visitors which modify trees and creates a new tree.

Since:
  Jep 4.1
See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected FunctionTable`
  `ft`
  `protected NodeFactory`
  `nf`
  `protected OperatorTableI`
  `ot`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GenericDoNothingVisitor()`
  Constructor to use as a JepComponent.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected boolean`
  `childrenHaveChanged(Node node, List<Node> children)`
  Tests if the children of a node have changed
  `protected Node`
  `copyChildrenIfNeeded(ASTFunNode node, List<Node> children)`
  Sets the children of a node if they have changed from its current children.
  `protected Node`
  `copyChildrenIfNeeded(ASTOpNode node, List<Node> children)`
  `JepComponent`
  `getLightWeightInstance()`
  Gets a light-weight instance suitable for using in multiple threads.
  `void`
  `init(Jep jep)`
  Initialize the component.
  `ParseException`
  `makeException(String message)`
  Create an Exception of the correct type.
  `Node`
  `visit(ASTConstant node, D data)`
  Visit a constant node
  `Node`
  `visit(ASTFunNode node, D data)`
  Visit a function node
  `Node`
  `visit(ASTOpNode node, D data)`
  Visit an operator node
  `Node`
  `visit(ASTVarNode node, D data)`
  Visit a variable node

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface com.singularsys.jep.GenericVisitor

  `makeException, visit, visitChildren`

- ## Field Details

  - ### nf

    protected NodeFactory nf

  - ### ot

    protected OperatorTableI ot

  - ### ft

    protected FunctionTable ft

- ## Constructor Details

  - ### GenericDoNothingVisitor

    public GenericDoNothingVisitor()
    Constructor to use as a JepComponent. `init(Jep)` must be called later.

- ## Method Details

  - ### visit

    public Node visit(ASTConstant node, D data) throws ParseException
    Description copied from interface: `GenericVisitor`
    Visit a constant node
    Specified by:
      `visit` in interface `GenericVisitor<Node,D,ParseException>`
    Parameters:
      `node` - current node
      `data` - context data
    Returns:
      the result of visiting the node
    Throws:
      `ParseException`

  - ### visit

    public Node visit(ASTFunNode node, D data) throws ParseException
    Description copied from interface: `GenericVisitor`
    Visit a function node
    Specified by:
      `visit` in interface `GenericVisitor<Node,D,ParseException>`
    Parameters:
      `node` - current node
      `data` - context data
    Returns:
      the result of visiting the node
    Throws:
      `ParseException`

  - ### visit

    public Node visit(ASTOpNode node, D data) throws ParseException
    Description copied from interface: `GenericVisitor`
    Visit an operator node
    Specified by:
      `visit` in interface `GenericVisitor<Node,D,ParseException>`
    Parameters:
      `node` - current node
      `data` - context data
    Returns:
      the result of visiting the node
    Throws:
      `ParseException`

  - ### visit

    public Node visit(ASTVarNode node, D data) throws ParseException
    Description copied from interface: `GenericVisitor`
    Visit a variable node
    Specified by:
      `visit` in interface `GenericVisitor<Node,D,ParseException>`
    Parameters:
      `node` - current node
      `data` - context data
    Returns:
      the result of visiting the node
    Throws:
      `ParseException`

  - ### init

    public void init(Jep jep)
    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:
      `jep` - the current Jep instance

  - ### 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:
      either a new instance, null or 'this'.

  - ### makeException

    public ParseException makeException(String message)
    Description copied from interface: `GenericVisitor`
    Create an Exception of the correct type. A typical implementation is

        @Override
        public JepException makeException(String message) {
         return new JepException(message);
        }

    Specified by:
      `makeException` in interface `GenericVisitor<Node,D,ParseException>`
    Parameters:
      `message` - error message
    Returns:
      an Exception

  - ### copyChildrenIfNeeded

    protected Node copyChildrenIfNeeded(ASTFunNode node, List<Node> children) throws ParseException
    Sets the children of a node if they have changed from its current children. If all the children are the same as the current children of the node then return the node.
    Throws:
      `ParseException`

  - ### copyChildrenIfNeeded

    protected Node copyChildrenIfNeeded(ASTOpNode node, List<Node> children) throws ParseException
    Throws:
      `ParseException`

  - ### childrenHaveChanged

    protected boolean childrenHaveChanged(Node node, List<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 any child have changed, false otherwise