public class Case extends PostfixMathCommand implements CallbackEvaluationI
case("c","a",5,"b",6,"c",7,8)
will return 7.Switch
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
Case.NullBehaviour
Action to take if first argument is null.
|
curNumberOfParameters, name, NaN, numberOfParameters
Constructor and Description |
---|
Case()
Standard constructor with no default value and errors if null if found.
|
Case(Case.NullBehaviour nullBehaviour)
Constructor with defined behaviour for null.
|
Case(java.lang.Object defaultVal)
A case statement with a predefined default value and errors if null if found.
|
Case(java.lang.Object defaultVal,
Case.NullBehaviour nullBehaviour)
Case statement with given default value and defined null behaviour.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkNumberOfParameters(int n)
Must have at least 3 parameters.
|
java.lang.Object |
evaluate(Node node,
Evaluator pv)
Performs some special evaluation on the node.
|
java.lang.Object |
getDefaultVal()
The default value, only meaningful if isHasDefault() is true.
|
Case.NullBehaviour |
getNullBehaviour()
Behaviour when passed zero arguments.
|
boolean |
isHasDefault()
Whether a default value is set
|
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, getName, getNumberOfParameters, run, setCurNumberOfParameters, setName, toString, toString
public Case()
public Case(Case.NullBehaviour nullBehaviour)
nullBehaviour
- action to take if first argument is nullpublic Case(java.lang.Object defaultVal)
defaultVal
- The default value to return when no cases matchpublic Case(java.lang.Object defaultVal, Case.NullBehaviour nullBehaviour)
defaultVal
- The default value to return when no cases matchnullBehaviour
- action to take if first argument is nullpublic boolean isHasDefault()
public java.lang.Object getDefaultVal()
public Case.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