|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.util.lang.Objects
public final class Objects
Object utilities.
Nested Class Summary | |
---|---|
static interface |
Objects.IObjectSizeOfStrategy
Interface that enables users to plugin the way object sizes are calculated with Wicket. |
static class |
Objects.SerializingObjectSizeOfStrategy
Objects.IObjectSizeOfStrategy that works by serializing the object to an instance of
ByteCountingOutputStream , which records the number of bytes written to it. |
Method Summary | ||
---|---|---|
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 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 Object |
byteArrayToObject(byte[] data)
De-serializes an object from a byte array. |
|
static Object |
cloneModel(Object object)
Makes a deep clone of an object by serializing and deserializing it. |
|
static Object |
cloneObject(Object object)
Makes a deep clone of an object by serializing and deserializing it. |
|
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 double |
doubleValue(Object value)
Evaluates the given object as a double-precision floating-point number. |
|
static boolean |
equal(Object a,
Object b)
Returns true if a and b are equal. |
|
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 int |
hashCode(Object... obj)
returns hashcode of the objects by calling obj.hashcode(). |
|
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 long |
longValue(Object value)
Evaluates the given object as a long integer. |
|
static Object |
newInstance(String className)
Creates a new instance using the current application's class resolver. |
|
static Number |
newInteger(int type,
long value)
Returns a new Number object of an appropriate type to hold the given integer value. |
|
static byte[] |
objectToByteArray(Object object)
Serializes an object into a byte array. |
|
static
|
resolveClass(String className)
|
|
static void |
setObjectSizeOfStrategy(Objects.IObjectSizeOfStrategy objectSizeOfStrategy)
Sets the strategy for determining the sizes of objects. |
|
static void |
setObjectStreamFactory(IObjectStreamFactory objectStreamFactory)
Configure this utility class to use the provided IObjectStreamFactory instance. |
|
static long |
sizeof(Object object)
Computes the size of an object. |
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static BigDecimal bigDecValue(Object value) throws NumberFormatException
value
- an object to interpret as a BigDecimal
NumberFormatException
- if the given object can't be understood as a BigDecimalpublic static BigInteger bigIntValue(Object value) throws NumberFormatException
value
- an object to interpret as a BigInteger
NumberFormatException
- if the given object can't be understood as a BigIntegerpublic static boolean booleanValue(Object value)
value
- an object to interpret as a boolean
public static Object byteArrayToObject(byte[] data)
data
- The serialized object
public static Object cloneModel(Object object)
object
- The object to clone
public static Object cloneObject(Object object)
object
- The object to clone
cloneModel(Object)
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 Object convertValue(Object value, Class<?> toType)
value
- an object to be converted to the given typetoType
- class type to be converted to
public static double doubleValue(Object value) throws NumberFormatException
value
- an object to interpret as a double
NumberFormatException
- if the given object can't be understood as a doublepublic static boolean equal(Object a, Object b)
a
- Object ab
- Object b
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 value)
value
- an object that needs to be interpreted as a number
public static int getNumericType(Object v1, Object v2)
v1
- one argument to a numeric operatorv2
- the other argument
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 boolean isEqual(Object object1, Object object2)
equals()
sense.
object1
- First object to compareobject2
- Second object to compare
public static long longValue(Object value) throws NumberFormatException
value
- an object to interpret as a long integer
NumberFormatException
- if the given object can't be understood as a long integerpublic static Object newInstance(String className)
className
- The full class name
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 byte[] objectToByteArray(Object object)
object
- The object
public static void setObjectSizeOfStrategy(Objects.IObjectSizeOfStrategy objectSizeOfStrategy)
objectSizeOfStrategy
- the strategy. Pass null to reset to the default.public static void setObjectStreamFactory(IObjectStreamFactory objectStreamFactory)
IObjectStreamFactory
instance.
objectStreamFactory
- The factory instance to use. If you pass in null, the
default
will be set (again). Pass null to reset
to the default.public static long sizeof(Object object)
object
- Object to compute size of
public static String stringValue(Object value)
value
- an object to interpret as a String
public static int hashCode(Object... obj)
obj
-
public static String stringValue(Object value, boolean trim)
value
- an object to interpret as a Stringtrim
- whether to trim the string
public static <T> Class<T> resolveClass(String className) throws ClassNotFoundException
T
- class typeclassName
- Class to resolve
ClassNotFoundException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |