org.jfree.util
Class ObjectUtilities

java.lang.Object
  extended by org.jfree.util.ObjectUtilities

public final class ObjectUtilities
extends java.lang.Object

A collection of useful static utility methods.


Method Summary
static java.lang.Object clone(java.lang.Object object)
          Returns a clone of the specified object, if it can be cloned, otherwise throws a CloneNotSupportedException.
static java.util.Collection deepClone(java.util.Collection collection)
          Returns a new collection containing clones of all the items in the specified collection.
static boolean equal(java.lang.Object o1, java.lang.Object o2)
          Returns true if the two objects are equal OR both null.
static java.lang.ClassLoader getClassLoader(java.lang.Class c)
          Returns the classloader, which was responsible for loading the given class.
static int hashCode(java.lang.Object object)
          Returns a hash code for an object, or zero if the object is null.
static java.lang.Object loadAndInstantiate(java.lang.String className, java.lang.Class source)
          Tries to create a new instance of the given class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

equal

public static boolean equal(java.lang.Object o1,
                            java.lang.Object o2)
Returns true if the two objects are equal OR both null.

Parameters:
o1 - object 1 (null permitted).
o2 - object 2 (null permitted).
Returns:
true or false.

hashCode

public static int hashCode(java.lang.Object object)
Returns a hash code for an object, or zero if the object is null.

Parameters:
object - the object (null permitted).
Returns:
The object's hash code (or zero if the object is null).

clone

public static java.lang.Object clone(java.lang.Object object)
                              throws java.lang.CloneNotSupportedException
Returns a clone of the specified object, if it can be cloned, otherwise throws a CloneNotSupportedException.

Parameters:
object - the object to clone (null not permitted).
Returns:
A clone of the specified object.
Throws:
java.lang.CloneNotSupportedException - if the object cannot be cloned.

deepClone

public static java.util.Collection deepClone(java.util.Collection collection)
                                      throws java.lang.CloneNotSupportedException
Returns a new collection containing clones of all the items in the specified collection.

Parameters:
collection - the collection (null not permitted).
Returns:
A new collection containing clones of all the items in the specified collection.
Throws:
java.lang.CloneNotSupportedException - if any of the items in the collection cannot be cloned.

getClassLoader

public static java.lang.ClassLoader getClassLoader(java.lang.Class c)
Returns the classloader, which was responsible for loading the given class.

Parameters:
c - the classloader, either an application class loader or the boot loader.
Returns:
the classloader, never null.

loadAndInstantiate

public static java.lang.Object loadAndInstantiate(java.lang.String className,
                                                  java.lang.Class source)
Tries to create a new instance of the given class. This is a short cut for the common bean instantiation code.

Parameters:
className - the class name as String, never null.
source - the source class, from where to get the classloader.
Returns:
the instantiated object or null, if an error occured.