Class ElementOf

All Implemented Interfaces:
PostfixMathCommandI, Serializable

public class ElementOf extends ArrayFunctionBase
Tests if the first argument is in a set of values given in subsequent arguments. For example IN(var,"north","south","east","west"). An array can be used for a two argument version IN(var,["north","south","east","west"]). The function can be configured to return the negation, i.e. not element of.

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();
 
Since:
3.5.0
Author:
Richard Morris
See Also:
  • Field Details

  • Constructor Details

    • ElementOf

      public ElementOf(Comparative comp, boolean elementOf)
      Construct the function.
      Parameters:
      comp - comparative object used to compare two elements
      elementOf - whether the function calculate "element-of" or "not element-of". If false the result of function is negated.
  • Method Details