public class LazyLogical extends PostfixMathCommand implements CallbackEvaluationI
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 evaluatedModifier and Type | Field and Description |
---|---|
protected boolean |
allowNumbers |
static int |
AND |
protected int |
id
Represents which logical operator this is.
|
static int |
OR |
curNumberOfParameters, name, NaN, numberOfParameters
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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
|
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, checkNumberOfParameters, getName, getNumberOfParameters, run, setCurNumberOfParameters, setName, toString, toString
protected int id
public static final int AND
public static final int OR
protected boolean allowNumbers
public LazyLogical(int id_in)
id_in
- either of the constants AND or ORpublic LazyLogical(int id_in, boolean disallowNumbers)
id_in
- Either AND or ORdisallowNumbers
- if true Number arguments will raise exceptions,
otherwise as the Standard constructor.public java.lang.Object evaluate(Node node, Evaluator pv) throws EvaluationException
CallbackEvaluationI
pv.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 CallbackEvaluationI
node
- The current nodepv
- The visitor, can be used evaluate the childrenEvaluationException
- if the calculation cannot be performedEvaluator
public int getId()
public boolean isAllowNumbers()
Copyright © 2018 Singular Systems http://www.singularsys.com/jep