Jazz API Documentation

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.

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 used in conjunction with the clone() method.
 void reset()
          Resets the table, removing all entries from it.
 void updateObjectReferences()
          Goes through all the original objects in the table, and notifies them to update their internal references, passing in a reference to this table so it can be queried for original/new object mappings.
 
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.

updateObjectReferences

public void updateObjectReferences()
Goes through all the original objects in the table, and notifies them to update their internal references, passing in a reference to this table so it can be queried for original/new object mappings.

getNewObjectReference

public ZSceneGraphObject getNewObjectReference(ZSceneGraphObject origObj)
                                        throws ZDanglingReferenceException
This method is used in conjunction with the clone() method. It can be used by the updateNodeReferences() method to see if a node that is being referenced has been duplicated in the new cloned sub-graph. An object's updateObjectReferences() method would use this method by calling it with the reference to the old (existed before the clone operation) object. If the object has been duplicated in the clone sub-graph, the corresponding object in the cloned sub-graph is returned. If no corresponding reference is found, a ZDanglingReferenceException is thrown.
Parameters:
origObj - The reference to the object in the original sub-graph.

Jazz API Documentation