Class MathUtil
- java.lang.Object
-
- org.eclipse.rdf4j.query.algebra.evaluation.util.MathUtil
-
public class MathUtil extends Object
A utility class for evaluation of mathematical expressions on RDF literals.- Author:
- Jeen Broekstra
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_DECIMAL_EXPANSION_SCALE
The default expansion scale used in division operations resulting in a decimal value with non-terminating decimal expansion.
-
Constructor Summary
Constructors Constructor Description MathUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Literal
compute(Literal leftLit, Literal rightLit, MathExpr.MathOp op)
Computes the result of applying the supplied math operator on the supplied left and right operand.static int
getDecimalExpansionScale()
Returns the decimal expansion scale used in division operations resulting in a decimal value with non-terminating decimal expansion.static void
setDecimalExpansionScale(int decimalExpansionScale)
Sets the decimal expansion scale used in divisions resulting in a decimal value with non-terminating decimal expansion.
-
-
-
Field Detail
-
DEFAULT_DECIMAL_EXPANSION_SCALE
public static final int DEFAULT_DECIMAL_EXPANSION_SCALE
The default expansion scale used in division operations resulting in a decimal value with non-terminating decimal expansion. The OpenRDF default is 24 digits, a value used in various other SPARQL implementations, to make comparison between these systems easy.- See Also:
- Constant Field Values
-
-
Method Detail
-
compute
public static Literal compute(Literal leftLit, Literal rightLit, MathExpr.MathOp op) throws ValueExprEvaluationException
Computes the result of applying the supplied math operator on the supplied left and right operand.- Parameters:
leftLit
- a numeric datatype literalrightLit
- a numeric datatype literalop
- a mathematical operator, as definied by MathExpr.MathOp.- Returns:
- a numeric datatype literal containing the result of the operation. The result will be datatype according to the most specific data type the two operands have in common per the SPARQL/XPath spec.
- Throws:
ValueExprEvaluationException
-
getDecimalExpansionScale
public static int getDecimalExpansionScale()
Returns the decimal expansion scale used in division operations resulting in a decimal value with non-terminating decimal expansion. By default, this value is set to 24.- Returns:
- The decimal expansion scale.
-
setDecimalExpansionScale
public static void setDecimalExpansionScale(int decimalExpansionScale)
Sets the decimal expansion scale used in divisions resulting in a decimal value with non-terminating decimal expansion.- Parameters:
decimalExpansionScale
- The decimal expansion scale to set. Note that a mimimum of 18 is required to stay compliant with the XPath specification of xsd:decimal operations.
-
-