Enum Class Calc

java.lang.Object
java.lang.Enum<Calc>
org.basex.query.expr.Calc
All Implemented Interfaces:
Serializable, Comparable<Calc>, java.lang.constant.Constable

public enum Calc extends Enum<Calc>
Calculation.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Enum Constant Details

    • 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 Details

    • values

      public static Calc[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Calc valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class 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
    • toString

      public String toString()
      Overrides:
      toString in class Enum<Calc>