nl.knowledgeplaza.util
Class ObjectUtil

java.lang.Object
  extended by nl.knowledgeplaza.util.ObjectUtil

public class ObjectUtil
extends java.lang.Object

Version:
$Revision: 1.3 $

Field Summary
static java.lang.String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Constructor Summary
ObjectUtil()
           
 
Method Summary
static byte byteValue(java.lang.Object o)
           
static java.lang.Object callMethod(java.lang.Object object, java.lang.String methodName)
          Call method with no parameters
static java.lang.Object callMethod(java.lang.Object object, java.lang.String methodName, java.lang.Class[] parameterTypes, java.lang.Object[] parameterValues)
          Call a method
static int compareTo(java.lang.Comparable o1, java.lang.Comparable o2)
          Does a o1.compareTo(o2) but also checks if o1 or o2 are null.
static java.lang.Object deepClone(java.lang.Object orig)
          Returns a copy of the object
static java.lang.Object deepCloneReflection(java.lang.Object obj)
          Makes a reflection-based deep clone of 'obj'.
static java.lang.Object deepCloneSerialisation(java.lang.Object orig)
          Returns a copy of the object, or null if the object cannot be serialized.
static double doubleValue(java.lang.Object o)
           
static boolean equals(java.lang.Object o1, java.lang.Object o2)
          Does a o1.equals(o2) but also checks if o1 or o2 are null.
static double floatValue(java.lang.Object o)
           
static java.lang.reflect.Method getMethod(java.lang.Object object, java.lang.String methodName, java.lang.Class[] parameterTypes)
          Determine if object has a method
static boolean hasMethod(java.lang.Object object, java.lang.String methodName)
          Determine if object has a method
static boolean hasMethod(java.lang.Object object, java.lang.String methodName, java.lang.Class[] parameterTypes)
          Determine if object has a method
static java.lang.Object ifNull(java.lang.Object s, java.lang.Object n)
           
static int intValue(java.lang.Object o)
           
static long longValue(java.lang.Object o)
           
static short shortValue(java.lang.Object o)
           
static java.lang.Object stripProxies(java.lang.Object o)
          Strip the proxies from an object, so the actual object is returned.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCECODE_VERSION

public static final java.lang.String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values
Constructor Detail

ObjectUtil

public ObjectUtil()
Method Detail

deepClone

public static java.lang.Object deepClone(java.lang.Object orig)
Returns a copy of the object


deepCloneSerialisation

public static java.lang.Object deepCloneSerialisation(java.lang.Object orig)
Returns a copy of the object, or null if the object cannot be serialized.


deepCloneReflection

public static java.lang.Object deepCloneReflection(java.lang.Object obj)
Makes a reflection-based deep clone of 'obj'.

Parameters:
obj - input object to clone [null will cause a NullPointerException]
Returns:
obj's deep clone [never null; can be == to 'obj']
Throws:
java.lang.RuntimeException - on any failure

byteValue

public static byte byteValue(java.lang.Object o)

shortValue

public static short shortValue(java.lang.Object o)

intValue

public static int intValue(java.lang.Object o)

longValue

public static long longValue(java.lang.Object o)

doubleValue

public static double doubleValue(java.lang.Object o)

floatValue

public static double floatValue(java.lang.Object o)

ifNull

public static java.lang.Object ifNull(java.lang.Object s,
                                      java.lang.Object n)
Parameters:
s -
Returns:

getMethod

public static java.lang.reflect.Method getMethod(java.lang.Object object,
                                                 java.lang.String methodName,
                                                 java.lang.Class[] parameterTypes)
Determine if object has a method

Parameters:
object -
methodName -
parameterTypes -

hasMethod

public static boolean hasMethod(java.lang.Object object,
                                java.lang.String methodName,
                                java.lang.Class[] parameterTypes)
Determine if object has a method

Parameters:
object -
methodName -
parameterTypes -

hasMethod

public static boolean hasMethod(java.lang.Object object,
                                java.lang.String methodName)
Determine if object has a method

Parameters:
object -
methodName - TODO: caching

callMethod

public static java.lang.Object callMethod(java.lang.Object object,
                                          java.lang.String methodName,
                                          java.lang.Class[] parameterTypes,
                                          java.lang.Object[] parameterValues)
Call a method

Parameters:
object -
methodName -
parameterTypes -
parameterValues -

callMethod

public static java.lang.Object callMethod(java.lang.Object object,
                                          java.lang.String methodName)
Call method with no parameters

Parameters:
object -
methodName -
Returns:

equals

public static boolean equals(java.lang.Object o1,
                             java.lang.Object o2)
Does a o1.equals(o2) but also checks if o1 or o2 are null.

Parameters:
o1 -
o2 -
Returns:

compareTo

public static int compareTo(java.lang.Comparable o1,
                            java.lang.Comparable o2)
Does a o1.compareTo(o2) but also checks if o1 or o2 are null.

Parameters:
o1 -
o2 -
Returns:

stripProxies

public static java.lang.Object stripProxies(java.lang.Object o)
Strip the proxies from an object, so the actual object is returned. So for example if a EntityManager e is wrapped in a java.lang.reflect.Proxy p, then stripProxies(p) returns e.

Parameters:
o -
Returns:


Copyright © 2010. All Rights Reserved.