public abstract class Calculator
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Calculator.AnyDivAny
Arithmetic: anyAtomicType div AnyAtomicType
|
static class |
Calculator.AnyIdivAny
Arithmetic: anyAtomicType idiv AnyAtomicType
|
static class |
Calculator.AnyMinusAny
Arithmetic: anyAtomicType - AnyAtomicType
|
static class |
Calculator.AnyModAny
Arithmetic: anyAtomicType mod AnyAtomicType
|
static class |
Calculator.AnyPlusAny
Arithmetic: anyAtomicType + AnyAtomicType
|
static class |
Calculator.AnyTimesAny
Arithmetic: anyAtomicType * AnyAtomicType
|
static class |
Calculator.DecimalDivDecimal
Arithmetic: decimal div decimal (including types that promote to decimal, that is, integer)
|
static class |
Calculator.DecimalIdivDecimal
Arithmetic: decimal idiv decimal (including types that promote to decimal, that is, integer)
|
static class |
Calculator.DecimalMinusDecimal
Arithmetic: decimal - decimal (including types that promote to decimal, that is, integer)
|
static class |
Calculator.DecimalModDecimal
Arithmetic: decimal mod decimal (including types that promote to decimal, that is, integer)
|
static class |
Calculator.DecimalPlusDecimal
Arithmetic: decimal + decimal (including types that promote to decimal, that is, integer)
|
static class |
Calculator.DecimalTimesDecimal
Arithmetic: decimal * decimal (including types that promote to decimal, that is, integer)
|
static class |
Calculator.DoubleDivDouble
Arithmetic: double div double (including types that promote to double)
|
static class |
Calculator.DoubleMinusDouble
Arithmetic: double - double (including types that promote to double)
|
static class |
Calculator.DoubleModDouble
Arithmetic: double mod double (including types that promote to double)
|
static class |
Calculator.DoublePlusDouble
Arithmetic: double + double (including types that promote to double)
|
static class |
Calculator.DoubleTimesDouble
Arithmetic: double * double (including types that promote to double)
|
static class |
Calculator.FloatDivFloat
Arithmetic: float div float (including types that promote to float)
|
static class |
Calculator.FloatIdivFloat
Arithmetic: float idiv float (including types that promote to float)
|
static class |
Calculator.FloatMinusFloat
Arithmetic: float - float (including types that promote to float)
|
static class |
Calculator.FloatModFloat
Arithmetic: float mod float (including types that promote to float)
|
static class |
Calculator.FloatPlusFloat
Arithmetic: float + float (including types that promote to float)
|
static class |
Calculator.FloatTimesFloat
Arithmetic: float * float (including types that promote to float)
|
static class |
Calculator.IntegerDivInteger
Arithmetic: integer div integer
|
static class |
Calculator.IntegerIdivInteger
Arithmetic: integer idiv integer
|
static class |
Calculator.IntegerMinusInteger
Arithmetic: integer - integer
|
static class |
Calculator.IntegerModInteger
Arithmetic: integer mod integer
|
static class |
Calculator.IntegerPlusInteger
Arithmetic: integer + integer
|
static class |
Calculator.IntegerTimesInteger
Arithmetic: integer * integer
|
Modifier and Type | Field and Description |
---|---|
static Calculator[] |
ANY_ANY
Calculators used for the six operators when the static type information does not allow
a more specific calculator to be chosen
|
static Calculator[] |
DATETIME_DATETIME
Calculators used when both operands are xs:dateTime, xs:date, or xs:time
|
static Calculator[] |
DATETIME_DURATION
Calculators used when the first operand is xs:dateTime, xs:date, or xs:time,
and the second is a duration
|
static Calculator[] |
DECIMAL_DECIMAL |
static Calculator[] |
DECIMAL_DOUBLE
Calculators used when the first operand is a decimal
|
static Calculator[] |
DECIMAL_FLOAT |
static Calculator[] |
DECIMAL_INTEGER |
static int |
DIV |
static Calculator[] |
DOUBLE_DECIMAL |
static Calculator[] |
DOUBLE_DOUBLE
Calculators used when the first operand is a double
|
static Calculator[] |
DOUBLE_FLOAT |
static Calculator[] |
DOUBLE_INTEGER |
static Calculator[] |
DURATION_DATETIME
Calculators used when the second operand is xs:dateTime, xs:date, or xs:time,
and the first is a duration
|
static Calculator[] |
DURATION_DURATION
Calculators used when the both operands are durations
|
static Calculator[] |
DURATION_NUMERIC
Calculators used when the first operand is a duration and the second is numeric
|
static Calculator[] |
FLOAT_DECIMAL |
static Calculator[] |
FLOAT_DOUBLE
Calculators used when the first operand is a float
|
static Calculator[] |
FLOAT_FLOAT |
static Calculator[] |
FLOAT_INTEGER |
static int |
IDIV |
static Calculator[] |
INTEGER_DECIMAL |
static Calculator[] |
INTEGER_DOUBLE
Calculators used when the first operand is an integer
|
static Calculator[] |
INTEGER_FLOAT |
static Calculator[] |
INTEGER_INTEGER |
static int |
MINUS |
static int |
MOD |
static Calculator[] |
NUMERIC_DURATION
Calculators used when the second operand is a duration and the first is numeric
|
static int |
PLUS |
static int |
TIMES |
Constructor and Description |
---|
Calculator() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
code()
Get a short code to identify the calculator in expression export files
|
abstract AtomicValue |
compute(AtomicValue a,
AtomicValue b,
XPathContext c)
Perform an arithmetic operation
|
static BigDecimalValue |
decimalDivide(NumericValue a,
NumericValue b) |
static Calculator |
getCalculator(int typeA,
int typeB,
int operator,
boolean mustResolve)
Factory method to get a calculator for a given combination of types
|
static java.lang.String |
getCalculatorSetName(int typeA,
int typeB)
Get the name of the calculator set for a given combination of types
|
abstract AtomicType |
getResultType(AtomicType typeA,
AtomicType typeB)
Get the type of the result of the calculator, given arguments types typeA and typeB
|
static int |
getTokenFromOperator(int operator)
Get the token number corresponding to the operator number
|
static int |
operatorFromCode(char code) |
static Calculator |
reconstructCalculator(java.lang.String code)
Get a calculator given the short code used in the exported expression tree
|
public static final int PLUS
public static final int MINUS
public static final int TIMES
public static final int DIV
public static final int MOD
public static final int IDIV
public static final Calculator[] ANY_ANY
public static final Calculator[] DOUBLE_DOUBLE
public static final Calculator[] DOUBLE_FLOAT
public static final Calculator[] DOUBLE_DECIMAL
public static final Calculator[] DOUBLE_INTEGER
public static final Calculator[] FLOAT_DOUBLE
public static final Calculator[] FLOAT_FLOAT
public static final Calculator[] FLOAT_DECIMAL
public static final Calculator[] FLOAT_INTEGER
public static final Calculator[] DECIMAL_DOUBLE
public static final Calculator[] DECIMAL_FLOAT
public static final Calculator[] DECIMAL_DECIMAL
public static final Calculator[] DECIMAL_INTEGER
public static final Calculator[] INTEGER_DOUBLE
public static final Calculator[] INTEGER_FLOAT
public static final Calculator[] INTEGER_DECIMAL
public static final Calculator[] INTEGER_INTEGER
public static final Calculator[] DATETIME_DATETIME
public static final Calculator[] DATETIME_DURATION
public static final Calculator[] DURATION_DATETIME
public static final Calculator[] DURATION_DURATION
public static final Calculator[] DURATION_NUMERIC
public static final Calculator[] NUMERIC_DURATION
public static int getTokenFromOperator(int operator)
operator
- the Calculator operator codepublic java.lang.String code()
public static Calculator getCalculator(int typeA, int typeB, int operator, boolean mustResolve)
typeA
- fingerprint of the primitive type of the first operandtypeB
- fingerprint of the primitive type of the second operandoperator
- the arithmetic operator in usemustResolve
- indicates that a concrete Calculator is required (rather than
an ANY_ANY calculator which needs to be further resolved at run-time)public static Calculator reconstructCalculator(java.lang.String code)
code
- the short code, e.g. i+i for IntegerPlusIntegerpublic static int operatorFromCode(char code)
public static java.lang.String getCalculatorSetName(int typeA, int typeB)
typeA
- the fingerprint of the primitive type of the first operandtypeB
- the fingerprint of the primitive type of the second operandpublic abstract AtomicValue compute(AtomicValue a, AtomicValue b, XPathContext c) throws XPathException
a
- the first operand. Must not be null, and must be an instance of the type implied by the
class name.b
- the second operand. Must not be null, and must be an instance of the type implied by the
class name.c
- the XPath dynamic evaluation contextXPathException
- in the event of an arithmetic errorpublic abstract AtomicType getResultType(AtomicType typeA, AtomicType typeB)
typeA
- the type of the first operandtypeB
- the type of the second operandpublic static BigDecimalValue decimalDivide(NumericValue a, NumericValue b) throws XPathException
XPathException
Copyright (c) 2004-2018 Saxonica Limited. All rights reserved.