edu.umd.cs.jazz.util
Class ZObjectReferenceTable

java.lang.Object
  |
  +--edu.umd.cs.jazz.util.ZObjectReferenceTable
All Implemented Interfaces:
java.io.Serializable

public class ZObjectReferenceTable
extends java.lang.Object
implements java.io.Serializable

ZObjectReferenceTable helps to manage the references between objects within the scenegraph when a portion of the scenegraph is duplicated with clone(). It maintains the relationship between all cloned objects, and the original objects they were cloned from. Then, after all objects have been duplicated, each object's updateObjectReferences method is called. This method takes a ZObjectReferenceTable object as a parameter. The object's updateObjectReferences method can then use the getNewObjectReference method from this object to get updated references to objects that have been duplicated in the new sub-graph. If a match is found, a reference to the corresponding object in the newly cloned sub-graph is returned. If no corresponding reference is found, a ZDanglingReferenceException is thrown.

ZObjectReferenceTable is a singleton, which means that there can only be one instance of it in the entire run-time system. Rather than call the constructor, use the getInstance() method to access the single instance.

Warning: Serialized and ZSerialized objects of this class will not be compatible with future Jazz releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Jazz. A future release of Jazz will provide support for long term persistence.

Author:
Ben Bederson
See Also:
Serialized Form

Constructor Summary
protected ZObjectReferenceTable()
          Constructor for new empty table.
 
Method Summary
 void addObject(ZSceneGraphObject orig, ZSceneGraphObject copy)
          Adds an original/cloned object pair to the table.
static ZObjectReferenceTable getInstance()
          Implements singleton for this class.
 ZSceneGraphObject getNewObjectReference(ZSceneGraphObject origObj)
          This method is called to test if a node that is referenced by the object has been duplicated in the new cloned sub-graph.
 java.util.Iterator iterator()
          Return an iterator for this table.
 void reset()
          Resets the table, removing all entries from it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZObjectReferenceTable

protected ZObjectReferenceTable()
Constructor for new empty table.

Method Detail

getInstance

public static ZObjectReferenceTable getInstance()
Implements singleton for this class. Always returns the same instance of ZObjectReferenceTable.


addObject

public void addObject(ZSceneGraphObject orig,
                      ZSceneGraphObject copy)
Adds an original/cloned object pair to the table.

Parameters:
orig - The original object
copy - The copy of the original object

reset

public void reset()
Resets the table, removing all entries from it.


iterator

public java.util.Iterator iterator()
Return an iterator for this table.


getNewObjectReference

public ZSceneGraphObject getNewObjectReference(ZSceneGraphObject origObj)
This method is called to test if a node that is referenced by the object has been duplicated in the new cloned sub-graph. updateObjectReferences() calls this method with a reference to an old scene graph object (i.e. one that existed before the clone operation). If the object was cloned during the clone operation, the cloned version of the object is returned. Otherwise, null is returned.

Parameters:
origObj - The reference to the object in the original sub-graph.
Returns:
The cloned version of the Object, or null if it was not cloned.


Copyright 2003 by University of Maryland, College Park, MD 20742, USA All rights reserved.