public class Registry
extends java.lang.Object
The Registry class holds all of the information relevant to the Item, which is accessible as a key-value pair. Entries may be registered with the Registry and it will call their update method when the value of a key is initially set or changed.
Constructor and Description |
---|
Registry()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(java.lang.String keyToCheck)
This operation checks to see if the Registry contains a particular key.
|
void |
dispatch()
The dispatch operation directs the Registry to call the update operation
on all of the Entries that are registered against keys with updated
values.
|
java.lang.String |
getValue(java.lang.String key)
The getValue operation checks the Registry for a key and returns its
value.
|
boolean |
register(IUpdateable registrant,
java.lang.String key)
The register operation registers a class that implements IUpdateable
against a key in the Registry.
|
boolean |
setValue(java.lang.String key,
java.lang.String value)
The setValue operations sets the value for a certain key.
|
boolean |
updateValue(java.lang.String key,
java.lang.String value)
The updateValue operation updates the value for the given key in the
Registry.
|
public boolean register(IUpdateable registrant, java.lang.String key)
The register operation registers a class that implements IUpdateable against a key in the Registry. If the value of the key is set or changed, the Registry will call the update operation of the IUpdateable interface when the Registry.dispatch() is called. If the key is not in the Registry, it will be added as part of the registration.
registrant
- The Entry that depends on the value of the key and should be notified of changes.
key
- The key for which the Entry should be notified of changes to its value.
True if the registration is successful, false otherwise.
public void dispatch()
The dispatch operation directs the Registry to call the update operation on all of the Entries that are registered against keys with updated values.
public boolean setValue(java.lang.String key, java.lang.String value)
The setValue operations sets the value for a certain key.
key
- The key whose value should be updated.
value
- The new value.
True if the value is set, false otherwise.
public java.lang.String getValue(java.lang.String key)
The getValue operation checks the Registry for a key and returns its value. It returns NULL if the key does not have a value or if the key does not exist in the Registry.
key
- The key for which the value should be returned.
The value of the key. NULL if the value is unset or key does not exist.
public boolean updateValue(java.lang.String key, java.lang.String value)
The updateValue operation updates the value for the given key in the Registry. It does not add the key to the Registry, so if the key is not already there this operation will do nothing. It returns true if it is able to update the value and false if it can not find the key in the Registry or for some other problem.
key
- The key that should be updated.
value
- The new value.
True if it is can update the value and false if not
public boolean containsKey(java.lang.String keyToCheck)
This operation checks to see if the Registry contains a particular key.
keyToCheck
- The key to be checked.
True if the key exists in the registry, false otherwise.