public class SimpleCountKeyManager extends java.lang.Object implements IKeyManager
Constructor and Description |
---|
SimpleCountKeyManager() |
Modifier and Type | Method and Description |
---|---|
void |
addKeyChangeListener(IKeyChangeListener listener)
Adds a new
IKeyChangeListener to listen for key change events in
the manager. |
java.util.List<java.lang.String> |
getAvailableKeys()
Gets the list of available keys.
|
java.lang.String |
getNextKey()
Returns the next available key, usually based on some default prefix,
e.g., "key1", "key2".
|
boolean |
keyAvailable(java.lang.String key)
Determines whether the specified key is available.
|
void |
releaseKey(java.lang.String key)
Releases the specified key if it is valid.
|
void |
removeKeyChangeListener(IKeyChangeListener listener)
Removes an existing
IKeyChangeListener from the key manager. |
java.lang.String |
takeKey()
Takes the next available key if it is available.
|
public java.lang.String takeKey()
Listeners are notified that the key has been taken.
count
, as a string.public void releaseKey(java.lang.String key)
Listeners are notified that the key has been released.
key
- The key to release.public boolean keyAvailable(java.lang.String key)
IKeyManager
keyAvailable
in interface IKeyManager
key
- The key to test.public java.util.List<java.lang.String> getAvailableKeys()
IKeyManager
getAvailableKeys
in interface IKeyManager
public java.lang.String getNextKey() throws java.lang.IllegalStateException
IKeyManager
getNextKey
in interface IKeyManager
java.lang.IllegalStateException
- An exception is thrown if there is a pre-defined list of keys
and there are no more keys available.public void addKeyChangeListener(IKeyChangeListener listener)
IKeyManager
IKeyChangeListener
to listen for key change events in
the manager.addKeyChangeListener
in interface IKeyManager
listener
- The new listener. The same listener should not be added twice.public void removeKeyChangeListener(IKeyChangeListener listener)
IKeyManager
IKeyChangeListener
from the key manager.removeKeyChangeListener
in interface IKeyManager
listener
- The old listener. This removes the first matching occurrence
of the listener from the manager.