Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.lsmp.djep.xjep
Class SubstitutionVisitor

    java.lang.Object
      org.lsmp.djep.xjep.DoNothingVisitor
          org.lsmp.djep.xjep.SubstitutionVisitor

All Implemented Interfaces:
  ParserVisitor

    public class SubstitutionVisitor

extends DoNothingVisitor

Allows substitution of a given variable with an expression tree. Substitution is best done using the `XJep.substitute` method. For example

     XJepI xjep = ...;
     Node node = xjep.parse("x^2+x");
     Node sub = xjep.parse("sin(y)");
     Node res = xjep.substitute(node,"x",sub,xjep);

Will give the expression "(sin(y))^2+sin(y)".

Author:
  Rich Morris Created on 16-Nov-2003

Constructor Summary
`SubstitutionVisitor()`

Method Summary
`Node` | `substitute(Node orig, java.lang.String[] names, Node[] replacements, XJep xj)` Substitutes all occurrences of a set of variable var with a set of replacements.
`Node` | `substitute(Node orig, java.lang.String name, Node replacement, XJep xj)` Substitutes all occurrences of variable var with replacement.
`java.lang.Object` | `visit(ASTVarNode node, java.lang.Object data)`

Methods inherited from class org.lsmp.djep.xjep.DoNothingVisitor
`acceptChildrenAsArray, visit, visit, visit, visit`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SubstitutionVisitor

    public SubstitutionVisitor()

Method Detail

### substitute

    public Node substitute(Node orig,
                           java.lang.String name,
                           Node replacement,
                           XJep xj)
                    throws ParseException

  Substitutes all occurrences of variable var with replacement. Does not do a DeepCopy.

  Parameters:
    `orig` - the expression we wish to perform the substitution on
    `name` - the name of the variable
    `replacement` - the expression var is substituted for
  Returns:
    the tree with variable replace (does not do a DeepCopy)
  Throws:
    `ParseException`

### substitute

    public Node substitute(Node orig,
                           java.lang.String[] names,
                           Node[] replacements,
                           XJep xj)
                    throws ParseException

  Substitutes all occurrences of a set of variable var with a set of replacements. Does not do a DeepCopy.

  Parameters:
    `orig` - the expression we wish to perform the substitution on
    `names` - the names of the variable
    `replacements` - the expression var is substituted for
  Returns:
    the tree with variable replace (does not do a DeepCopy)
  Throws:
    `ParseException`

### visit

    public java.lang.Object visit(ASTVarNode node,
                                  java.lang.Object data)
                           throws ParseException

  Specified by:
    `visit` in interface `ParserVisitor`
  Overrides:
    `visit` in class `DoNothingVisitor`
  Throws:
    `ParseException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

http://www.singularsys.com/jep Copyright © 2007 Singular Systems