|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.singularsys.jep.walkers.DoNothingVisitor
com.singularsys.jep.walkers.SubstitutionVisitor
public class SubstitutionVisitor
Allows substitution of a given variable with an expression tree. For example
Jep jep = new Jep();
Node node = jep.parse("x^2+x");
SubstitutionVisitor sv = new SubstitutionVisitor(jep);
Node sub = jep.parse("sin(y)");
Node res = sv.substitute(node,"x",sub);
Will give the expression "(sin(y))^2+sin(y)".
| Field Summary | |
|---|---|
protected Operator |
assign
|
protected DeepCopyVisitor |
dcv
|
| Fields inherited from class com.singularsys.jep.walkers.DoNothingVisitor |
|---|
ft, jep, nf, ot, vt |
| Constructor Summary | |
|---|---|
SubstitutionVisitor(Jep j)
|
|
| Method Summary | |
|---|---|
Node |
substitute(Node orig,
Node sub)
Substitutes into orig the equation given by sub |
Node |
substitute(Node orig,
Node[] subs)
|
Node |
substitute(Node orig,
java.lang.String[] names,
Node[] replacements)
Substitutes all occurrences of a set of variable var with a set of replacements. |
Node |
substitute(Node orig,
java.lang.String[] names,
java.lang.Object[] values)
Substitute a set of names with a set of values. |
Node |
substitute(Node orig,
java.lang.String name,
Node replacement)
Substitutes all occurrences of variable var with replacement. |
java.lang.Object |
visit(ASTVarNode node,
java.lang.Object data)
Visit a variable node. |
| Methods inherited from class com.singularsys.jep.walkers.DoNothingVisitor |
|---|
copyChildrenIfNeeded, visit, visit, visit, visit, visitChildren, visitNode |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Operator assign
protected DeepCopyVisitor dcv
| Constructor Detail |
|---|
public SubstitutionVisitor(Jep j)
| Method Detail |
|---|
public Node substitute(Node orig,
java.lang.String name,
Node replacement)
throws JepException
orig - the expression we wish to perform the substitution onname - the name of the variablereplacement - the expression var is substituted for
JepException
public Node substitute(Node orig,
Node sub)
throws JepException
orig - the equation to substitute intosub - and equation of the form x=....
JepException - if sub is of the wrong form
public Node substitute(Node orig,
Node[] subs)
throws JepException
JepException
public Node substitute(Node orig,
java.lang.String[] names,
Node[] replacements)
throws JepException
orig - the expression we wish to perform the substitution onnames - the names of the variablereplacements - the expression var is substituted for
JepException
public Node substitute(Node orig,
java.lang.String[] names,
java.lang.Object[] values)
throws JepException
orig - names - values -
JepException
public java.lang.Object visit(ASTVarNode node,
java.lang.Object data)
throws JepException
DoNothingVisitor
visit in interface ParserVisitorvisit in class DoNothingVisitorJepException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||