Package org.basex.query.expr
Enum Calc
- java.lang.Object
-
- java.lang.Enum<Calc>
-
- org.basex.query.expr.Calc
-
- All Implemented Interfaces:
Serializable
,Comparable<Calc>
public enum Calc extends Enum<Calc>
Calculation.- Author:
- BaseX Team 2005-22, BSD License, Christian Gruen
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Item
eval(Item item1, Item item2, InputInfo ii)
Performs the calculation.abstract Calc
invert()
Inverts the operator.static Type
numType(Type type1, Type type2)
Returns the numeric type with the highest precedence.abstract Expr
optimize(Expr expr1, Expr expr2, InputInfo info, CompileContext cc)
Optimizes the expressions.String
toString()
abstract Type
type(Type type1, Type type2)
Returns the result type of this calculation.static Calc
valueOf(String name)
Returns the enum constant of this type with the specified name.static Calc[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
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 nameNullPointerException
- if the argument is null
-
eval
public abstract Item eval(Item item1, Item item2, InputInfo ii) throws QueryException
Performs the calculation.- Parameters:
item1
- first itemitem2
- second itemii
- 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 expressionexpr2
- second expressioninfo
- input infocc
- 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 typetype2
- 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 typetype2
- second item type- Returns:
- type
-
-