ognl
public abstract class OgnlOps extends java.lang.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 java.lang.Object |
add(java.lang.Object v1,
java.lang.Object v2) |
static java.math.BigDecimal |
bigDecValue(java.lang.Object value)
Evaluates the given object as a BigDecimal.
|
static java.math.BigInteger |
bigIntValue(java.lang.Object value)
Evaluates the given object as a BigInteger.
|
static java.lang.Object |
binaryAnd(java.lang.Object v1,
java.lang.Object v2) |
static java.lang.Object |
binaryOr(java.lang.Object v1,
java.lang.Object v2) |
static java.lang.Object |
binaryXor(java.lang.Object v1,
java.lang.Object v2) |
static java.lang.Object |
bitNegate(java.lang.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(java.lang.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 java.lang.RuntimeException |
castToRuntime(java.lang.Throwable t)
Utility method that converts incoming exceptions to
RuntimeException
instances - or casts them if they already are. |
static int |
compareWithConversion(java.lang.Object v1,
java.lang.Object v2)
Compares two objects for equality, even if it has to convert one of them to the other type.
|
static java.lang.Object |
convertValue(boolean value,
java.lang.Class toType) |
static java.lang.Object |
convertValue(boolean value,
java.lang.Class toType,
boolean preventNull) |
static java.lang.Object |
convertValue(byte value,
java.lang.Class toType) |
static java.lang.Object |
convertValue(byte value,
java.lang.Class toType,
boolean preventNull) |
static java.lang.Object |
convertValue(char value,
java.lang.Class toType) |
static java.lang.Object |
convertValue(char value,
java.lang.Class toType,
boolean preventNull) |
static java.lang.Object |
convertValue(double value,
java.lang.Class toType) |
static java.lang.Object |
convertValue(double value,
java.lang.Class toType,
boolean preventNull) |
static java.lang.Object |
convertValue(float value,
java.lang.Class toType) |
static java.lang.Object |
convertValue(float value,
java.lang.Class toType,
boolean preventNull) |
static java.lang.Object |
convertValue(int value,
java.lang.Class toType) |
static java.lang.Object |
convertValue(int value,
java.lang.Class toType,
boolean preventNull) |
static java.lang.Object |
convertValue(long value,
java.lang.Class toType) |
static java.lang.Object |
convertValue(long value,
java.lang.Class toType,
boolean preventNull) |
static java.lang.Object |
convertValue(java.lang.Object value,
java.lang.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 java.lang.Object |
convertValue(java.lang.Object value,
java.lang.Class toType,
boolean preventNulls) |
static java.lang.Object |
divide(java.lang.Object v1,
java.lang.Object v2) |
static double |
doubleValue(java.lang.Object value)
Evaluates the given object as a double-precision floating-point number.
|
static boolean |
equal(java.lang.Object v1,
java.lang.Object v2) |
static java.lang.String |
getEscapedChar(char ch) |
static java.lang.String |
getEscapeString(java.lang.String value) |
static int |
getIntValue(java.lang.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(java.lang.Object value)
Returns a constant from the NumericTypes interface that represents the numeric type of the
given object.
|
static int |
getNumericType(java.lang.Object v1,
java.lang.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(java.lang.Object v1,
java.lang.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(java.lang.Object v1,
java.lang.Object v2) |
static boolean |
in(java.lang.Object v1,
java.lang.Object v2) |
static boolean |
isEqual(java.lang.Object object1,
java.lang.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(java.lang.Object v1,
java.lang.Object v2) |
static long |
longValue(java.lang.Object value)
Evaluates the given object as a long integer.
|
static java.lang.Object |
multiply(java.lang.Object v1,
java.lang.Object v2) |
static java.lang.Object |
negate(java.lang.Object value) |
static java.lang.Number |
newInteger(int type,
long value)
Returns a new Number object of an appropriate type to hold the given integer value.
|
static java.lang.Number |
newReal(int type,
double value)
Returns a new Number object of an appropriate type to hold the given real value.
|
static java.lang.Object |
remainder(java.lang.Object v1,
java.lang.Object v2) |
static java.lang.Object |
returnValue(java.lang.Object ignore,
java.lang.Object returnValue) |
static java.lang.Object |
shiftLeft(java.lang.Object v1,
java.lang.Object v2) |
static java.lang.Object |
shiftRight(java.lang.Object v1,
java.lang.Object v2) |
static java.lang.String |
stringValue(java.lang.Object value)
Evaluates the given object as a String.
|
static java.lang.String |
stringValue(java.lang.Object value,
boolean trim)
Evaluates the given object as a String and trims it if the trim flag is true.
|
static java.lang.Object |
subtract(java.lang.Object v1,
java.lang.Object v2) |
static java.lang.Object |
toArray(boolean value,
java.lang.Class toType) |
static java.lang.Object |
toArray(boolean value,
java.lang.Class toType,
boolean preventNull) |
static java.lang.Object |
toArray(byte value,
java.lang.Class toType) |
static java.lang.Object |
toArray(byte value,
java.lang.Class toType,
boolean preventNull) |
static java.lang.Object |
toArray(char value,
java.lang.Class toType) |
static java.lang.Object |
toArray(char value,
java.lang.Class toType,
boolean preventNull) |
static java.lang.Object |
toArray(double value,
java.lang.Class toType) |
static java.lang.Object |
toArray(double value,
java.lang.Class toType,
boolean preventNull) |
static java.lang.Object |
toArray(float value,
java.lang.Class toType) |
static java.lang.Object |
toArray(float value,
java.lang.Class toType,
boolean preventNull) |
static java.lang.Object |
toArray(int value,
java.lang.Class toType) |
static java.lang.Object |
toArray(int value,
java.lang.Class toType,
boolean preventNull) |
static java.lang.Object |
toArray(long value,
java.lang.Class toType) |
static java.lang.Object |
toArray(long value,
java.lang.Class toType,
boolean preventNull) |
static java.lang.Object |
toArray(java.lang.Object value,
java.lang.Class toType) |
static java.lang.Object |
toArray(java.lang.Object value,
java.lang.Class toType,
boolean preventNulls) |
static java.lang.Object |
unsignedShiftRight(java.lang.Object v1,
java.lang.Object v2) |
public static int compareWithConversion(java.lang.Object v1, java.lang.Object v2)
v1
- First value to comparev2
- second value to comparejava.lang.IllegalArgumentException
- if the objects are both non-numeric yet of incompatible types or do not implement
Comparable.public static boolean isEqual(java.lang.Object object1, java.lang.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(java.lang.Object value)
value
- an object to interpret as a booleanpublic static long longValue(java.lang.Object value) throws java.lang.NumberFormatException
value
- an object to interpret as a long integerjava.lang.NumberFormatException
- if the given object can't be understood as a long integerpublic static double doubleValue(java.lang.Object value) throws java.lang.NumberFormatException
value
- an object to interpret as a doublejava.lang.NumberFormatException
- if the given object can't be understood as a doublepublic static java.math.BigInteger bigIntValue(java.lang.Object value) throws java.lang.NumberFormatException
value
- an object to interpret as a BigIntegerjava.lang.NumberFormatException
- if the given object can't be understood as a BigIntegerpublic static java.math.BigDecimal bigDecValue(java.lang.Object value) throws java.lang.NumberFormatException
value
- an object to interpret as a BigDecimaljava.lang.NumberFormatException
- if the given object can't be understood as a BigDecimalpublic static java.lang.String stringValue(java.lang.Object value, boolean trim)
value
- an object to interpret as a Stringpublic static java.lang.String stringValue(java.lang.Object value)
value
- an object to interpret as a Stringpublic static int getNumericType(java.lang.Object value)
value
- an object that needs to be interpreted as a numberpublic static java.lang.Object toArray(char value, java.lang.Class toType)
public static java.lang.Object toArray(byte value, java.lang.Class toType)
public static java.lang.Object toArray(int value, java.lang.Class toType)
public static java.lang.Object toArray(long value, java.lang.Class toType)
public static java.lang.Object toArray(float value, java.lang.Class toType)
public static java.lang.Object toArray(double value, java.lang.Class toType)
public static java.lang.Object toArray(boolean value, java.lang.Class toType)
public static java.lang.Object convertValue(char value, java.lang.Class toType)
public static java.lang.Object convertValue(byte value, java.lang.Class toType)
public static java.lang.Object convertValue(int value, java.lang.Class toType)
public static java.lang.Object convertValue(long value, java.lang.Class toType)
public static java.lang.Object convertValue(float value, java.lang.Class toType)
public static java.lang.Object convertValue(double value, java.lang.Class toType)
public static java.lang.Object convertValue(boolean value, java.lang.Class toType)
public static java.lang.Object convertValue(char value, java.lang.Class toType, boolean preventNull)
public static java.lang.Object convertValue(byte value, java.lang.Class toType, boolean preventNull)
public static java.lang.Object convertValue(int value, java.lang.Class toType, boolean preventNull)
public static java.lang.Object convertValue(long value, java.lang.Class toType, boolean preventNull)
public static java.lang.Object convertValue(float value, java.lang.Class toType, boolean preventNull)
public static java.lang.Object convertValue(double value, java.lang.Class toType, boolean preventNull)
public static java.lang.Object convertValue(boolean value, java.lang.Class toType, boolean preventNull)
public static java.lang.Object toArray(char value, java.lang.Class toType, boolean preventNull)
public static java.lang.Object toArray(byte value, java.lang.Class toType, boolean preventNull)
public static java.lang.Object toArray(int value, java.lang.Class toType, boolean preventNull)
public static java.lang.Object toArray(long value, java.lang.Class toType, boolean preventNull)
public static java.lang.Object toArray(float value, java.lang.Class toType, boolean preventNull)
public static java.lang.Object toArray(double value, java.lang.Class toType, boolean preventNull)
public static java.lang.Object toArray(boolean value, java.lang.Class toType, boolean preventNull)
public static java.lang.Object convertValue(java.lang.Object value, java.lang.Class toType)
value
- an object to be converted to the given typetoType
- class type to be converted topublic static java.lang.Object toArray(java.lang.Object value, java.lang.Class toType)
public static java.lang.Object toArray(java.lang.Object value, java.lang.Class toType, boolean preventNulls)
public static java.lang.Object convertValue(java.lang.Object value, java.lang.Class toType, boolean preventNulls)
public static int getIntValue(java.lang.Object value)
Number
instances have their intValue() methods invoked.value
- The object to get the value of.public static int getNumericType(java.lang.Object v1, java.lang.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(java.lang.Object v1, java.lang.Object v2, boolean canBeNonNumeric)
v1
- one argument to an operatorv2
- the other argumentcanBeNonNumeric
- whether the operator can be interpreted as non-numericpublic static java.lang.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 java.lang.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 java.lang.Object binaryOr(java.lang.Object v1, java.lang.Object v2)
public static java.lang.Object binaryXor(java.lang.Object v1, java.lang.Object v2)
public static java.lang.Object binaryAnd(java.lang.Object v1, java.lang.Object v2)
public static boolean equal(java.lang.Object v1, java.lang.Object v2)
public static boolean less(java.lang.Object v1, java.lang.Object v2)
public static boolean greater(java.lang.Object v1, java.lang.Object v2)
public static boolean in(java.lang.Object v1, java.lang.Object v2) throws OgnlException
OgnlException
public static java.lang.Object shiftLeft(java.lang.Object v1, java.lang.Object v2)
public static java.lang.Object shiftRight(java.lang.Object v1, java.lang.Object v2)
public static java.lang.Object unsignedShiftRight(java.lang.Object v1, java.lang.Object v2)
public static java.lang.Object add(java.lang.Object v1, java.lang.Object v2)
public static java.lang.Object subtract(java.lang.Object v1, java.lang.Object v2)
public static java.lang.Object multiply(java.lang.Object v1, java.lang.Object v2)
public static java.lang.Object divide(java.lang.Object v1, java.lang.Object v2)
public static java.lang.Object remainder(java.lang.Object v1, java.lang.Object v2)
public static java.lang.Object negate(java.lang.Object value)
public static java.lang.Object bitNegate(java.lang.Object value)
public static java.lang.String getEscapeString(java.lang.String value)
public static java.lang.String getEscapedChar(char ch)
public static java.lang.Object returnValue(java.lang.Object ignore, java.lang.Object returnValue)
public static java.lang.RuntimeException castToRuntime(java.lang.Throwable t)
RuntimeException
instances - or casts them if they already are.t
- The exception to cast.RuntimeException
.