nl.knowledgeplaza.util
Class ObjectUtil

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

public class ObjectUtil
extends Object

Version:
$Revision: 1.3 $

Field Summary
static String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Constructor Summary
ObjectUtil()
           
 
Method Summary
static byte byteValue(Object o)
           
static Object callMethod(Object object, String methodName)
          Call method with no parameters
static Object callMethod(Object object, String methodName, Class[] parameterTypes, Object[] parameterValues)
          Call a method
static int compareTo(Comparable o1, Comparable o2)
          Does a o1.compareTo(o2) but also checks if o1 or o2 are null.
static Object deepClone(Object orig)
          Returns a copy of the object
static Object deepCloneReflection(Object obj)
          Makes a reflection-based deep clone of 'obj'.
static Object deepCloneSerialisation(Object orig)
          Returns a copy of the object, or null if the object cannot be serialized.
static double doubleValue(Object o)
           
static boolean equals(Object o1, Object o2)
          Does a o1.equals(o2) but also checks if o1 or o2 are null.
static double floatValue(Object o)
           
static Method getMethod(Object object, String methodName, Class[] parameterTypes)
          Determine if object has a method
static boolean hasMethod(Object object, String methodName)
          Determine if object has a method
static boolean hasMethod(Object object, String methodName, Class[] parameterTypes)
          Determine if object has a method
static Object ifNull(Object s, Object n)
           
static int intValue(Object o)
           
static long longValue(Object o)
           
static short shortValue(Object o)
           
static Object stripProxies(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 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 Object deepClone(Object orig)
Returns a copy of the object


deepCloneSerialisation

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


deepCloneReflection

public static Object deepCloneReflection(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:
RuntimeException - on any failure

byteValue

public static byte byteValue(Object o)

shortValue

public static short shortValue(Object o)

intValue

public static int intValue(Object o)

longValue

public static long longValue(Object o)

doubleValue

public static double doubleValue(Object o)

floatValue

public static double floatValue(Object o)

ifNull

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

getMethod

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

Parameters:
object -
methodName -
parameterTypes -

hasMethod

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

Parameters:
object -
methodName -
parameterTypes -

hasMethod

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

Parameters:
object -
methodName - TODO: caching

callMethod

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

Parameters:
object -
methodName -
parameterTypes -
parameterValues -

callMethod

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

Parameters:
object -
methodName -
Returns:

equals

public static boolean equals(Object o1,
                             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(Comparable o1,
                            Comparable o2)
Does a o1.compareTo(o2) but also checks if o1 or o2 are null.

Parameters:
o1 -
o2 -
Returns:

stripProxies

public static Object stripProxies(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 © 2011 KnowledgePlaza. All Rights Reserved.