Package com.singularsys.jep.walkers

# Class ImportationVisitor

java.lang.Object
com.singularsys.jep.walkers.GenericDoNothingVisitor<Void>
com.singularsys.jep.walkers.GenericDeepCopyVisitor<Void>
com.singularsys.jep.walkers.ImportationVisitor

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

public class ImportationVisitor extends GenericDeepCopyVisitor<Void>
Imports an expression from one Jep instance into another. This class is quicker than using a SerializableExpression but cannot handle such large equations.

       Jep sourceJep = ...;
       Jep destJep = ...;
       ImportationVisitor iv = new ImportationVisitor(destJep);
       Node node = sourceJep.parse("x^2-y^2");
       Node imported = iv.importEqn(node);

Since Jep 4.1, this class extends `GenericDeepCopyVisitor`, changing some type signatures. The method `importEqn(Node)` should be used to import equations, rather than the deprecated `deepCopy(Node)`.

Since:
  Jep 3.5
Author:
  Richard Morris
See Also:
  - `SerializableExpression`
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class com.singularsys.jep.walkers.GenericDoNothingVisitor

  `ft, nf, ot`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ImportationVisitor(Jep j)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Node`
  `deepCopy(Node node)`
  Deprecated.
  use `importEqn(Node)` instead, which is more descriptive.
  `Node`
  `importEqn(Node node)`
  Imports an equation from another Jep instance.
  `Node`
  `visit(ASTFunNode node, Void data)`
  Ensures that functions will be correct for the give Jep instance.
  `Node`
  `visit(ASTOpNode node, Void data)`
  Ensures that operators are correct for the given Jep instance.
  `Node`
  `visit(ASTVarNode node, Void data)`
  Uses the name of the variable rather than the variable reference to create the node

  ### Methods inherited from class com.singularsys.jep.walkers.GenericDeepCopyVisitor

  `getLightWeightInstance, visit, visit`

  ### Methods inherited from class com.singularsys.jep.walkers.GenericDoNothingVisitor

  `childrenHaveChanged, copyChildrenIfNeeded, copyChildrenIfNeeded, init, makeException`

  ### 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, visitChildren`

- ## Constructor Details

  - ### ImportationVisitor

    public ImportationVisitor(Jep j)

- ## Method Details

  - ### visit

    public Node visit(ASTVarNode node, Void data) throws ParseException
    Uses the name of the variable rather than the variable reference to create the node
    Specified by:
      `visit` in interface `GenericVisitor<Node,Void,ParseException>`
    Overrides:
      `visit` in class `GenericDeepCopyVisitor<Void>`
    Parameters:
      `node` - current node
      `data` - context data
    Returns:
      the result of visiting the node
    Throws:
      `ParseException`

  - ### visit

    public Node visit(ASTFunNode node, Void data) throws ParseException
    Ensures that functions will be correct for the give Jep instance. Necessary for functions which implement `JepComponent`.
    Specified by:
      `visit` in interface `GenericVisitor<Node,Void,ParseException>`
    Overrides:
      `visit` in class `GenericDeepCopyVisitor<Void>`
    Parameters:
      `node` - current node
      `data` - context data
    Returns:
      the result of visiting the node
    Throws:
      `ParseException`
    Since:
      4.0

  - ### visit

    public Node visit(ASTOpNode node, Void data) throws ParseException
    Ensures that operators are correct for the given Jep instance. Necessary for functions which implement `JepComponent`.
    Specified by:
      `visit` in interface `GenericVisitor<Node,Void,ParseException>`
    Overrides:
      `visit` in class `GenericDeepCopyVisitor<Void>`
    Parameters:
      `node` - current node
      `data` - context data
    Returns:
      the result of visiting the node
    Throws:
      `ParseException`
    Since:
      4.0

  - ### importEqn

    public Node importEqn(Node node) throws ParseException
    Imports an equation from another Jep instance.
    Parameters:
      `node` - the node to import
    Returns:
      a new node, with the same variable names, function names and operator names, but using the functions and operators of the Jep instance used to create this visitor.
    Throws:
      `ParseException` - if there is an error during the importation process.

  - ### deepCopy

    @Deprecated(since="4.1") public Node deepCopy(Node node) throws ParseException
    Deprecated.
    use `importEqn(Node)` instead, which is more descriptive.
    Imports an equation from another Jep instance.
    Parameters:
      `node` - the node to import
    Returns:
      a new node, with the same variable names, function names and operator names, but using the functions and operators of the Jep instance used to create this visitor.
    Throws:
      `ParseException` - if there is an error during the importation process.