ELArithmetic (Apache Tomcat 11.0.24 API Documentation)
Description: declaration: package: org.apache.el.lang, class: ELArithmetic

# 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 Object
A helper class of Arithmetic defined by the EL Specification.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static final class`
  `ELArithmetic.BigDecimalDelegate`
  Arithmetic delegate for BigDecimal operations.
  `static final class`
  `ELArithmetic.BigIntegerDelegate`
  Arithmetic delegate for BigInteger operations.
  `static final class`
  `ELArithmetic.DoubleDelegate`
  Arithmetic delegate for double/float operations.
  `static final class`
  `ELArithmetic.LongDelegate`
  Arithmetic delegate for long/integer operations.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final ELArithmetic.BigDecimalDelegate`
  `BIGDECIMAL`
  BigDecimal arithmetic delegate instance.
  `static final ELArithmetic.BigIntegerDelegate`
  `BIGINTEGER`
  BigInteger arithmetic delegate instance.
  `static final ELArithmetic.DoubleDelegate`
  `DOUBLE`
  Double arithmetic delegate instance.
  `static final ELArithmetic.LongDelegate`
  `LONG`
  Long arithmetic delegate instance.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `ELArithmetic()`
  Protected constructor for subclasses.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected abstract Number`
  `add(Number num0, Number num1)`
  Add two numbers.
  `static Number`
  `add(Object obj0, Object obj1)`
  Add two objects, coercing them to the appropriate numeric type.
  `protected abstract Number`
  `coerce(Number num)`
  Coerce a number to the delegate's preferred type.
  `protected final Number`
  `coerce(Object obj)`
  Coerce an object to a number.
  `protected abstract Number`
  `coerce(String str)`
  Coerce a string to a number.
  `protected abstract Number`
  `divide(Number num0, Number num1)`
  Divide two numbers.
  `static Number`
  `divide(Object obj0, Object obj1)`
  Divide two objects, coercing them to the appropriate numeric type.
  `static boolean`
  `isNumber(Object obj)`
  Check if the given object is a number.
  `static boolean`
  `isNumberType(Class<?> type)`
  Check if the given class is a number type.
  `protected abstract boolean`
  `matches(Object obj0, Object obj1)`
  Check if this delegate matches the given operand types.
  `protected abstract Number`
  `mod(Number num0, Number num1)`
  Compute the modulo of two numbers.
  `static Number`
  `mod(Object obj0, Object obj1)`
  Compute the modulo of two objects, coercing them to the appropriate numeric type.
  `protected abstract Number`
  `multiply(Number num0, Number num1)`
  Multiply two numbers.
  `static Number`
  `multiply(Object obj0, Object obj1)`
  Multiply two objects, coercing them to the appropriate numeric type.
  `protected abstract Number`
  `subtract(Number num0, Number num1)`
  Subtract two numbers.
  `static Number`
  `subtract(Object obj0, Object obj1)`
  Subtract two objects, coercing them to the appropriate numeric type.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### 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.

- ## Constructor Details

  - ### ELArithmetic

    protected ELArithmetic()
    Protected constructor for subclasses.

- ## Method Details

  - ### add

    public static Number add(Object obj0, Object obj1)
    Add two objects, coercing them to the appropriate numeric type.
    Parameters:
      `obj0` - The first operand
      `obj1` - The second operand
    Returns:
      The result of the addition

  - ### mod

    public static Number mod(Object obj0, Object obj1)
    Compute the modulo of two objects, coercing them to the appropriate numeric type.
    Parameters:
      `obj0` - The dividend
      `obj1` - The divisor
    Returns:
      The result of the modulo operation

  - ### subtract

    public static Number subtract(Object obj0, Object obj1)
    Subtract two objects, coercing them to the appropriate numeric type.
    Parameters:
      `obj0` - The minuend
      `obj1` - The subtrahend
    Returns:
      The result of the subtraction

  - ### divide

    public static Number divide(Object obj0, Object obj1)
    Divide two objects, coercing them to the appropriate numeric type.
    Parameters:
      `obj0` - The dividend
      `obj1` - The divisor
    Returns:
      The result of the division

  - ### multiply

    public static Number multiply(Object obj0, Object obj1)
    Multiply two objects, coercing them to the appropriate numeric type.
    Parameters:
      `obj0` - The first factor
      `obj1` - The second factor
    Returns:
      The result of the multiplication

  - ### isNumber

    public static boolean isNumber(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(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 Number add(Number num0, Number num1)
    Add two numbers.
    Parameters:
      `num0` - The first number
      `num1` - The second number
    Returns:
      The sum

  - ### multiply

    protected abstract Number multiply(Number num0, Number num1)
    Multiply two numbers.
    Parameters:
      `num0` - The first number
      `num1` - The second number
    Returns:
      The product

  - ### subtract

    protected abstract Number subtract(Number num0, Number num1)
    Subtract two numbers.
    Parameters:
      `num0` - The minuend
      `num1` - The subtrahend
    Returns:
      The difference

  - ### mod

    protected abstract Number mod(Number num0, Number num1)
    Compute the modulo of two numbers.
    Parameters:
      `num0` - The dividend
      `num1` - The divisor
    Returns:
      The remainder

  - ### coerce

    protected abstract Number coerce(Number num)
    Coerce a number to the delegate's preferred type.
    Parameters:
      `num` - The number to coerce
    Returns:
      The coerced number

  - ### coerce

    protected final Number coerce(Object obj)
    Coerce an object to a number.
    Parameters:
      `obj` - The object to coerce
    Returns:
      The coerced number

  - ### coerce

    protected abstract Number coerce(String str)
    Coerce a string to a number.
    Parameters:
      `str` - The string to coerce
    Returns:
      The coerced number

  - ### divide

    protected abstract Number divide(Number num0, Number num1)
    Divide two numbers.
    Parameters:
      `num0` - The dividend
      `num1` - The divisor
    Returns:
      The quotient

  - ### matches

    protected abstract boolean matches(Object obj0, Object obj1)
    Check if this delegate matches the given operand types.
    Parameters:
      `obj0` - The first operand
      `obj1` - The second operand
    Returns:
      true if this delegate should handle these types