dd.util
Class Registry
java.lang.Object
java.util.AbstractMap
java.util.HashMap
dd.util.Registry
- All Implemented Interfaces:
- java.lang.Cloneable, java.util.EventListener, java.util.Map, java.beans.PropertyChangeListener, java.io.Serializable
- public class Registry
- extends java.util.HashMap
- implements java.beans.PropertyChangeListener
A storage container for SimObjects. Registries are indexed by a unique ID
string and store simobjects. They fire PropertyChangeEvents, so a
listener interested in the SimObjects in the registry (and when they
change) can listen to the registry rather than listeneing to each of the
individual objects within it.
- Author:
- Seth McGinnis
- See Also:
- Serialized Form
Method Summary |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds the listener to the list of objects to be notified when this
simulation object changes. |
void |
clear()
|
void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Informs listeners that a property has changed. |
java.lang.String |
getID(java.lang.Object o)
|
void |
propertyChange(java.beans.PropertyChangeEvent e)
|
void |
put(java.lang.Object key,
SimObject value)
|
void |
put(SimObject value)
Puts a value with an aribtrary unique key. |
java.lang.Object |
remove(java.lang.Object o)
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes the listener from the notification list. |
Methods inherited from class java.util.HashMap |
clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, size, values |
Methods inherited from class java.util.AbstractMap |
equals, hashCode, toString |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
equals, hashCode |
Registry
public Registry()
Registry
public Registry(java.util.Map map)
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
- Adds the listener to the list of objects to be notified when this
simulation object changes. This simulation object is the source of a
property change event when attributes and other values of the
simulation object change. The listener will be notified whenever any
property of this simulation object changes.
- Parameters:
listener
- object to notify when properties change
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
- Removes the listener from the notification list. This removes a
registered listener from the list of object to be informed when this
simulation object changes.
- Parameters:
listener
- object to no longer receive notifications
firePropertyChange
public void firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
- Informs listeners that a property has changed. This method is
currently called immediately after the specified property is
set (in case a listener wishes to revert to the earlier value.) This
method is called automatically when an attribute value is set. If a
subclass has additional properties that require notification, they
should call this method immediately after setting the property in
order to inform any listeners. By convention, property names are the
names of instance variables or attributes.
- Parameters:
propertyName
- name of the property that is changingoldValue
- former value of the propertynewValue
- new (probably current) value of the property
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent e)
- Specified by:
propertyChange
in interface java.beans.PropertyChangeListener
getID
public java.lang.String getID(java.lang.Object o)
clear
public void clear()
- Specified by:
clear
in interface java.util.Map
remove
public java.lang.Object remove(java.lang.Object o)
- Specified by:
remove
in interface java.util.Map
put
public void put(java.lang.Object key,
SimObject value)
put
public void put(SimObject value)
- Puts a value with an aribtrary unique key. In some cases, it is
unimportant what the keys are in the Registry, just that they are
unique. This convenience method uses
Object.hashCode()
to
generate keys.