Class AbstractOperator

java.lang.Object
com.igormaznitsa.jcp.expression.operators.AbstractOperator
All Implemented Interfaces:
ExpressionItem
Direct Known Subclasses:
OperatorADD, OperatorAND, OperatorDIV, OperatorEQU, OperatorGREAT, OperatorGREATEQU, OperatorLESS, OperatorLESSEQU, OperatorMOD, OperatorMUL, OperatorNOT, OperatorNOTEQU, OperatorOR, OperatorSUB, OperatorXOR

public abstract class AbstractOperator extends Object implements ExpressionItem
The class is the base for all operator handlers
  • Field Details

    • EXECUTION_PREFIX

      public static final String EXECUTION_PREFIX
      The constant is the prefix for executing methods of operators
      See Also:
    • ALL_OPERATORS

      public static final AbstractOperator[] ALL_OPERATORS
      The array contains all operators allowed by the preprocessor
  • Constructor Details

    • AbstractOperator

      public AbstractOperator()
  • Method Details

    • findForClass

      public static <E extends AbstractOperator> E findForClass(Class<E> operatorClass)
      Find an operator handler for its class
      Type Parameters:
      E - the handler class extends AbstractOperator
      Parameters:
      operatorClass - the class to be used for search, must not be null
      Returns:
      an instance of the handler or null if there is not any such one
    • getExpressionItemType

      public ExpressionItemType getExpressionItemType()
      Get the expression item type
      Specified by:
      getExpressionItemType in interface ExpressionItem
      Returns:
      for operators it is always ExpressionItemType.OPERATOR
    • getArity

      public abstract int getArity()
      Get the operator arity
      Returns:
      the operator arity (1 or 2)
    • getKeyword

      public abstract String getKeyword()
      Get the operator keyword
      Returns:
      the operator keyword, must not be null
    • getReference

      public abstract String getReference()
      Get the operator reference to be shown for a help information request
      Returns:
      the operator reference as a String, must not be null
    • toString

      public String toString()
      Overrides:
      toString in class Object