public class ElementOf extends ArrayFunctionBase
The function could be used as an operator:
public enum InOperators implements EmptyOperatorTable.OperatorKey { IN,NOTIN } Jep jep = new Jep(new StandardConfigurableParser()); OperatorTableI opTab = jep.getOperatorTable(); Operator eqOp = opTab.getEQ(); Operator inOp = new Operator( "IN", new ElementOf((Comparative) eqOp.getPFMC(),true), Operator.BINARY+Operator.RIGHT); Operator notInOp = new Operator( "NOTIN", new ElementOf((Comparative) eqOp.getPFMC(),false), Operator.BINARY+Operator.RIGHT); opTab.addOperator(InOperators.IN,inOp,eqOp); opTab.addOperator(InOperators.NOTIN,notInOp,eqOp); jep.reinitializeComponents();
ArrayFunctionBase.ZeroLengthErrorBehaviour
Modifier and Type | Field and Description |
---|---|
protected Comparative |
comp |
curNumberOfParameters, name, NaN, numberOfParameters
Constructor and Description |
---|
ElementOf(Comparative comp,
boolean elementOf)
Construct the function.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
calc(java.util.List<java.lang.Object> l)
Should not be called.
|
protected java.lang.Object |
calc(java.lang.Object first,
java.util.List<java.lang.Object> l)
Calculates if the element is in the list or not.
|
void |
run(java.util.Stack<java.lang.Object> stack)
Calls the calc method after concatenating the second and subsequent elements into list.
|
addToArray, checkNumberOfParameters, getZeroLengthErrorBehaviour, setZeroLengthErrorBehaviour, throwAtLeastOneExcep
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString, toString
protected Comparative comp
public ElementOf(Comparative comp, boolean elementOf)
comp
- comparative object used to compare two elementselementOf
- whether the function calculate "element-of" or "not element-of". If false the result of function is negated.protected java.lang.Object calc(java.lang.Object first, java.util.List<java.lang.Object> l) throws EvaluationException
first
- element to testl
- list with all the other arguments in the listEvaluationException
public void run(java.util.Stack<java.lang.Object> stack) throws EvaluationException
run
in interface PostfixMathCommandI
run
in class ArrayFunctionBase
stack
- arguments for functionEvaluationException
- if function cannot be evaluatedprotected java.lang.Object calc(java.util.List<java.lang.Object> l) throws EvaluationException
calc
in class ArrayFunctionBase
l
- The list to operate on. Note this is in reverse order of the arguments of the function.EvaluationException
- alwaysCopyright © 2018 Singular Systems http://www.singularsys.com/jep