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(boolean value) |
static boolean |
booleanValue(double value) |
static boolean |
booleanValue(float value) |
static boolean |
booleanValue(int value) |
static boolean |
booleanValue(long 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 RuntimeException |
castToRuntime(Throwable t)
Utility method that converts incoming exceptions to
RuntimeException
instances - or casts them if they already are. |
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(boolean value,
Class toType) |
static Object |
convertValue(boolean value,
Class toType,
boolean preventNull) |
static Object |
convertValue(byte value,
Class toType) |
static Object |
convertValue(byte value,
Class toType,
boolean preventNull) |
static Object |
convertValue(char value,
Class toType) |
static Object |
convertValue(char value,
Class toType,
boolean preventNull) |
static Object |
convertValue(double value,
Class toType) |
static Object |
convertValue(double value,
Class toType,
boolean preventNull) |
static Object |
convertValue(float value,
Class toType) |
static Object |
convertValue(float value,
Class toType,
boolean preventNull) |
static Object |
convertValue(int value,
Class toType) |
static Object |
convertValue(int value,
Class toType,
boolean preventNull) |
static Object |
convertValue(long value,
Class toType) |
static Object |
convertValue(long value,
Class toType,
boolean preventNull) |
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 |
convertValue(Object value,
Class toType,
boolean preventNulls) |
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 String |
getEscapedChar(char ch) |
static String |
getEscapeString(String value) |
static int |
getIntValue(Object value)
Converts the specified value to a primitive integer value.
|
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 |
returnValue(Object ignore,
Object returnValue) |
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 |
toArray(boolean value,
Class toType) |
static Object |
toArray(boolean value,
Class toType,
boolean preventNull) |
static Object |
toArray(byte value,
Class toType) |
static Object |
toArray(byte value,
Class toType,
boolean preventNull) |
static Object |
toArray(char value,
Class toType) |
static Object |
toArray(char value,
Class toType,
boolean preventNull) |
static Object |
toArray(double value,
Class toType) |
static Object |
toArray(double value,
Class toType,
boolean preventNull) |
static Object |
toArray(float value,
Class toType) |
static Object |
toArray(float value,
Class toType,
boolean preventNull) |
static Object |
toArray(int value,
Class toType) |
static Object |
toArray(int value,
Class toType,
boolean preventNull) |
static Object |
toArray(long value,
Class toType) |
static Object |
toArray(long value,
Class toType,
boolean preventNull) |
static Object |
toArray(Object value,
Class toType) |
static Object |
toArray(Object value,
Class toType,
boolean preventNulls) |
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.object1
- First object to compareobject2
- Second object to comparepublic static boolean booleanValue(boolean value)
public static boolean booleanValue(int value)
public static boolean booleanValue(float value)
public static boolean booleanValue(long value)
public static boolean booleanValue(double value)
public 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 getIntValue(Object value)
Number
instances have their intValue() methods invoked.value
- The object to get the value of.public 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
public static String getEscapedChar(char ch)
public static RuntimeException castToRuntime(Throwable t)
RuntimeException
instances - or casts them if they already are.t
- The exception to cast.RuntimeException
.Copyright © 1997–2021 The Apache Software Foundation. All rights reserved.