|
|||||||||
| 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.functions.If
public class If
The if(condExpr, posExpr, negExpr) function. The value of trueExpr will be returned if condExpr is >0 or Boolean.TRUE and value of negExpr will be returned if condExpr is <= 0 or Boolean.TRUE.
This function performs lazy evaluation so that only posExpr or negExpr will be evaluated. For Complex numbers only the real part is used.
An alternate form if(condExpr, posExpr, negExpr, zeroExpr) is also available. Note most computations are carried out over floating point doubles so testing for zero can be dangerous.
This function implements the SpecialEvaluationI interface so that it handles setting the value of a variable.
| Field Summary |
|---|
| Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand |
|---|
curNumberOfParameters, numberOfParameters |
| Constructor Summary | |
|---|---|
If()
|
|
| Method Summary | |
|---|---|
boolean |
checkNumberOfParameters(int n)
Checks the number of parameters of the call. |
java.lang.Object |
evaluate(Node node,
Evaluator pv)
Performs some special evaluation on the node. |
void |
run(java.util.Stack<java.lang.Object> aStack)
Run the function on the stack. |
| Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand |
|---|
checkStack, getNumberOfParameters, setCurNumberOfParameters |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public If()
| Method Detail |
|---|
public boolean checkNumberOfParameters(int n)
checkNumberOfParameters in interface PostfixMathCommandIcheckNumberOfParameters in class PostfixMathCommandn - number of parameters function will be called with.
public java.lang.Object evaluate(Node node,
Evaluator pv)
throws EvaluationException
CallbackEvaluationIpv.eval(node.jjtGetChild(i))for each child. The SymbolTable is not passed as an argument. This is because it is better practice to get and set variable values by using node.getVar().setValue() rather that through the SymbolTable with requires a hashtable lookup.
evaluate in interface CallbackEvaluationInode - The current nodepv - The visitor, can be used evaluate the children
EvaluationExceptionEvaluator
public void run(java.util.Stack<java.lang.Object> aStack)
throws EvaluationException
PostfixMathCommandI
run in interface PostfixMathCommandIEvaluationException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||