Package com.singularsys.jep.walkers

# Class LightWeightImportationVisitor

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

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

public class LightWeightImportationVisitor extends GenericDeepCopyVisitor<Void>
A variant off the `ImportationVisitor` that uses either the same pfmc for a node or its `getLightWeightInstance()` if the function implements `JepComponent`. The `ImportationVisitor` finds the function by looking it up in the FunctionTable.

This class is used by the `MacroFunction` to ensure that these work correctly with the `com.singularsys.jep.misc.overloadedfunctions` package.

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

Since:
  Jep 4.1
See Also:
  - Serialized Form

- ## Field Summary

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

  `ft, nf, ot`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LightWeightImportationVisitor(Jep j)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Node`
  `importEqn(Node node)`
  Import an equation from another Jep instance.
  `Node`
  `visit(ASTFunNode node, Void data)`
  Creates a new function node, using the same pfmc, or its lightweight instance if the function implements `JepComponent`.
  `Node`
  `visit(ASTOpNode node, Void data)`
  Create a new operator node, using the same operator.
  `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

  - ### LightWeightImportationVisitor

    public LightWeightImportationVisitor(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
    Creates a new function node, using the same pfmc, or its lightweight instance if the function implements `JepComponent`.
    Specified by:
      `visit` in interface `GenericVisitor<Node,Void,ParseException>`
    Overrides:
      `visit` in class `GenericDeepCopyVisitor<Void>`
    Parameters:
      `node` - node to copy
      `data` - ignored
    Returns:
      a new node
    Throws:
      `ParseException`

  - ### visit

    public Node visit(ASTOpNode node, Void data) throws ParseException
    Create a new operator node, using the same operator. The Node's pfmc, either the nodes pfmc or its lightWeight instance.
    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`

  - ### importEqn

    public Node importEqn(Node node) throws ParseException
    Import an equation from another Jep instance.
    Parameters:
      `node` - the node to import
    Returns:
      a copy of the node, with the same pfmc or its lightWeightInstance if the pfmc implements `JepComponent`
    Throws:
      `ParseException`