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
public abstract class ELArithmetic extends java.lang.ObjectA helper class of Arithmetic defined by the EL Specification.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classELArithmetic.BigDecimalDelegateArithmetic delegate for BigDecimal operations.static classELArithmetic.BigIntegerDelegateArithmetic delegate for BigInteger operations.static classELArithmetic.DoubleDelegateArithmetic delegate for double/float operations.static classELArithmetic.LongDelegateArithmetic delegate for long/integer operations.
-
Field Summary
Fields Modifier and Type Field Description static ELArithmetic.BigDecimalDelegateBIGDECIMALBigDecimal arithmetic delegate instance.static ELArithmetic.BigIntegerDelegateBIGINTEGERBigInteger arithmetic delegate instance.static ELArithmetic.DoubleDelegateDOUBLEDouble arithmetic delegate instance.static ELArithmetic.LongDelegateLONGLong arithmetic delegate instance.
-
Constructor Summary
Constructors Modifier Constructor Description protectedELArithmetic()Protected constructor for subclasses.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract java.lang.Numberadd(java.lang.Number num0, java.lang.Number num1)Add two numbers.static java.lang.Numberadd(java.lang.Object obj0, java.lang.Object obj1)Add two objects, coercing them to the appropriate numeric type.protected abstract java.lang.Numbercoerce(java.lang.Number num)Coerce a number to the delegate's preferred type.protected java.lang.Numbercoerce(java.lang.Object obj)Coerce an object to a number.protected abstract java.lang.Numbercoerce(java.lang.String str)Coerce a string to a number.protected abstract java.lang.Numberdivide(java.lang.Number num0, java.lang.Number num1)Divide two numbers.static java.lang.Numberdivide(java.lang.Object obj0, java.lang.Object obj1)Divide two objects, coercing them to the appropriate numeric type.static booleanisNumber(java.lang.Object obj)Check if the given object is a number.static booleanisNumberType(java.lang.Class<?> type)Check if the given class is a number type.protected abstract booleanmatches(java.lang.Object obj0, java.lang.Object obj1)Check if this delegate matches the given operand types.protected abstract java.lang.Numbermod(java.lang.Number num0, java.lang.Number num1)Compute the modulo of two numbers.static java.lang.Numbermod(java.lang.Object obj0, java.lang.Object obj1)Compute the modulo of two objects, coercing them to the appropriate numeric type.protected abstract java.lang.Numbermultiply(java.lang.Number num0, java.lang.Number num1)Multiply two numbers.static java.lang.Numbermultiply(java.lang.Object obj0, java.lang.Object obj1)Multiply two objects, coercing them to the appropriate numeric type.protected abstract java.lang.Numbersubtract(java.lang.Number num0, java.lang.Number num1)Subtract two numbers.static java.lang.Numbersubtract(java.lang.Object obj0, java.lang.Object obj1)Subtract two objects, coercing them to the appropriate numeric type.
-
-
-
Field Detail
-
BIGDECIMAL
public static final ELArithmetic.BigDecimalDelegate BIGDECIMAL
BigDecimal arithmetic delegate instance.
-
BIGINTEGER
public static final ELArithmetic.BigIntegerDelegate BIGINTEGER
BigInteger arithmetic delegate instance.
-
DOUBLE
public static final ELArithmetic.DoubleDelegate DOUBLE
Double arithmetic delegate instance.
-
LONG
public static final ELArithmetic.LongDelegate LONG
Long arithmetic delegate instance.
-
-
Method Detail
-
add
public static java.lang.Number add(java.lang.Object obj0, java.lang.Object obj1)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
public static java.lang.Number mod(java.lang.Object obj0, java.lang.Object obj1)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
public static java.lang.Number subtract(java.lang.Object obj0, java.lang.Object obj1)Subtract two objects, coercing them to the appropriate numeric type.- Parameters:
obj0- The minuendobj1- The subtrahend- Returns:
- The result of the subtraction
-
divide
public static java.lang.Number divide(java.lang.Object obj0, java.lang.Object obj1)Divide two objects, coercing them to the appropriate numeric type.- Parameters:
obj0- The dividendobj1- The divisor- Returns:
- The result of the division
-
multiply
public static java.lang.Number multiply(java.lang.Object obj0, java.lang.Object obj1)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
public static boolean isNumber(java.lang.Object obj)
Check if the given object is a number.- Parameters:
obj- The object to check- Returns:
- true if the object is a number
-
isNumberType
public static boolean isNumberType(java.lang.Class<?> type)
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
protected abstract java.lang.Number add(java.lang.Number num0, java.lang.Number num1)Add two numbers.- Parameters:
num0- The first numbernum1- The second number- Returns:
- The sum
-
multiply
protected abstract java.lang.Number multiply(java.lang.Number num0, java.lang.Number num1)Multiply two numbers.- Parameters:
num0- The first numbernum1- The second number- Returns:
- The product
-
subtract
protected abstract java.lang.Number subtract(java.lang.Number num0, java.lang.Number num1)Subtract two numbers.- Parameters:
num0- The minuendnum1- The subtrahend- Returns:
- The difference
-
mod
protected abstract java.lang.Number mod(java.lang.Number num0, java.lang.Number num1)Compute the modulo of two numbers.- Parameters:
num0- The dividendnum1- The divisor- Returns:
- The remainder
-
coerce
protected abstract java.lang.Number coerce(java.lang.Number num)
Coerce a number to the delegate's preferred type.- Parameters:
num- The number to coerce- Returns:
- The coerced number
-
coerce
protected final java.lang.Number coerce(java.lang.Object obj)
Coerce an object to a number.- Parameters:
obj- The object to coerce- Returns:
- The coerced number
-
coerce
protected abstract java.lang.Number coerce(java.lang.String str)
Coerce a string to a number.- Parameters:
str- The string to coerce- Returns:
- The coerced number
-
divide
protected abstract java.lang.Number divide(java.lang.Number num0, java.lang.Number num1)Divide two numbers.- Parameters:
num0- The dividendnum1- The divisor- Returns:
- The quotient
-
matches
protected abstract boolean matches(java.lang.Object obj0, java.lang.Object obj1)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
-
-