dsto.dfc.databeans
Class Registry

java.lang.Object
  extended by dsto.dfc.databeans.AbstractDataObject
      extended by dsto.dfc.databeans.DataObject
          extended by dsto.dfc.databeans.Registry
All Implemented Interfaces:
IDataObject, IDataObjectChildListener, Serializable, Cloneable

public class Registry
extends DataObject

A registry of data objects where each object is uniquely identified by one of its properties. The properties of a registry are the key values of objects add ()'ed to it, the values are the objects themselves. This provides extra convenience over using setValue () and getValue () calls plus automatic uniqueness checking.

Note: the key property of an object should not change once added to the registry.

Author:
Matthew Phillips
See Also:
Serialized Form

Field Summary
 Object keyProperty
           
 
Fields inherited from class dsto.dfc.databeans.DataObject
propertyToValue, typeInfo
 
Fields inherited from class dsto.dfc.databeans.AbstractDataObject
listeners
 
Fields inherited from interface dsto.dfc.databeans.IDataObject
OVERRIDE, PERSISTENT, PERSISTENT_OVERRIDE, TRANSIENT, TRANSIENT_OVERRIDE
 
Constructor Summary
Registry()
          Create a default instance using the default string "id" as the key property.
Registry(Object keyProperty)
          Create a new instance.
 
Method Summary
 void add(IDataObject object)
          Add an object to the registry.
 boolean containsKey(Object key)
          Test if a given key exists in the registry.
 IDataObject find(Object key)
          Find an object with a given key.
 Iterator iterator()
          Create an iterator over all the entities in the registry.
 IDataObject peek(Object key)
          Peek to see if an object exists.
 void remove(Object key)
           
 int size()
          The number of objects in the registry.
 Set snapshot()
          Create a snapshot of the current objects.
 
Methods inherited from class dsto.dfc.databeans.DataObject
getTypeInfo, getValue, isTransient, propertyIterator, setTypeInfo, setValue, shallowClone
 
Methods inherited from class dsto.dfc.databeans.AbstractDataObject
addFirstPropertyListener, addPropertyListener, childPropertyChanged, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, getBeanValue, getBooleanValue, getBooleanValue, getCharValue, getCharValue, getDoubleValue, getDoubleValue, getFloatValue, getFloatValue, getIntValue, getIntValue, getLongValue, getLongValue, getObjectValue, getPropertyListeners, getShortValue, getStringValue, registerValue, removePropertyListener, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, toString, unregisterValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

keyProperty

public final Object keyProperty
Constructor Detail

Registry

public Registry()
Create a default instance using the default string "id" as the key property.


Registry

public Registry(Object keyProperty)
Create a new instance.

Parameters:
keyProperty - The property that is used to identify objects added to the registry.
Method Detail

add

public void add(IDataObject object)
         throws IllegalArgumentException
Add an object to the registry.

Parameters:
object - The object to add.
Throws:
IllegalArgumentException - if the objects' key is null or already in use.

remove

public void remove(Object key)

peek

public IDataObject peek(Object key)
Peek to see if an object exists.

Parameters:
key - The object key.
Returns:
The object, or null if not found.
See Also:
find(Object)

find

public IDataObject find(Object key)
                 throws IllegalArgumentException
Find an object with a given key. Generates an error if no object with the key is found.

Parameters:
key - The object key.
Returns:
The object.
Throws:
IllegalArgumentException - if no object with the key exists.
See Also:
peek(Object)

containsKey

public boolean containsKey(Object key)
Test if a given key exists in the registry.


iterator

public Iterator iterator()
Create an iterator over all the entities in the registry.

Overrides:
iterator in class DataObject

size

public int size()
The number of objects in the registry.


snapshot

public Set snapshot()
Create a snapshot of the current objects. This will not change if the registry is later modified,



Copyright © 2008 Commonwealth of Australia