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