|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.misc.MacroFunction
public class MacroFunction
A function specified by a string. For example
MacroFunction fact = new MacroFunction(
"fact",new String[]{"x"},
"if(x>1,x*fact(x-1),1)");
jep.addFunction("fact",fact);
fact.init(jep);
Node n = jep.parse("fact(5)");
| Field Summary | |
|---|---|
protected Node |
topNode
|
| Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand |
|---|
curNumberOfParameters, name, NaN, numberOfParameters |
| Constructor Summary | |
|---|---|
MacroFunction(Jep jep,
java.lang.String funName,
java.lang.String[] parameters,
java.lang.String expression)
Create a macro function with two or more arguments defined by an expression. |
|
MacroFunction(Jep jep,
java.lang.String funName,
java.lang.String parameter,
java.lang.String expression)
Create a macro function with a single arguments defined by an expression. |
|
MacroFunction(java.lang.String funName,
java.lang.String[] parameters,
java.lang.String expression)
Create a macro function with two or more arguments defined by an expression. |
|
| Method Summary | |
|---|---|
JepComponent |
getLightWeightInstance()
Gets a light-weight instance suitable for using in multiple threads. |
java.lang.String[] |
getParameterNames()
|
Node |
getTopNode()
|
void |
init(Jep j)
The init method must be called after construction. |
void |
run(java.util.Stack<java.lang.Object> stack)
Calculates the value of the expression. |
java.lang.String |
toString()
|
| Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand |
|---|
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, checkNumberOfParameters, checkStack, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected transient Node topNode
| Constructor Detail |
|---|
public MacroFunction(Jep jep,
java.lang.String funName,
java.lang.String[] parameters,
java.lang.String expression)
jep - The jep instancefunName - name of the functionparameters - an array of the formal parameter names used by the functionexpression -
public MacroFunction(Jep jep,
java.lang.String funName,
java.lang.String parameter,
java.lang.String expression)
jep - The jep instancefunName - name of the functionparameter - the name of the formal parameter.expression -
public MacroFunction(java.lang.String funName,
java.lang.String[] parameters,
java.lang.String expression)
init(Jep) method
must be called after the function is added to the function table, which will recompile the function.
funName - name of the functionparameters - an array of the formal parameter names used by the functionexpression - | Method Detail |
|---|
public void init(Jep j)
init in interface JepComponentj - jep instance
java.lang.RuntimeException - if errors compiling the expression.
public void run(java.util.Stack<java.lang.Object> stack)
throws EvaluationException
run in interface PostfixMathCommandIEvaluationExceptionpublic Node getTopNode()
public java.lang.String[] getParameterNames()
public java.lang.String toString()
toString in class java.lang.Objectpublic JepComponent getLightWeightInstance()
JepComponent
getLightWeightInstance in interface JepComponent
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||