All arithmetic operators (+, - , *, /, %) follow the same rules regarding their arguments.
| Modifier and Type | Field and Description |
|---|---|
| protected static final BigDecimal | BIGD_DOUBLE_MAX_VALUE
Double.MAX_VALUE as BigDecimal. |
| protected static final BigDecimal | BIGD_DOUBLE_MIN_VALUE
Double.MIN_VALUE as BigDecimal. |
| protected static final int | BIGD_SCALE
Default BigDecimal scale. |
| protected static final BigInteger | BIGI_LONG_MAX_VALUE
Long.MAX_VALUE as BigInteger. |
| protected static final BigInteger | BIGI_LONG_MIN_VALUE
Long.MIN_VALUE as BigInteger. |
| protected final MathContext | mathContext
The big decimal math context. |
| protected final int | mathScale
The big decimal scale. |
| private volatile boolean | strict
Whether this JexlArithmetic instance behaves in strict or lenient mode. |
| Access | Constructor and Description |
|---|---|
| public | JexlArithmetic(boolean
whether this arithmetic is lenient or strict lenient)Creates a JexlArithmetic. |
| public | JexlArithmetic(boolean
whether this arithmetic is lenient or strict lenient, MathContext the math context instance to use for +,-,/,*,% operations on big decimals. bigdContext, int the scale used for big decimals. bigdScale)Creates a JexlArithmetic. |
| Modifier and Type | Method and Description |
|---|---|
| public Object | |
| public Object | Returns: left & rightthe left operand left, Object the right operator right)Performs a bitwise and. |
| public Object | |
| public Object | |
| public Object | Returns: left rightthe left operand left, Object the right operator right)Performs a bitwise xor. |
| protected int | |
| protected Object | Returns: Integer(0) if lenientThe result of +,/,-,*,% when both operands are null. |
| protected void | |
| public Object | |
| public boolean | |
| public MathContext | Returns: the math contextThe MathContext instance used for +,-,/,*,% operations on big decimals. |
| public int | |
| public boolean | Returns: test result.first value left, Object second value right)Test if left > right. |
| public boolean | Returns: test result.first value left, Object second value right)Test if left >= right. |
| protected boolean | Returns: true if it is a Float or a Double.Object to be analyzed. o)Is Object a floating point number. |
| protected boolean | Returns: true if it is, false otherwise.the object to be tested val)Test if the passed value is a floating point number, i.e. a float, double or string with ( "." | "E" | "e"). |
| protected boolean | Returns: the result of the test.one object to test left, Object the other right)Test if either left or right are either a Float or Double. |
| public boolean | Returns: true if lenient, false if strictChecks whether this JexlArithmetic instance triggers errors during evaluation when null is used as an operand. |
| protected boolean | Returns: true if Integer, Long, Byte, Short or Character.Object to be analyzed. o)Is Object a whole number. |
| public boolean | |
| public boolean | Returns: test result.first value left, Object second value right)Test if left <= right. |
| public boolean | |
| public Object | |
| public Object | |
| public Number | |
| protected boolean | Returns: true if attempt to narrow source to target is acceptedthe target narrow class narrow, Class<?> the orginal source class source)Whether we consider the narrow class as a potential candidate for narrowing the source. |
| protected boolean | Returns: true if some arguments were narrowed and args array is modified, false if no narrowing occured and args array has not been modifiedthe argument array args)Replace all numbers in an arguments array with the smallest type that will fit. |
| protected Object | Returns: the original array if the attempt to strictly type the array fails, a typed array otherwisean untyped array untyped)Given an array of objects, attempt to type it more strictly. |
| protected Number | Returns: an Integer or Long if narrowing is possible, the original BigInteger otherwisethe left hand side operand that lead to the bigd result lhs, Object the right hand side operand that lead to the bigd result rhs, BigDecimal the BigDecimal to narrow bigd)Given a BigDecimal, attempt to narrow it to an Integer or Long if it fits if one of the arguments is a numberable. |
| protected Number | Returns: an Integer or Long if narrowing is possible, the original BigInteger otherwisethe left hand side operand that lead to the bigi result lhs, Object the right hand side operand that lead to the bigi result rhs, BigInteger the BigInteger to narrow bigi)Given a BigInteger, narrow it to an Integer or Long if it fits and the arguments class allow it. |
| protected Number | Returns: the narrowed number or the source if no narrowing was possiblethe original number original, Class<?> the attempted target class narrow)Given a Number, return back the value attempting to narrow it to a target class. |
| public Object | |
| public BigDecimal | Returns: the rounded big decimalthe big decimal to round number)Ensure a big decimal is rounded by this arithmetic scale and rounding mode. |
| pack-priv void | setLenient(boolean
true means no JexlException will occur, false allows them flag)
Deprecated
as of 2.1 - may be removed in a later release
Sets whether this JexlArithmetic instance triggers errors during evaluation when
null is used as an operand.
|
| public Object | |
| public BigDecimal | Returns: a BigDecimal.the object to be coerced. val)Get a BigDecimal from the object passed. |
| public BigInteger | Returns: a BigDecimal.the object to be coerced. val)Get a BigInteger from the object passed. |
| public boolean | |
| public double | |
| public int | |
| public long | |
| public String |
| BIGD_DOUBLE_MAX_VALUE | back to summary |
|---|---|
| protected static final BigDecimal BIGD_DOUBLE_MAX_VALUE Double.MAX_VALUE as BigDecimal. | |
| BIGD_DOUBLE_MIN_VALUE | back to summary |
|---|---|
| protected static final BigDecimal BIGD_DOUBLE_MIN_VALUE Double.MIN_VALUE as BigDecimal. | |
| BIGD_SCALE | back to summary |
|---|---|
| protected static final int BIGD_SCALE Default BigDecimal scale.
| |
| BIGI_LONG_MAX_VALUE | back to summary |
|---|---|
| protected static final BigInteger BIGI_LONG_MAX_VALUE Long.MAX_VALUE as BigInteger. | |
| BIGI_LONG_MIN_VALUE | back to summary |
|---|---|
| protected static final BigInteger BIGI_LONG_MIN_VALUE Long.MIN_VALUE as BigInteger. | |
| mathContext | back to summary |
|---|---|
| protected final MathContext mathContext The big decimal math context.
| |
| mathScale | back to summary |
|---|---|
| protected final int mathScale The big decimal scale.
| |
| strict | back to summary |
|---|---|
| private volatile boolean strict Whether this JexlArithmetic instance behaves in strict or lenient mode. May be made final in a later version. | |
| JexlArithmetic | back to summary |
|---|---|
| public JexlArithmetic(boolean lenient) Creates a JexlArithmetic.
| |
| JexlArithmetic | back to summary |
|---|---|
| public JexlArithmetic(boolean lenient, MathContext bigdContext, int bigdScale) Creates a JexlArithmetic.
| |
| add | back to summary |
|---|---|
| public Object add(Object left, Object right) Add two values together. If any numeric add fails on coercion to the appropriate type, treat as Strings and do concatenation. | |
| bitwiseAnd | back to summary |
|---|---|
| public Object bitwiseAnd(Object left, Object right) Performs a bitwise and. | |
| bitwiseComplement | back to summary |
|---|---|
| public Object bitwiseComplement(Object val) Performs a bitwise complement. | |
| bitwiseOr | back to summary |
|---|---|
| public Object bitwiseOr(Object left, Object right) Performs a bitwise or. | |
| bitwiseXor | back to summary |
|---|---|
| public Object bitwiseXor(Object left, Object right) Performs a bitwise xor. | |
| compare | back to summary |
|---|---|
| protected int compare(Object left, Object right, String operator) Performs a comparison.
| |
| controlNullNullOperands | back to summary |
|---|---|
| protected Object controlNullNullOperands() The result of +,/,-,*,% when both operands are null.
| |
| controlNullOperand | back to summary |
|---|---|
| protected void controlNullOperand() Throw a NPE if arithmetic is strict.
| |
| divide | back to summary |
|---|---|
| public Object divide(Object left, Object right) Divide the left value by the right.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object left, Object right) Test if left and right are equal. | |
| getMathContext | back to summary |
|---|---|
| public MathContext getMathContext() The MathContext instance used for +,-,/,*,% operations on big decimals.
| |
| getMathScale | back to summary |
|---|---|
| public int getMathScale() The BigDecimal scale used for comparison and coercion operations.
| |
| greaterThan | back to summary |
|---|---|
| public boolean greaterThan(Object left, Object right) Test if left > right. | |
| greaterThanOrEqual | back to summary |
|---|---|
| public boolean greaterThanOrEqual(Object left, Object right) Test if left >= right. | |
| isFloatingPoint | back to summary |
|---|---|
| protected boolean isFloatingPoint(final Object o) Is Object a floating point number.
| |
| isFloatingPointNumber | back to summary |
|---|---|
| protected boolean isFloatingPointNumber(Object val) Test if the passed value is a floating point number, i.e. a float, double or string with ( "." | "E" | "e").
| |
| isFloatingPointType | back to summary |
|---|---|
| protected boolean isFloatingPointType(Object left, Object right) Test if either left or right are either a Float or Double. | |
| isLenient | back to summary |
|---|---|
| public boolean isLenient() Checks whether this JexlArithmetic instance triggers errors during evaluation when null is used as an operand.
| |
| isNumberable | back to summary |
|---|---|
| protected boolean isNumberable(final Object o) Is Object a whole number.
| |
| lessThan | back to summary |
|---|---|
| public boolean lessThan(Object left, Object right) Test if left < right. | |
| lessThanOrEqual | back to summary |
|---|---|
| public boolean lessThanOrEqual(Object left, Object right) Test if left <= right. | |
| matches | back to summary |
|---|---|
| public boolean matches(Object left, Object right) Test if left regexp matches right. | |
| mod | back to summary |
|---|---|
| public Object mod(Object left, Object right) left value mod right.
| |
| multiply | back to summary |
|---|---|
| public Object multiply(Object left, Object right) Multiply the left value by the right. | |
| narrow | back to summary |
|---|---|
| public Number narrow(Number original) Given a Number, return back the value using the smallest type the result will fit into. This works hand in hand with parameter 'widening' in java method calls, e.g. a call to substring(int,int) with an int and a long will fail, but a call to substring(int,int) with an int and a short will succeed. | |
| narrowAccept | back to summary |
|---|---|
| protected boolean narrowAccept(Class<?> narrow, Class<?> source) Whether we consider the narrow class as a potential candidate for narrowing the source. | |
| narrowArguments | back to summary |
|---|---|
| protected boolean narrowArguments(Object[] args) Replace all numbers in an arguments array with the smallest type that will fit.
| |
| narrowArrayType | back to summary |
|---|---|
| protected Object narrowArrayType(Object[] untyped) Given an array of objects, attempt to type it more strictly.
| |
| narrowBigDecimal | back to summary |
|---|---|
| protected Number narrowBigDecimal(Object lhs, Object rhs, BigDecimal bigd) Given a BigDecimal, attempt to narrow it to an Integer or Long if it fits if one of the arguments is a numberable.
| |
| narrowBigInteger | back to summary |
|---|---|
| protected Number narrowBigInteger(Object lhs, Object rhs, BigInteger bigi) Given a BigInteger, narrow it to an Integer or Long if it fits and the arguments class allow it. The rules are: if either arguments is a BigInteger, no narrowing will occur if either arguments is a Long, no narrowing to Integer will occur
| |
| narrowNumber | back to summary |
|---|---|
| protected Number narrowNumber(Number original, Class<?> narrow) Given a Number, return back the value attempting to narrow it to a target class. | |
| negate | back to summary |
|---|---|
| public Object negate(Object val) Negates a value (unary minus for numbers). | |
| roundBigDecimal | back to summary |
|---|---|
| public BigDecimal roundBigDecimal(final BigDecimal number) Ensure a big decimal is rounded by this arithmetic scale and rounding mode.
| |
| setLenient | back to summary |
|---|---|
| pack-priv void setLenient(boolean flag)
Deprecated as of 2.1 - may be removed in a later release Sets whether this JexlArithmetic instance triggers errors during evaluation when null is used as an operand. This method is not thread safe; it may be called as an optional step by the JexlEngine in its initialization code before expression creation & evaluation.
| |
| subtract | back to summary |
|---|---|
| public Object subtract(Object left, Object right) Subtract the right value from the left. | |
| toBigDecimal | back to summary |
|---|---|
| public BigDecimal toBigDecimal(Object val) Get a BigDecimal from the object passed. Null and empty string maps to zero.
| |
| toBigInteger | back to summary |
|---|---|
| public BigInteger toBigInteger(Object val) Get a BigInteger from the object passed. Null and empty string maps to zero.
| |
| toBoolean | back to summary |
|---|---|
| public boolean toBoolean(Object val) Coerce to a boolean (not a java.lang.Boolean).
| |
| toDouble | back to summary |
|---|---|
| public double toDouble(Object val) Coerce to a double.
| |
| toInteger | back to summary |
|---|---|
| public int toInteger(Object val) Coerce to a int.
| |
| toLong | back to summary |
|---|---|
| public long toLong(Object val) Coerce to a long (not a java.lang.Long).
| |
| toString | back to summary |
|---|---|
| public String toString(Object val) Coerce to a string.
| |