Enum Calc

    • Enum Constant Detail

      • PLUS

        public static final Calc PLUS
        Addition.
      • MINUS

        public static final Calc MINUS
        Subtraction.
      • MULT

        public static final Calc MULT
        Multiplication.
      • DIV

        public static final Calc DIV
        Division.
      • IDIV

        public static final Calc IDIV
        Integer division.
      • MOD

        public static final Calc MOD
        Modulo.
    • Method Detail

      • values

        public static Calc[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Calc c : Calc.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Calc valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • eval

        public abstract Item eval​(Item item1,
                                  Item item2,
                                  InputInfo ii)
                           throws QueryException
        Performs the calculation.
        Parameters:
        item1 - first item
        item2 - second item
        ii - input info
        Returns:
        result type
        Throws:
        QueryException - query exception
      • optimize

        public abstract Expr optimize​(Expr expr1,
                                      Expr expr2,
                                      InputInfo info,
                                      CompileContext cc)
                               throws QueryException
        Optimizes the expressions.
        Parameters:
        expr1 - first expression
        expr2 - second expression
        info - input info
        cc - compilation context
        Returns:
        result expression, or null if expression cannot be optimized
        Throws:
        QueryException - query exception
      • type

        public abstract Type type​(Type type1,
                                  Type type2)
        Returns the result type of this calculation.
        Parameters:
        type1 - first item type
        type2 - second item type
        Returns:
        result expression, or null if expression cannot be optimized
      • invert

        public abstract Calc invert()
        Inverts the operator.
        Returns:
        inverted operator or null
      • numType

        public static Type numType​(Type type1,
                                   Type type2)
        Returns the numeric type with the highest precedence.
        Parameters:
        type1 - first item type
        type2 - second item type
        Returns:
        type