|
|||||||||
| 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.LazyLogical
public class LazyLogical
A version of the logical operators which use lazy evaluation. The first argument is always evaluated but the second argument is only evaluated if needed. Hence
0 || arg2 arg2 is evaluated1 || arg2 arg2 is not evaluated and true is returned0 && arg2 arg2 is not evaluated and false is returned1 && arg2 arg2 is evaluated
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.singularsys.jep.functions.CallbackEvaluationI |
|---|
CallbackEvaluationI.Runnable |
| Field Summary | |
|---|---|
protected boolean |
allowNumbers
|
static int |
AND
|
protected int |
id
Represents which logical operator this is. |
static int |
OR
|
| Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand |
|---|
curNumberOfParameters, name, NaN, numberOfParameters |
| Constructor Summary | |
|---|---|
LazyLogical(int id_in)
Standard constructor, non zero Numbers will be treated as true and zero Numbers as false. |
|
LazyLogical(int id_in,
boolean disallowNumbers)
Constructor which restricts type of arguments. |
|
| Method Summary | |
|---|---|
java.lang.Object |
evaluate(Node node,
Evaluator pv)
Performs some special evaluation on the node. |
int |
getId()
Return a code indicating the type of this operator |
boolean |
isAllowNumbers()
Returns whether numbers are treated as booleans |
void |
run(java.util.Stack<java.lang.Object> inStack)
Run the function on the stack. |
| 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, toString, wait, wait, wait |
| Field Detail |
|---|
protected int id
public static final int AND
public static final int OR
protected boolean allowNumbers
| Constructor Detail |
|---|
public LazyLogical(int id_in)
id_in - either of the constants AND or OR
public LazyLogical(int id_in,
boolean disallowNumbers)
id_in - disallowNumbers - if true Number arguments will raise exceptions,
otherwise as the Standard constructor.| Method Detail |
|---|
public void run(java.util.Stack<java.lang.Object> inStack)
throws EvaluationException
PostfixMathCommandI
run in interface PostfixMathCommandIEvaluationException
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
EvaluationExceptionEvaluatorpublic int getId()
public boolean isAllowNumbers()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||