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.
  • Field Details

  • 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