org.argouml.model.uml
Class EventListenerList

java.lang.Object
  |
  +--org.argouml.model.uml.EventListenerList

class EventListenerList
extends java.lang.Object

A wrapped object array that contains triples of eventtype, eventname, interested listener. I used an Object array for this purpose since it performs fast. Copied a lot of the code from javax.swing.EventListenerList.


Field Summary
(package private)  java.lang.Object[] _listenerList
          The list of EventKey - Listener pairs.
private static java.lang.Object[] NULL_ARRAY
          A null array to be shared by all empty listener lists
 
Constructor Summary
(package private) EventListenerList()
           
 
Method Summary
 void add(EventKey key, MElementListener listener)
          Registers the given listeners for the event typed by EventKey.
 int getListenerCount()
          Returns the total number of listeners for this listener list.
 int getListenerCount(EventKey key)
          Returns the total number of listeners of the supplied type for this listener list.
private  int getListenerCount(java.lang.Object[] list, EventKey key)
          Returns the number of listeners that are interested in the given key and exist in the given object array.
 MElementListener[] getListeners(EventKey key)
          Returns an array of listeners that are interested in an event that is typed by the given EventKey.
 void remove(EventKey key, MElementListener listener)
          Removes a listener from the list.
private  void removeElement(int index)
          Does the actual removal of an element at the given index in the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_ARRAY

private static final java.lang.Object[] NULL_ARRAY
A null array to be shared by all empty listener lists


_listenerList

java.lang.Object[] _listenerList
The list of EventKey - Listener pairs. It's visibility is default since it's used in AbstractUmlModelFactory in a performant but quite awkward way from an encapsulation point of view.

Constructor Detail

EventListenerList

EventListenerList()
Method Detail

getListeners

public MElementListener[] getListeners(EventKey key)
Returns an array of listeners that are interested in an event that is typed by the given EventKey. If the name is null of the EventKey, all listeners are returned that have the corresponding name filled or null. Same is true for the type.

Parameters:
key -
Returns:
An array of listeners that are interested in the event typed by the given EventKey

add

public void add(EventKey key,
                MElementListener listener)
Registers the given listeners for the event typed by EventKey. If the name is null (of the EventKey), the listener is registred for all events that have a type corresponding to the type in the given key, no matter what the name of the event is. Vice versa for the type.

A listener that has been added twice will get the events for which it registred twice. Be careful with registring listeners!

Parameters:
key -
listener -

remove

public void remove(EventKey key,
                   MElementListener listener)
Removes a listener from the list.

Parameters:
key -
listener -

removeElement

private void removeElement(int index)
Does the actual removal of an element at the given index in the list.

Parameters:
index -

getListenerCount

private int getListenerCount(java.lang.Object[] list,
                             EventKey key)
Returns the number of listeners that are interested in the given key and exist in the given object array.

Parameters:
list -
key -
Returns:

getListenerCount

public int getListenerCount(EventKey key)
Returns the total number of listeners of the supplied type for this listener list.


getListenerCount

public int getListenerCount()
Returns the total number of listeners for this listener list.



ArgoUML © 1996-2004 (20040306)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook