public class Switch extends PostfixMathCommand implements CallbackEvaluationI
switch(2,5,6,7,8)
will return 6.
The first argument must be an exact integerCase
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
Switch.NullBehaviour
Action to take if first argument is null.
|
curNumberOfParameters, name, NaN, numberOfParameters
Constructor and Description |
---|
Switch()
Default switch statement.
|
Switch(Switch.NullBehaviour nullBehaviour)
Switch function with defined null behaviour.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkNumberOfParameters(int n)
Must have at least 2 parameters.
|
java.lang.Object |
evaluate(Node node,
Evaluator pv)
Performs some special evaluation on the node.
|
Switch.NullBehaviour |
getNullBehaviour()
Behaviour when passed zero arguments.
|
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, getName, getNumberOfParameters, run, setCurNumberOfParameters, setName, toString, toString
public Switch()
public Switch(Switch.NullBehaviour nullBehaviour)
nullBehaviour
- action to take if first argument is null.public Switch.NullBehaviour getNullBehaviour()
public boolean checkNumberOfParameters(int n)
checkNumberOfParameters
in interface PostfixMathCommandI
checkNumberOfParameters
in class PostfixMathCommand
n
- number of parameters function will be called with.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
Copyright © 2018 Singular Systems http://www.singularsys.com/jep