cz.cuni.amis.utils.listener
Class ListenersMap<Key>

java.lang.Object
  extended by cz.cuni.amis.utils.listener.ListenersMap<Key>

public class ListenersMap<Key>
extends java.lang.Object

Map of the listeners according to some key.

Comes in handy when you need the map of Listeners<? extends Listener> and work with them (otherwise you're doomed to write tedious and ugly for-cycles forever).

And believe me, you don't want to parametrize the class more further the 'Key'... ... just remember it must be used with instances of 'Listener' and Java-generics are hell.


Constructor Summary
ListenersMap()
           
 
Method Summary
 void add(Key key, IListener listener)
           
 boolean hasListeners()
          Notice that "hasListeners" may report true even if there are no listeners registered here (because of weak references).
 boolean isListening(IListener listener)
           
 boolean isListening(Key key, IListener listener)
           
 void notify(Key key, Listeners.ListenerNotifier<IListener> notifier)
           
 void notify(Listeners.ListenerNotifier<IListener> notifier)
           
 boolean notifySafe(Key key, Listeners.ListenerNotifier<IListener> notifier, java.util.logging.Logger exceptionLog)
           
 boolean notifySafe(Listeners.ListenerNotifier<IListener> notifier, java.util.logging.Logger exceptionLog)
           
 void remove(IListener listener)
           
 void remove(Key key, IListener listener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListenersMap

public ListenersMap()
Method Detail

add

public void add(Key key,
                IListener listener)

isListening

public boolean isListening(IListener listener)

isListening

public boolean isListening(Key key,
                           IListener listener)

remove

public void remove(IListener listener)

remove

public void remove(Key key,
                   IListener listener)

notify

public void notify(Listeners.ListenerNotifier<IListener> notifier)

notify

public void notify(Key key,
                   Listeners.ListenerNotifier<IListener> notifier)

notifySafe

public boolean notifySafe(Listeners.ListenerNotifier<IListener> notifier,
                          java.util.logging.Logger exceptionLog)

notifySafe

public boolean notifySafe(Key key,
                          Listeners.ListenerNotifier<IListener> notifier,
                          java.util.logging.Logger exceptionLog)

hasListeners

public boolean hasListeners()
Notice that "hasListeners" may report true even if there are no listeners registered here (because of weak references). But it will usually return correct value.

Returns: