public abstract class OgnlOps extends Object implements NumericTypes
BIGDEC, BIGINT, BOOL, BYTE, CHAR, DOUBLE, FLOAT, INT, LONG, MIN_REAL_TYPE, NONNUMERIC, SHORT
Constructor and Description |
---|
OgnlOps() |
Modifier and Type | Method and Description |
---|---|
static Object |
add(Object v1,
Object v2) |
static BigDecimal |
bigDecValue(Object value)
Evaluates the given object as a BigDecimal.
|
static BigInteger |
bigIntValue(Object value)
Evaluates the given object as a BigInteger.
|
static Object |
binaryAnd(Object v1,
Object v2) |
static Object |
binaryOr(Object v1,
Object v2) |
static Object |
binaryXor(Object v1,
Object v2) |
static Object |
bitNegate(Object value) |
static boolean |
booleanValue(Object value)
Evaluates the given object as a boolean: if it is a Boolean object, it's easy; if
it's a Number or a Character, returns true for non-zero objects; and otherwise
returns true for non-null objects.
|
static int |
compareWithConversion(Object v1,
Object v2)
Compares two objects for equality, even if it has to convert
one of them to the other type.
|
static Object |
convertValue(Object value,
Class toType)
Returns the value converted numerically to the given class type
This method also detects when arrays are being converted and
converts the components of one array to the type of the other.
|
static Object |
divide(Object v1,
Object v2) |
static double |
doubleValue(Object value)
Evaluates the given object as a double-precision floating-point number.
|
static boolean |
equal(Object v1,
Object v2) |
static int |
getNumericType(int t1,
int t2,
boolean canBeNonNumeric)
Returns the constant from the NumericTypes interface that best expresses the type
of an operation, which can be either numeric or not, on the two given types.
|
static int |
getNumericType(Object value)
Returns a constant from the NumericTypes interface that represents the numeric
type of the given object.
|
static int |
getNumericType(Object v1,
Object v2)
Returns the constant from the NumericTypes interface that best expresses the type
of a numeric operation on the two given objects.
|
static int |
getNumericType(Object v1,
Object v2,
boolean canBeNonNumeric)
Returns the constant from the NumericTypes interface that best expresses the type
of an operation, which can be either numeric or not, on the two given objects.
|
static boolean |
greater(Object v1,
Object v2) |
static boolean |
in(Object v1,
Object v2) |
static boolean |
isEqual(Object object1,
Object object2)
Returns true if object1 is equal to object2 in either the
sense that they are the same object or, if both are non-null
if they are equal in the
equals() sense. |
static boolean |
less(Object v1,
Object v2) |
static long |
longValue(Object value)
Evaluates the given object as a long integer.
|
static Object |
multiply(Object v1,
Object v2) |
static Object |
negate(Object value) |
static Number |
newInteger(int type,
long value)
Returns a new Number object of an appropriate type to hold the given integer
value.
|
static Number |
newReal(int type,
double value)
Returns a new Number object of an appropriate type to hold the given real value.
|
static Object |
remainder(Object v1,
Object v2) |
static Object |
shiftLeft(Object v1,
Object v2) |
static Object |
shiftRight(Object v1,
Object v2) |
static String |
stringValue(Object value)
Evaluates the given object as a String.
|
static String |
stringValue(Object value,
boolean trim)
Evaluates the given object as a String and trims it if the trim flag is true.
|
static Object |
subtract(Object v1,
Object v2) |
static Object |
unsignedShiftRight(Object v1,
Object v2) |
public static int compareWithConversion(Object v1, Object v2)
v1
- First value to comparev2
- second value to compareIllegalArgumentException
- if the objects are both non-numeric
yet of incompatible types or do not implement Comparable.public static boolean isEqual(Object object1, Object object2)
equals()
sense.v1
- First object to comparev2
- Second object to comparepublic static boolean booleanValue(Object value)
value
- an object to interpret as a booleanpublic static long longValue(Object value) throws NumberFormatException
value
- an object to interpret as a long integerNumberFormatException
- if the given object can't be understood as a long integerpublic static double doubleValue(Object value) throws NumberFormatException
value
- an object to interpret as a doubleNumberFormatException
- if the given object can't be understood as a doublepublic static BigInteger bigIntValue(Object value) throws NumberFormatException
value
- an object to interpret as a BigIntegerNumberFormatException
- if the given object can't be understood as a BigIntegerpublic static BigDecimal bigDecValue(Object value) throws NumberFormatException
value
- an object to interpret as a BigDecimalNumberFormatException
- if the given object can't be understood as a BigDecimalpublic static String stringValue(Object value, boolean trim)
value
- an object to interpret as a Stringpublic static String stringValue(Object value)
value
- an object to interpret as a Stringpublic static int getNumericType(Object value)
value
- an object that needs to be interpreted as a numberpublic static Object convertValue(Object value, Class toType)
value
- an object to be converted to the given typetoType
- class type to be converted topublic static int getNumericType(Object v1, Object v2)
v1
- one argument to a numeric operatorv2
- the other argumentpublic static int getNumericType(int t1, int t2, boolean canBeNonNumeric)
t1
- type of one argument to an operatort2
- type of the other argumentcanBeNonNumeric
- whether the operator can be interpreted as non-numericpublic static int getNumericType(Object v1, Object v2, boolean canBeNonNumeric)
v1
- one argument to an operatorv2
- the other argumentcanBeNonNumeric
- whether the operator can be interpreted as non-numericpublic static Number newInteger(int type, long value)
type
- the nominal numeric type of the result, a constant from the NumericTypes interfacevalue
- the integer value to convert to a Number objectpublic static Number newReal(int type, double value)
type
- the nominal numeric type of the result, a constant from the NumericTypes interfacevalue
- the real value to convert to a Number objectpublic static boolean in(Object v1, Object v2) throws OgnlException
OgnlException