Package org.apache.el.lang
Class ELArithmetic
java.lang.Object
org.apache.el.lang.ELArithmetic
- Direct Known Subclasses:
ELArithmetic.BigDecimalDelegate,ELArithmetic.BigIntegerDelegate,ELArithmetic.DoubleDelegate,ELArithmetic.LongDelegate
A helper class of Arithmetic defined by the EL Specification.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classArithmetic delegate for BigDecimal operations.static final classArithmetic delegate for BigInteger operations.static final classArithmetic delegate for double/float operations.static final classArithmetic delegate for long/integer operations. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ELArithmetic.BigDecimalDelegateBigDecimal arithmetic delegate instance.static final ELArithmetic.BigIntegerDelegateBigInteger arithmetic delegate instance.static final ELArithmetic.DoubleDelegateDouble arithmetic delegate instance.static final ELArithmetic.LongDelegateLong arithmetic delegate instance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract NumberAdd two numbers.static NumberAdd two objects, coercing them to the appropriate numeric type.protected abstract NumberCoerce a number to the delegate's preferred type.protected final NumberCoerce an object to a number.protected abstract NumberCoerce a string to a number.protected abstract NumberDivide two numbers.static NumberDivide two objects, coercing them to the appropriate numeric type.static booleanCheck if the given object is a number.static booleanisNumberType(Class<?> type) Check if the given class is a number type.protected abstract booleanCheck if this delegate matches the given operand types.protected abstract NumberCompute the modulo of two numbers.static NumberCompute the modulo of two objects, coercing them to the appropriate numeric type.protected abstract NumberMultiply two numbers.static NumberMultiply two objects, coercing them to the appropriate numeric type.protected abstract NumberSubtract two numbers.static NumberSubtract two objects, coercing them to the appropriate numeric type.
-
Field Details
-
BIGDECIMAL
BigDecimal arithmetic delegate instance. -
BIGINTEGER
BigInteger arithmetic delegate instance. -
DOUBLE
Double arithmetic delegate instance. -
LONG
Long arithmetic delegate instance.
-
-
Constructor Details
-
ELArithmetic
protected ELArithmetic()Protected constructor for subclasses.
-
-
Method Details
-
add
Add two objects, coercing them to the appropriate numeric type.- Parameters:
obj0- The first operandobj1- The second operand- Returns:
- The result of the addition
-
mod
Compute the modulo of two objects, coercing them to the appropriate numeric type.- Parameters:
obj0- The dividendobj1- The divisor- Returns:
- The result of the modulo operation
-
subtract
Subtract two objects, coercing them to the appropriate numeric type.- Parameters:
obj0- The minuendobj1- The subtrahend- Returns:
- The result of the subtraction
-
divide
Divide two objects, coercing them to the appropriate numeric type.- Parameters:
obj0- The dividendobj1- The divisor- Returns:
- The result of the division
-
multiply
Multiply two objects, coercing them to the appropriate numeric type.- Parameters:
obj0- The first factorobj1- The second factor- Returns:
- The result of the multiplication
-
isNumber
Check if the given object is a number.- Parameters:
obj- The object to check- Returns:
- true if the object is a number
-
isNumberType
Check if the given class is a number type.- Parameters:
type- The class to check- Returns:
- true if the class is a number type
-
add
Add two numbers.- Parameters:
num0- The first numbernum1- The second number- Returns:
- The sum
-
multiply
Multiply two numbers.- Parameters:
num0- The first numbernum1- The second number- Returns:
- The product
-
subtract
Subtract two numbers.- Parameters:
num0- The minuendnum1- The subtrahend- Returns:
- The difference
-
mod
Compute the modulo of two numbers.- Parameters:
num0- The dividendnum1- The divisor- Returns:
- The remainder
-
coerce
Coerce a number to the delegate's preferred type.- Parameters:
num- The number to coerce- Returns:
- The coerced number
-
coerce
Coerce an object to a number.- Parameters:
obj- The object to coerce- Returns:
- The coerced number
-
coerce
Coerce a string to a number.- Parameters:
str- The string to coerce- Returns:
- The coerced number
-
divide
Divide two numbers.- Parameters:
num0- The dividendnum1- The divisor- Returns:
- The quotient
-
matches
Check if this delegate matches the given operand types.- Parameters:
obj0- The first operandobj1- The second operand- Returns:
- true if this delegate should handle these types
-