public class ELSupport
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static boolean |
COERCE_NULL_TO_NULL
EL 2.2 by spec. should coerce "null" value to 0 number, 0 character, "" String, false boolean.
|
protected static boolean |
COERCE_TO_ZERO |
Constructor and Description |
---|
ELSupport() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Boolean |
coerceToBoolean(java.lang.Object obj,
boolean primitive)
Convert an object to Boolean.
|
static java.util.Date |
coerceToDateTime(java.lang.Object obj,
java.lang.Class type)
Coerce an object to an instance of java.util.Date
|
static java.lang.Enum<?> |
coerceToEnum(java.lang.Object obj,
java.lang.Class type) |
protected static java.lang.Number |
coerceToNumber(java.lang.Number number,
java.lang.Class<?> type) |
static java.lang.Number |
coerceToNumber(java.lang.Object obj,
java.lang.Class<?> type) |
protected static java.lang.Number |
coerceToNumber(java.lang.String val,
java.lang.Class<?> type) |
static java.lang.String |
coerceToString(java.lang.Object obj)
Coerce an object to a string.
|
static java.lang.Object |
coerceToType(java.lang.Object obj,
java.lang.Class<?> type) |
protected static java.lang.Object |
coerceToTypeForSetValue(java.lang.Object obj,
java.lang.Class<?> type) |
static int |
compare(java.lang.Object obj0,
java.lang.Object obj1)
Compare two objects, after coercing to the same type if appropriate.
|
static boolean |
equals(java.lang.Object obj0,
java.lang.Object obj1)
Compare two objects for equality, after coercing to the same type if appropriate.
|
static boolean |
isBigDecimalOp(java.lang.Object obj0,
java.lang.Object obj1) |
static boolean |
isBigIntegerOp(java.lang.Object obj0,
java.lang.Object obj1) |
static boolean |
isDateTimeType(java.lang.Class<?> type) |
static boolean |
isDoubleOp(java.lang.Object obj0,
java.lang.Object obj1) |
static boolean |
isLongOp(java.lang.Object obj0,
java.lang.Object obj1) |
static boolean |
isStringFloat(java.lang.String str) |
protected static final boolean COERCE_NULL_TO_NULL
protected static final boolean COERCE_TO_ZERO
public static final int compare(java.lang.Object obj0, java.lang.Object obj1) throws ELException
equals(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:
obj0
- first objectobj1
- second objectELException
- if neither object is Comparablejava.lang.ClassCastException
- if the objects are not mutually comparablepublic static final boolean equals(java.lang.Object obj0, java.lang.Object obj1) throws ELException
obj0
- the first objectobj1
- the second objectELException
- if one of the coercion failspublic static final java.lang.Enum<?> coerceToEnum(java.lang.Object obj, java.lang.Class type)
public static final java.lang.Boolean coerceToBoolean(java.lang.Object obj, boolean primitive) throws ELException
obj
- 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 java.lang.Number coerceToNumber(java.lang.Number number, java.lang.Class<?> type) throws ELException
ELException
public static final java.lang.Number coerceToNumber(java.lang.Object obj, java.lang.Class<?> type) throws ELException
ELException
protected static final java.lang.Number coerceToNumber(java.lang.String val, java.lang.Class<?> type) throws ELException
ELException
public static final java.lang.String coerceToString(java.lang.Object obj)
obj
- the object to convertprotected static final java.lang.Object coerceToTypeForSetValue(java.lang.Object obj, java.lang.Class<?> type) throws ELException
ELException
public static final java.lang.Object coerceToType(java.lang.Object obj, java.lang.Class<?> type) throws ELException
ELException
public static final boolean isBigDecimalOp(java.lang.Object obj0, java.lang.Object obj1)
public static final boolean isBigIntegerOp(java.lang.Object obj0, java.lang.Object obj1)
public static final boolean isDoubleOp(java.lang.Object obj0, java.lang.Object obj1)
public static final boolean isLongOp(java.lang.Object obj0, java.lang.Object obj1)
public static final boolean isStringFloat(java.lang.String str)
public static final boolean isDateTimeType(java.lang.Class<?> type)
public static final java.util.Date coerceToDateTime(java.lang.Object obj, java.lang.Class type) throws ELException
obj
- the object to be converted; must be an instance of java.util.Date or
a number which represents the millisecond since "the epoch" base time, namely January 1, 1970, 00:00:00 GMT.type
- the class type which shall be a kind of java.util.Date; e.g. java.sql.Date, java.sql.Time, java.sql.TimestampELException
Copyright © 2005-2011 Potix Corporation. All Rights Reserved.