public class ELSupport extends Object
Modifier and Type | Field and Description |
---|---|
protected static boolean |
COERCE_TO_ZERO |
Constructor and Description |
---|
ELSupport() |
Modifier and Type | Method and 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 Object |
coerceToType(ELContext ctx,
Object obj,
Class<?> 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) |
public static final int compare(ELContext ctx, Object obj0, Object obj1) throws ELException
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:
ctx
- the context in which this comparison is taking placeobj0
- first objectobj1
- second objectELException
- if neither object is ComparableClassCastException
- if the objects are not mutually comparablepublic static final boolean equals(ELContext ctx, Object obj0, Object obj1) throws ELException
ctx
- the context in which this equality test is taking placeobj0
- the first objectobj1
- the second objectELException
- if one of the coercion failspublic static final Boolean coerceToBoolean(ELContext ctx, Object obj, boolean primitive) throws ELException
ctx
- the context in which this conversion is taking placeobj
- the object to convertprimitive
- is the target a primitive in which case coercion to null
is not permittedELException
- if object is not Boolean or Stringprotected static final Number coerceToNumber(Number number, Class<?> type) throws ELException
ELException
public static final Number coerceToNumber(ELContext ctx, Object obj, Class<?> type) throws ELException
ELException
protected static final Number coerceToNumber(String val, Class<?> type) throws ELException
ELException
public static final String coerceToString(ELContext ctx, Object obj)
ctx
- the context in which this conversion is taking placeobj
- the object to convertpublic static final Object coerceToType(ELContext ctx, Object obj, Class<?> type) throws ELException
ELException
public static final boolean isStringFloat(String str)
Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.