|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.fhg.igd.util.Notifier
public class Notifier
Acts on trigger objects such as events or messages. The strategy is to index listeners according to the objects they want to be triggered by. For each trigger object an entry in the hashtable index is made which serves as the key for the set of listeners wanting to be notified when this trigger object is detected by the notifier.
Listener| Field Summary | |
|---|---|
static int |
DEFAULT_CAPACITY
|
static float |
DEFAULT_LOADFACTOR
|
protected HashMap |
index_
For efficient notification this instance keeps a hashtable which uses the trigger objects as keys. |
| Constructor Summary | |
|---|---|
Notifier()
The default constructor creates a simple instance of this class. |
|
Notifier(int capacity,
float loadfactor)
Creates a notifier instance with the given default parameters which are passed to the HashMap which backs this class. |
|
| Method Summary | |
|---|---|
void |
addListener(Listener listener,
Object trigger)
Adds a listener to the list of listener. |
void |
addListener(Listener listener,
Object[] trigger)
Adds an listener to the list of listeners. |
int |
countListeners()
Returns the number of listener. |
void |
deleteListener(Listener listener)
Removes the given listener from the list of listeners. |
void |
deleteListeners()
Deletes the listeners. |
void |
notifyListeners(Object o)
Notifies those listeners which requested to be triggered by the given object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_CAPACITY
public static final float DEFAULT_LOADFACTOR
protected HashMap index_
| Constructor Detail |
|---|
public Notifier()
public Notifier(int capacity,
float loadfactor)
throws IllegalArgumentException
capacity - The initial capacity of the HashMap.loadfactor - The initial loadfactor of the HashMap.
IllegalArgumentException - if a parameter is wrong.| Method Detail |
|---|
public void addListener(Listener listener,
Object trigger)
listener - The listener to add.trigger - The object which triggers the notification
of the listener.
public void addListener(Listener listener,
Object[] trigger)
listener - The listener to add.trigger - The objects which trigger the notification
of the listener.public void deleteListener(Listener listener)
listener - The listener which should be removed.public void notifyListeners(Object o)
equals method.
Subclasses may implement other strategies such
as testing for implication of trigger objects by
the given one.
o - The object which is triggered.public void deleteListeners()
public int countListeners()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||