Class JexlThreadedArithmetic
java.lang.Object
org.apache.commons.jexl2.JexlArithmetic
org.apache.commons.jexl2.JexlThreadedArithmetic
A derived arithmetic that allows different threads to operate with
different strict/lenient/math modes using the same JexlEngine.
- Since:
- 2.1
-
Field Summary
Fields inherited from class JexlArithmetic
BIGD_DOUBLE_MAX_VALUE, BIGD_DOUBLE_MIN_VALUE, BIGD_SCALE, BIGI_LONG_MAX_VALUE, BIGI_LONG_MIN_VALUE, mathContext, mathScale -
Constructor Summary
ConstructorsConstructorDescriptionJexlThreadedArithmetic(boolean lenient) Standard ctor.JexlThreadedArithmetic(boolean lenient, MathContext bigdContext, int bigdScale) Creates a JexlThreadedArithmetic instance. -
Method Summary
Modifier and TypeMethodDescriptionThe MathContext instance used for +,-,/,*,% operations on big decimals.intThe BigDecimal scale used for comparison and coercion operations.booleanChecks whether this JexlArithmetic instance triggers errors during evaluation when null is used as an operand.static voidsetLenient(Boolean flag) Overrides the default behavior and sets whether this JexlArithmetic instance triggers errors during evaluation when null is used as an operand for the current thread.static voidSets the math context.static voidsetMathScale(Integer scale) Sets the math scale.Methods inherited from class JexlArithmetic
add, bitwiseAnd, bitwiseComplement, bitwiseOr, bitwiseXor, compare, controlNullNullOperands, controlNullOperand, divide, equals, greaterThan, greaterThanOrEqual, isFloatingPoint, isFloatingPointNumber, isFloatingPointType, isNumberable, lessThan, lessThanOrEqual, matches, mod, multiply, narrow, narrowAccept, narrowArguments, narrowArrayType, narrowBigDecimal, narrowBigInteger, narrowNumber, negate, roundBigDecimal, subtract, toBigDecimal, toBigInteger, toBoolean, toDouble, toInteger, toLong, toString
-
Constructor Details
-
JexlThreadedArithmetic
Standard ctor.- Parameters:
lenient- lenient versus strict evaluation flag
-
JexlThreadedArithmetic
Creates a JexlThreadedArithmetic instance.- Parameters:
lenient- whether this arithmetic is lenient or strictbigdContext- the math context instance to use for +,-,/,*,% operations on big decimals.bigdScale- the scale used for big decimals.
-
-
Method Details
-
setLenient
Overrides the default behavior and sets whether this JexlArithmetic instance triggers errors during evaluation when null is used as an operand for the current thread.It is advised to protect calls by either calling JexlThreadedArithmetic.setLenient explicitly before evaluation or add a try/finally clause resetting the flag to avoid unexpected reuse of the lenient flag value through thread pools side-effects.
- Parameters:
flag- true means no JexlException will occur, false allows them, null reverts to default behavior- See Also:
-
setMathScale
Sets the math scale.The goal and constraints are the same than for setLenient.
- Parameters:
scale- the scale
-
setMathContext
Sets the math context.The goal and constraints are the same than for setLenient.
- Parameters:
mc- the math context
-
isLenient
Checks whether this JexlArithmetic instance triggers errors during evaluation when null is used as an operand.- Overrides:
isLenientin classJexlArithmetic- Returns:
- true if lenient, false if strict
-
getMathScale
Description copied from class:JexlArithmeticThe BigDecimal scale used for comparison and coercion operations.- Overrides:
getMathScalein classJexlArithmetic- Returns:
- the scale
-
getMathContext
Description copied from class:JexlArithmeticThe MathContext instance used for +,-,/,*,% operations on big decimals.- Overrides:
getMathContextin classJexlArithmetic- Returns:
- the math context
-