|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuka.transport.DeepClone
Provides reference cycle resolution in the deep-clone
process. Objects of a class that implements the DeepCloneable interface, can also be fast locally cloned. Unlike
the regular Java cloning mechanism (see Object.clone()), a
clone produced by the uka.transport serialization is a
deep clone with all referenced objects also being cloned. The deep
clone facility is a fast replacement for writing an object into a
local stream and reading it back immediately.
The method DeepCloneable#deepClone(DeepClone) should
produce a deep clone by first calling Object.clone() and
then cloning all fields of reference type. The references to other
objects should be cloned by calling the appropriate doDeepClone(Object) method of this class.
| Nested Class Summary | |
(package private) class |
DeepClone.CopyMarshalStream
|
(package private) class |
DeepClone.CopyUnmarshalStream
|
| Field Summary | |
(package private) MemoryBuffer |
buffer
|
(package private) Queue |
completionQueue
|
(package private) ObjectSpace |
copies
|
(package private) DeepClone.CopyUnmarshalStream |
in
|
(package private) ObjectSpace |
originals
|
(package private) DeepClone.CopyMarshalStream |
out
|
(package private) EnlargingIntArray |
streamCopyIDs
Stores all object identifiers for copies that are created by the fall-back cloning through an DeepClone.CopyMarshalStream/DeepClone.CopyUnmarshalStream pair. |
(package private) boolean |
streamUsed
|
| Constructor Summary | |
DeepClone()
|
|
DeepClone(ObjectSpace originals,
ObjectSpace copies)
Creates a DeepClone object that operates on
application-provided object spaces. |
|
| Method Summary | |
int |
add(int id,
java.lang.Object copy)
|
void |
appendTo(ToString s)
This method should append the contents of each instance variable of the current
object to the given ToString object. |
private java.lang.Object[] |
doDeepClone(int id,
java.lang.Object[] orig,
java.lang.Class component)
|
java.lang.Object |
doDeepClone(java.lang.Object orig)
Deeply clones an arbitrary object. |
java.lang.Object[] |
doDeepClone(java.lang.Object[] orig)
Deeply clones an object array. |
java.lang.Object |
internalCloneByMarshal(java.lang.Object orig)
Implements the fall-back strategy for deep cloning by marshaling to an ObjectOutputStream and reading the
object back via an ObjectInputStream. |
java.lang.Object |
internalDeepClone(java.lang.Object orig)
|
private java.lang.Object |
internalDeepClone(java.lang.Object orig,
int id)
|
java.lang.Object |
internalDeepCloneAnonymous(java.lang.Object orig)
|
protected boolean |
preserveReference(java.lang.Object orig)
A subclass may decide for which objects a reference should be used instead of a copy. |
protected java.lang.Object |
replaceObject(java.lang.Object obj)
|
void |
reset()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
final ObjectSpace originals
final ObjectSpace copies
final Queue completionQueue
transient boolean streamUsed
transient MemoryBuffer buffer
transient DeepClone.CopyMarshalStream out
transient DeepClone.CopyUnmarshalStream in
transient EnlargingIntArray streamCopyIDs
DeepClone.CopyMarshalStream/DeepClone.CopyUnmarshalStream pair.
DeepClone.CopyMarshalStream.replaceObject(Object)| Constructor Detail |
public DeepClone()
public DeepClone(ObjectSpace originals,
ObjectSpace copies)
DeepClone object that operates on
application-provided object spaces.
originals - is an object space that
keeps track of all objects that were presented to this DeepClone object as source objects being cloned.copies - keeps all objects that were created during the
clone process. Original objects and their clones are identified
by the same object identifier in both object spaces. An object
for which a clone is requested, may already be present in the
originals space. In that case, the object identifier assigned
there is also used for the clone that will be inserted into the
copies space. If an object is already present in both, the
originals and copies space, the object is not cloned again, but
its existing clone form the copies space is returned. If an
object is neither present in the originals nor the copies
space, a new identifier is allocated from the originals space
via ObjectSpace.getID(java.lang.Object). Afterwards the object
and its clone is entered into the originals and copies space
using the newly allocated identifier. The copies space is never
used to allocate a new identifier.| Method Detail |
public void reset()
public int add(int id,
java.lang.Object copy)
public final java.lang.Object[] doDeepClone(java.lang.Object[] orig)
throws java.lang.CloneNotSupportedException
java.lang.CloneNotSupportedException
private java.lang.Object[] doDeepClone(int id,
java.lang.Object[] orig,
java.lang.Class component)
throws java.lang.CloneNotSupportedException
java.lang.CloneNotSupportedException
public final java.lang.Object doDeepClone(java.lang.Object orig)
throws java.lang.CloneNotSupportedException
doDeepClone(java.lang.Object[]) is called.
java.lang.CloneNotSupportedException
public final java.lang.Object internalDeepClone(java.lang.Object orig)
throws java.lang.CloneNotSupportedException
java.lang.CloneNotSupportedException
public final java.lang.Object internalDeepCloneAnonymous(java.lang.Object orig)
throws java.lang.CloneNotSupportedException
java.lang.CloneNotSupportedException
private java.lang.Object internalDeepClone(java.lang.Object orig,
int id)
throws java.lang.CloneNotSupportedException
java.lang.CloneNotSupportedException
public java.lang.Object internalCloneByMarshal(java.lang.Object orig)
throws java.lang.CloneNotSupportedException
ObjectOutputStream and reading the
object back via an ObjectInputStream.
java.lang.CloneNotSupportedExceptionprotected boolean preserveReference(java.lang.Object orig)
Classes.isImmutable(java.lang.Object) are prevented from cloning.
protected java.lang.Object replaceObject(java.lang.Object obj)
throws java.io.IOException
java.io.IOExceptionpublic void appendTo(ToString s)
Printableappend the contents of each instance variable of the current
object to the given ToString object. The appended data
should be labeled with the name of the corresponding instance
variable.
appendTo in interface PrintableToString,
ToString.append(String, Object),
ToString.append(String, boolean),
ToString.append(String, byte),
ToString.append(String, int)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||