|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.ognl.OgnlOps
public abstract class OgnlOps
This is an abstract class with static methods that define the operations of OGNL.
Field Summary |
---|
Fields inherited from interface org.apache.commons.ognl.NumericTypes |
---|
BIGDEC, BIGINT, BOOL, BYTE, CHAR, DOUBLE, FLOAT, INT, LONG, MIN_REAL_TYPE, NONNUMERIC, SHORT |
Constructor Summary | |
---|---|
OgnlOps()
|
Method Summary | ||
---|---|---|
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
|
convertValue(boolean value,
Class<T> toType)
|
|
static
|
convertValue(boolean value,
Class<T> toType,
boolean preventNull)
|
|
static
|
convertValue(byte value,
Class<T> toType)
|
|
static
|
convertValue(byte value,
Class<T> toType,
boolean preventNull)
|
|
static
|
convertValue(char value,
Class<T> toType)
|
|
static
|
convertValue(char value,
Class<T> toType,
boolean preventNull)
|
|
static
|
convertValue(double value,
Class<T> toType)
|
|
static
|
convertValue(double value,
Class<T> toType,
boolean preventNull)
|
|
static
|
convertValue(float value,
Class<T> toType)
|
|
static
|
convertValue(float value,
Class<T> toType,
boolean preventNull)
|
|
static
|
convertValue(int value,
Class<T> toType)
|
|
static
|
convertValue(int value,
Class<T> toType,
boolean preventNull)
|
|
static
|
convertValue(long value,
Class<T> toType)
|
|
static
|
convertValue(long value,
Class<T> 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
|
convertValue(Object value,
Class<T> 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)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public OgnlOps()
Method Detail |
---|
public static int compareWithConversion(Object v1, Object v2)
v1
- First value to comparev2
- second value to compare
IllegalArgumentException
- 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 compare
public 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 boolean
public static long longValue(Object value)
value
- an object to interpret as a long integer
NumberFormatException
- if the given object can't be understood as a long integerpublic static double doubleValue(Object value)
value
- an object to interpret as a double
NumberFormatException
- if the given object can't be understood as a doublepublic static BigInteger bigIntValue(Object value)
value
- an object to interpret as a BigInteger
NumberFormatException
- if the given object can't be understood as a BigIntegerpublic static BigDecimal bigDecValue(Object value)
value
- an object to interpret as a BigDecimal
NumberFormatException
- 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 Stringtrim
- if true trims the result
public static String stringValue(Object value)
value
- an object to interpret as a String
public static int getNumericType(Object value)
value
- an object that needs to be interpreted as a number
public static Object toArray(char value, Class<?> toType) throws OgnlException
OgnlException
public static Object toArray(byte value, Class<?> toType) throws OgnlException
OgnlException
public static Object toArray(int value, Class<?> toType) throws OgnlException
OgnlException
public static Object toArray(long value, Class<?> toType) throws OgnlException
OgnlException
public static Object toArray(float value, Class<?> toType) throws OgnlException
OgnlException
public static Object toArray(double value, Class<?> toType) throws OgnlException
OgnlException
public static Object toArray(boolean value, Class<?> toType) throws OgnlException
OgnlException
public static <T> Object convertValue(char value, Class<T> toType) throws OgnlException
OgnlException
public static <T> Object convertValue(byte value, Class<T> toType) throws OgnlException
OgnlException
public static <T> Object convertValue(int value, Class<T> toType) throws OgnlException
OgnlException
public static <T> Object convertValue(long value, Class<T> toType) throws OgnlException
OgnlException
public static <T> Object convertValue(float value, Class<T> toType) throws OgnlException
OgnlException
public static <T> Object convertValue(double value, Class<T> toType) throws OgnlException
OgnlException
public static <T> Object convertValue(boolean value, Class<T> toType) throws OgnlException
OgnlException
public static <T> Object convertValue(char value, Class<T> toType, boolean preventNull) throws OgnlException
OgnlException
public static <T> Object convertValue(byte value, Class<T> toType, boolean preventNull) throws OgnlException
OgnlException
public static <T> Object convertValue(int value, Class<T> toType, boolean preventNull) throws OgnlException
OgnlException
public static <T> Object convertValue(long value, Class<T> toType, boolean preventNull) throws OgnlException
OgnlException
public static <T> Object convertValue(float value, Class<T> toType, boolean preventNull) throws OgnlException
OgnlException
public static <T> Object convertValue(double value, Class<T> toType, boolean preventNull) throws OgnlException
OgnlException
public static <T> Object convertValue(boolean value, Class<T> toType, boolean preventNull) throws OgnlException
OgnlException
public static Object toArray(char value, Class<?> toType, boolean preventNull) throws OgnlException
OgnlException
public static Object toArray(byte value, Class<?> toType, boolean preventNull) throws OgnlException
OgnlException
public static Object toArray(int value, Class<?> toType, boolean preventNull) throws OgnlException
OgnlException
public static Object toArray(long value, Class<?> toType, boolean preventNull) throws OgnlException
OgnlException
public static Object toArray(float value, Class<?> toType, boolean preventNull) throws OgnlException
OgnlException
public static Object toArray(double value, Class<?> toType, boolean preventNull) throws OgnlException
OgnlException
public static Object toArray(boolean value, Class<?> toType, boolean preventNull) throws OgnlException
OgnlException
public static Object convertValue(Object value, Class<?> toType)
value
- an object to be converted to the given typetoType
- class type to be converted to
public static Object toArray(Object value, Class<?> toType) throws OgnlException
OgnlException
public static Object toArray(Object value, Class<?> toType, boolean preventNulls) throws OgnlException
OgnlException
public static <T> Object convertValue(Object value, Class<T> toType, boolean preventNulls)
public 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 argument
public 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-numeric
public 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-numeric
public 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 object
public 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 object
public static Object binaryOr(Object v1, Object v2)
public static Object binaryXor(Object v1, Object v2)
public static Object binaryAnd(Object v1, Object v2)
public static boolean equal(Object v1, Object v2)
public static boolean less(Object v1, Object v2)
public static boolean greater(Object v1, Object v2)
public static boolean in(Object v1, Object v2) throws OgnlException
OgnlException
public static Object shiftLeft(Object v1, Object v2)
public static Object shiftRight(Object v1, Object v2)
public static Object unsignedShiftRight(Object v1, Object v2)
public static Object add(Object v1, Object v2)
public static Object subtract(Object v1, Object v2)
public static Object multiply(Object v1, Object v2)
public static Object divide(Object v1, Object v2)
public static Object remainder(Object v1, Object v2)
public static Object negate(Object value)
public static Object bitNegate(Object value)
public static String getEscapeString(String value)
public static String getEscapedChar(char ch)
public static Object returnValue(Object ignore, Object returnValue)
public static RuntimeException castToRuntime(Throwable t)
RuntimeException
instances - or casts them if they
already are.
t
- The exception to cast.
RuntimeException
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |