com.nwoods.jgo
Class JGoCopyMap

java.lang.Object
  extended bycom.nwoods.jgo.JGoCopyMap
All Implemented Interfaces:
JGoCopyEnvironment, java.util.Map, java.io.Serializable

public class JGoCopyMap
extends java.lang.Object
implements JGoCopyEnvironment, java.io.Serializable

The default environment object used during copy operations. JGoCopyMap is used during copy operations to allow copies of complex networks of objects to be handled flexibly.

For example, when a network of objects is copied, references among the objects being copied can be considered to be references to the newly copied object, or references to the original objects, or references to already existing objects. JGoCopyMap copies all objects and maintains interobject references in a manner similar to how the original collection of objects referred to each other.

See Also:
JGoObject.copyObject(com.nwoods.jgo.JGoCopyEnvironment), Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Constructor Summary
JGoCopyMap()
          Constructs a new JGoCopyMap, which is basically a HashMap along with a Vector holding objects whose copying has been delayed.
 
Method Summary
 void clear()
          The standard Map behavior
 void clearDelayeds()
          Removes all delayed objects.
 boolean containsKey(java.lang.Object key)
          The standard Map behavior
 boolean containsValue(java.lang.Object value)
          The standard Map behavior
 JGoObject copy(JGoObject obj)
          Get a new object corresponding to the argument, either by finding an already copied object for it or by calling JGoObject.copyObject.
 JGoObject copyComplete(JGoObject obj)
          This convenience method performs both copy phases making a copy of a single object.
 void delay(java.lang.Object key)
          Adds the object to the collection of delayed objects.
 java.util.Set entrySet()
          The standard Map behavior
 boolean equals(java.lang.Object o)
          The standard Map behavior
 void finishDelayedCopies()
          Perform calls to JGoObject.copyObjectDelayed for any objects that were added to the Delayeds collection during earlier calls to copy(JGoObject).
 java.lang.Object get(java.lang.Object key)
          The standard Map behavior
 java.util.Vector getDelayeds()
          Returns the Vector of objects whose copy operation has been delayed.
 int hashCode()
          The standard Map behavior
 boolean isDelayed(java.lang.Object key)
          Tests if the specified object is in this collection of delayed objects.
 boolean isEmpty()
          The standard Map behavior
 boolean isEmptyDelayeds()
          Returns true if there are no delayed objects.
 java.util.Set keySet()
          The standard Map behavior
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          The standard Map behavior
 void putAll(java.util.Map t)
          The standard Map behavior
 java.lang.Object remove(java.lang.Object key)
          The standard Map behavior
 void removeDelayed(java.lang.Object key)
          Remove the object from the collection of delayed objects.
 int size()
          The standard Map behavior
 int sizeDelayeds()
          Returns the number of delayed objects.
 java.util.Collection values()
          The standard Map behavior
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JGoCopyMap

public JGoCopyMap()
Constructs a new JGoCopyMap, which is basically a HashMap along with a Vector holding objects whose copying has been delayed.

Method Detail

clear

public void clear()
The standard Map behavior

Specified by:
clear in interface java.util.Map

containsKey

public boolean containsKey(java.lang.Object key)
The standard Map behavior

Specified by:
containsKey in interface java.util.Map

containsValue

public boolean containsValue(java.lang.Object value)
The standard Map behavior

Specified by:
containsValue in interface java.util.Map

entrySet

public java.util.Set entrySet()
The standard Map behavior

Specified by:
entrySet in interface java.util.Map

equals

public boolean equals(java.lang.Object o)
The standard Map behavior

Specified by:
equals in interface java.util.Map

get

public java.lang.Object get(java.lang.Object key)
The standard Map behavior

Specified by:
get in interface java.util.Map

hashCode

public int hashCode()
The standard Map behavior

Specified by:
hashCode in interface java.util.Map

isEmpty

public boolean isEmpty()
The standard Map behavior

Specified by:
isEmpty in interface java.util.Map

keySet

public java.util.Set keySet()
The standard Map behavior

Specified by:
keySet in interface java.util.Map

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
The standard Map behavior

Specified by:
put in interface java.util.Map

putAll

public void putAll(java.util.Map t)
The standard Map behavior

Specified by:
putAll in interface java.util.Map

remove

public java.lang.Object remove(java.lang.Object key)
The standard Map behavior

Specified by:
remove in interface java.util.Map

size

public int size()
The standard Map behavior

Specified by:
size in interface java.util.Map

values

public java.util.Collection values()
The standard Map behavior

Specified by:
values in interface java.util.Map

copy

public JGoObject copy(JGoObject obj)
Description copied from interface: JGoCopyEnvironment
Get a new object corresponding to the argument, either by finding an already copied object for it or by calling JGoObject.copyObject.

This is a convenience method for JGoObject.copyObject implementations to call to find the corresponding new object for an old object even when it has already been copied: newobj.myObjRef = env.copy(myObjRef);

If the given object is null, this method returns null.

Specified by:
copy in interface JGoCopyEnvironment

finishDelayedCopies

public void finishDelayedCopies()
Perform calls to JGoObject.copyObjectDelayed for any objects that were added to the Delayeds collection during earlier calls to copy(JGoObject).

This is primarily called by JGoDocument.copyFromCollection.

Specified by:
finishDelayedCopies in interface JGoCopyEnvironment

copyComplete

public JGoObject copyComplete(JGoObject obj)
This convenience method performs both copy phases making a copy of a single object.

Specified by:
copyComplete in interface JGoCopyEnvironment
Returns:
null, if obj is null, else the result of copy(JGoObject) after a call to finishDelayedCopies().

clearDelayeds

public void clearDelayeds()
Description copied from interface: JGoCopyEnvironment
Removes all delayed objects.

Specified by:
clearDelayeds in interface JGoCopyEnvironment

isEmptyDelayeds

public boolean isEmptyDelayeds()
Description copied from interface: JGoCopyEnvironment
Returns true if there are no delayed objects.

Specified by:
isEmptyDelayeds in interface JGoCopyEnvironment

sizeDelayeds

public int sizeDelayeds()
Description copied from interface: JGoCopyEnvironment
Returns the number of delayed objects.

Specified by:
sizeDelayeds in interface JGoCopyEnvironment

isDelayed

public boolean isDelayed(java.lang.Object key)
Description copied from interface: JGoCopyEnvironment
Tests if the specified object is in this collection of delayed objects.

Specified by:
isDelayed in interface JGoCopyEnvironment
Parameters:
key - an object.
Returns:
true if the object is considered delayed.

delay

public void delay(java.lang.Object key)
Description copied from interface: JGoCopyEnvironment
Adds the object to the collection of delayed objects. The copying operation should copy this object after all the other objects have been copied.

Specified by:
delay in interface JGoCopyEnvironment
Parameters:
key - the object to be delayed

removeDelayed

public void removeDelayed(java.lang.Object key)
Description copied from interface: JGoCopyEnvironment
Remove the object from the collection of delayed objects.

Specified by:
removeDelayed in interface JGoCopyEnvironment
Parameters:
key - element to be removed from this Vector, if present.
Returns:
true if the Vector contained the specified element.

getDelayeds

public java.util.Vector getDelayeds()
Description copied from interface: JGoCopyEnvironment
Returns the Vector of objects whose copy operation has been delayed. After all the regular objects have been copied, it may be safe to copy the delayed objects.

Specified by:
getDelayeds in interface JGoCopyEnvironment
Returns:
Vector of objects whose copy operation has been delayed.