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

Package class diagram package ListenersMap
java.lang.Object
  extended by cz.cuni.amis.utils.listener.ListenersMap<Key>

public class ListenersMap<Key>
extends 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.

Author:
Jimmy

Constructor Summary
ListenersMap()
           
 
Method Summary
 void add(Key key, IListener listener)
           
 Logger getLog()
           
 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, Logger exceptionLog)
           
 boolean notifySafe(Listeners.ListenerNotifier<IListener> notifier, Logger exceptionLog)
           
 void remove(IListener listener)
           
 void remove(Key key, IListener listener)
           
 void setLog(Logger log, String name)
           
 
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

getLog

public Logger getLog()

setLog

public void setLog(Logger log,
                   String name)

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,
                          Logger exceptionLog)

notifySafe

public boolean notifySafe(Key key,
                          Listeners.ListenerNotifier<IListener> notifier,
                          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:


Copyright © 2014 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.