org.springframework.util
Class ObjectUtils

java.lang.Object
  extended by org.springframework.util.ObjectUtils

public abstract class ObjectUtils
extends Object

Miscellaneous object utility methods. Mainly for internal use within the framework; consider Jakarta's Commons Lang for a more comprehensive suite of object utilities.

Since:
19.03.2004
Author:
Juergen Hoeller, Keith Donald, Rod Johnson
See Also:
org.apache.commons.lang.ObjectUtils

Constructor Summary
ObjectUtils()
           
 
Method Summary
static Object[] addObjectToArray(Object[] array, Object obj)
          Append the given Object to the given array, returning a new array consisting of the input array contents plus the given Object.
static String getIdentityHexString(Object obj)
          Return a hex string form of an object's identity hash code.
static boolean isCheckedException(Throwable ex)
          Return whether the given throwable is a checked exception: that is, neither a RuntimeException nor an Error.
static boolean isCompatibleWithThrowsClause(Throwable ex, Class[] declaredExceptions)
          Check whether the given exception is compatible with the exceptions declared in a throws clause.
static boolean isEmpty(Object[] array)
          Return whether the given array is empty: that is, null or of zero length.
static boolean nullSafeEquals(Object o1, Object o2)
          Determine if the given objects are equal, returning true if both are null or false if only one is null.
static Object[] toObjectArray(Object primitiveArray)
          Convert a primitive array to an object array of primitive wrapper objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectUtils

public ObjectUtils()
Method Detail

nullSafeEquals

public static boolean nullSafeEquals(Object o1,
                                     Object o2)
Determine if the given objects are equal, returning true if both are null or false if only one is null.

Parameters:
o1 - first Object to compare
o2 - second Object to compare
Returns:
whether the given objects are equal

getIdentityHexString

public static String getIdentityHexString(Object obj)
Return a hex string form of an object's identity hash code.

Parameters:
obj - the object
Returns:
the object's identity code in hex

isCheckedException

public static boolean isCheckedException(Throwable ex)
Return whether the given throwable is a checked exception: that is, neither a RuntimeException nor an Error.

Parameters:
ex - the throwable to check
Returns:
whether the throwable is a checked exception
See Also:
Exception, RuntimeException, Error

isCompatibleWithThrowsClause

public static boolean isCompatibleWithThrowsClause(Throwable ex,
                                                   Class[] declaredExceptions)
Check whether the given exception is compatible with the exceptions declared in a throws clause.

Parameters:
ex - the exception to checked
declaredExceptions - the exceptions declared in the throws clause
Returns:
whether the given exception is compatible

isEmpty

public static boolean isEmpty(Object[] array)
Return whether the given array is empty: that is, null or of zero length.

Parameters:
array - the array to check

addObjectToArray

public static Object[] addObjectToArray(Object[] array,
                                        Object obj)
Append the given Object to the given array, returning a new array consisting of the input array contents plus the given Object.

Parameters:
array - the array to append to (can be null)
obj - the Object to append
Returns:
the new array (of the same component type; never null)

toObjectArray

public static Object[] toObjectArray(Object primitiveArray)
Convert a primitive array to an object array of primitive wrapper objects.

Parameters:
primitiveArray - the primitive array
Returns:
the object array
Throws:
IllegalArgumentException - if the parameter is not a primitive array


Copyright (c) 2002-2006 The Spring Framework Project.