audiojury.domain
Class ObjectCloner

java.lang.Object
  |
  +--audiojury.domain.ObjectCloner

public class ObjectCloner
extends java.lang.Object

Makes deep copies of objects. Use this class to make a deep copies of complex objects.


Method Summary
static java.lang.Object deepCopy(java.lang.Object oldObj)
          Static method for creating deep copies of objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

deepCopy

public static java.lang.Object deepCopy(java.lang.Object oldObj)
                                 throws java.lang.Exception
Static method for creating deep copies of objects.

Simply give the object you want to copy as a parameter and it will deep copied. That is the all complex sub objects of the object (parameters and such) will also be recursively deep copied. This will make the copy unique and will cure any dangling references.

This is done by serializing and then deserializing the object. This will have the side effect that any transient sub objects from the origional object will be lost in the copy.

Parameters:
oldObj - the object that will be copied.
Returns:
the deep copy of the object.
Throws:
java.lang.Exception - if there was an unhandled exception while performing the operation.