Class Expression.Operator

  • Direct Known Subclasses:
    Expression.Assignment, Expression.Comparator
    Enclosing class:
    Expression

    public abstract class Expression.Operator
    extends java.lang.Object
    Abstract definition of a supported operator. An operator is defined by its name (pattern), precedence and if it is left- or right associative.
    • Constructor Summary

      Constructors 
      Constructor Description
      Operator​(java.lang.String oper, int precedence, boolean leftAssoc)
      Creates a new operator.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object eval​(java.lang.String v1, java.lang.String v2)  
      abstract java.math.BigDecimal eval​(java.math.BigDecimal v1, java.math.BigDecimal v2)
      Implementation for this operator.
      java.lang.Object eval​(java.util.Map<java.lang.String,​java.lang.Object> variables, java.lang.Object v1, java.lang.Object v2)  
      java.lang.String getOper()  
      int getPrecedence()  
      boolean isLeftAssoc()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Operator

        public Operator​(java.lang.String oper,
                        int precedence,
                        boolean leftAssoc)
        Creates a new operator.
        Parameters:
        oper - The operator name (pattern).
        precedence - The operators precedence.
        leftAssoc - true if the operator is left associative, else false.
    • Method Detail

      • getOper

        public java.lang.String getOper()
      • getPrecedence

        public int getPrecedence()
      • isLeftAssoc

        public boolean isLeftAssoc()
      • eval

        public java.lang.Object eval​(java.util.Map<java.lang.String,​java.lang.Object> variables,
                                     java.lang.Object v1,
                                     java.lang.Object v2)
      • eval

        public java.lang.Object eval​(java.lang.String v1,
                                     java.lang.String v2)
      • eval

        public abstract java.math.BigDecimal eval​(java.math.BigDecimal v1,
                                                  java.math.BigDecimal v2)
        Implementation for this operator.
        Parameters:
        v1 - Operand 1.
        v2 - Operand 2.
        Returns:
        The result of the operation.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object