ix.util
Class ObjectCopier
java.lang.Object
|
+--ix.util.ObjectCopier
- public class ObjectCopier
- extends java.lang.Object
Copies Objects, including to instances of a different class.
Method Summary |
java.lang.Object |
copy(java.lang.Object obj)
Returns a top-level copy of the object. |
java.lang.Object |
copy(java.lang.Object obj,
java.lang.Class resultClass)
Returns a top-level copy as an instance of the specified result
class. |
java.lang.Object |
deepCopy(java.lang.Object obj)
Returns a full, recursive copy of the object. |
java.lang.Object |
deepCopy(java.lang.Object obj,
java.lang.Class resultClass)
Returns a full, recursive copy as an instance of the specified
result class. |
protected FieldWalker |
ensureFieldWalker(java.lang.Class c)
Returns a FieldWalker for the class. |
boolean |
isLeaf(java.lang.Object obj)
Returns true if and only if the object does not contain fields
that should be recursively copied. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
walkerCache
protected java.util.Map walkerCache
ObjectCopier
public ObjectCopier()
copy
public java.lang.Object copy(java.lang.Object obj)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
- Returns a top-level copy of the object.
copy
public java.lang.Object copy(java.lang.Object obj,
java.lang.Class resultClass)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
- Returns a top-level copy as an instance of the specified result
class.
deepCopy
public java.lang.Object deepCopy(java.lang.Object obj)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
- Returns a full, recursive copy of the object.
deepCopy
public java.lang.Object deepCopy(java.lang.Object obj,
java.lang.Class resultClass)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
- Returns a full, recursive copy as an instance of the specified
result class. Note that this method will change the class only
at the top level and that leaf field values are put directly
into the result rather than copied.
isLeaf
public boolean isLeaf(java.lang.Object obj)
- Returns true if and only if the object does not contain fields
that should be recursively copied.
ensureFieldWalker
protected FieldWalker ensureFieldWalker(java.lang.Class c)
- Returns a FieldWalker for the class. The walkers are cached
so that they needn't be computed more than once for a given
class.