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

# Class ELSupport

java.lang.Object
org.apache.el.lang.ELSupport

public class ELSupport extends Object
A helper class that implements the EL Specification.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected static final boolean`
  `COERCE_TO_ZERO`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Boolean`
  `coerceToBoolean(ELContext ctx, Object obj, boolean primitive)`
  Convert an object to Boolean.
  `static Enum<?>`
  `coerceToEnum(ELContext ctx, Object obj, Class type)`
  `static Number`
  `coerceToNumber(ELContext ctx, Object obj, Class<?> type)`
  `protected static Number`
  `coerceToNumber(Number number, Class<?> type)`
  `protected static Number`
  `coerceToNumber(String val, Class<?> type)`
  `static String`
  `coerceToString(ELContext ctx, Object obj)`
  Coerce an object to a string.
  `static <T> T`
  `coerceToType(ELContext ctx, Object obj, Class<T> type)`
  `static int`
  `compare(ELContext ctx, Object obj0, Object obj1)`
  Compare two objects, after coercing to the same type if appropriate.
  `static boolean`
  `equals(ELContext ctx, Object obj0, Object obj1)`
  Compare two objects for equality, after coercing to the same type if appropriate.
  `static boolean`
  `isBigDecimalOp(Object obj0, Object obj1)`
  `static boolean`
  `isBigIntegerOp(Object obj0, Object obj1)`
  `static boolean`
  `isDoubleOp(Object obj0, Object obj1)`
  `static boolean`
  `isLongOp(Object obj0, Object obj1)`
  `static boolean`
  `isStringFloat(String str)`

  ### Methods inherited from class Object

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

- ## Field Details

  - ### COERCE_TO_ZERO

    protected static final boolean COERCE_TO_ZERO

- ## Method Details

  - ### compare

    public static int compare(ELContext ctx, Object obj0, Object obj1) throws ELException
    Compare two objects, after coercing to the same type if appropriate.

    If the objects are identical, or they are equal according to `equals(ELContext, Object, Object)` then return 0.

    If either object is a BigDecimal, then coerce both to BigDecimal first. Similarly for Double(Float), BigInteger, and Long(Integer, Char, Short, Byte).

    Otherwise, check that the first object is an instance of Comparable, and compare against the second object. If that is null, return 1, otherwise return the result of comparing against the second object.

    Similarly, if the second object is Comparable, if the first is null, return -1, else return the result of comparing against the first object.

    A null object is considered as:

    - ZERO when compared with Numbers
    - the empty string for String compares
    - Otherwise null is considered to be lower than anything else.
    Parameters:
      `ctx` - the context in which this comparison is taking place
      `obj0` - first object
      `obj1` - second object
    Returns:
      -1, 0, or 1 if this object is less than, equal to, or greater than val.
    Throws:
      `ELException` - if neither object is Comparable
      `ClassCastException` - if the objects are not mutually comparable

  - ### equals

    public static boolean equals(ELContext ctx, Object obj0, Object obj1) throws ELException
    Compare two objects for equality, after coercing to the same type if appropriate.

    If the objects are identical (including both null) return true.

    If either object is null, return false.

    If either object is Boolean, coerce both to Boolean and check equality.

    Similarly for Enum, String, BigDecimal, Double(Float), Long(Integer, Short, Byte, Character)

    Otherwise default to using Object.equals().

    Parameters:
      `ctx` - the context in which this equality test is taking place
      `obj0` - the first object
      `obj1` - the second object
    Returns:
      true if the objects are equal
    Throws:
      `ELException` - if one of the coercion fails

  - ### coerceToEnum

    public static Enum<?> coerceToEnum(ELContext ctx, Object obj, Class type)

  - ### coerceToBoolean

    public static Boolean coerceToBoolean(ELContext ctx, Object obj, boolean primitive) throws ELException
    Convert an object to Boolean. Null and empty string are false.
    Parameters:
      `ctx` - the context in which this conversion is taking place
      `obj` - the object to convert
      `primitive` - is the target a primitive in which case coercion to null is not permitted
    Returns:
      the Boolean value of the object
    Throws:
      `ELException` - if object is not Boolean or String

  - ### coerceToNumber

    protected static Number coerceToNumber(Number number, Class<?> type) throws ELException
    Throws:
      `ELException`

  - ### coerceToNumber

    public static Number coerceToNumber(ELContext ctx, Object obj, Class<?> type) throws ELException
    Throws:
      `ELException`

  - ### coerceToNumber

    protected static Number coerceToNumber(String val, Class<?> type) throws ELException
    Throws:
      `ELException`

  - ### coerceToString

    public static String coerceToString(ELContext ctx, Object obj)
    Coerce an object to a string.
    Parameters:
      `ctx` - the context in which this conversion is taking place
      `obj` - the object to convert
    Returns:
      the String value of the object

  - ### coerceToType

    public static <T> T coerceToType(ELContext ctx, Object obj, Class<T> type) throws ELException
    Throws:
      `ELException`

  - ### isBigDecimalOp

    public static boolean isBigDecimalOp(Object obj0, Object obj1)

  - ### isBigIntegerOp

    public static boolean isBigIntegerOp(Object obj0, Object obj1)

  - ### isDoubleOp

    public static boolean isDoubleOp(Object obj0, Object obj1)

  - ### isLongOp

    public static boolean isLongOp(Object obj0, Object obj1)

  - ### isStringFloat

    public static boolean isStringFloat(String str)