java.lang.Object
org.bzdev.util.EvntListenerList
Class implementing a list of event listeners .
This class has the same behavior as the class
EventListenerList
. It is provided so that
several modules (e.g., org.bzdev.devqsim and org.bzdev.drama) will
not have a dependency on the module java.desktop.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends EventListener>
voidAdd a listener to the list The listener l's class or one of its superclasses must match the class t.int
Get the number of listenersint
getListenerCount
(Class<?> t) Get the number of listeners for a particular key Each listener will have the key t as the listener's class or a superclass.Object[]
Returns the internal list of alternating listener classes and listeners.<T extends EventListener>
T[]getListeners
(Class<T> t) Get an array of listeners of a particular type.<T extends EventListener>
voidRemove a listener from a listener list.toString()
Get a string representation of this object.
-
Constructor Details
-
EvntListenerList
public EvntListenerList()Constructor.
-
-
Method Details
-
add
Add a listener to the list The listener l's class or one of its superclasses must match the class t. The full list is comprised of a collection of sublists, each distinguished by a class t that serves as a key naming a sublist.- Type Parameters:
T
- the type of the class provided by the first argument- Parameters:
t
- the class for the listenerl
- the listener, whose type or supertype must match the one provided by the argument t
-
getListenerCount
public int getListenerCount()Get the number of listeners- Returns:
- the number of listeners
-
getListenerCount
Get the number of listeners for a particular key Each listener will have the key t as the listener's class or a superclass. The full list is comprised of a collection of sublists, each distinguished by a class t that serves as a key naming a sublist.- Parameters:
t
- the class or a superclass serving as a key for listeners- Returns:
- the number of listeners
-
getListenerList
Returns the internal list of alternating listener classes and listeners. The array returned is the internal array used by this class.Please see
EventListenerList
for additional documentation.- Returns:
- an array whose even elements (starting from 0) contain the class for a listener and whose odd values contain the corresponding listener
-
getListeners
Get an array of listeners of a particular type. The full list is comprised of a collection of sublists, each distinguished by a class t that serves as a key naming a sublist.- Type Parameters:
T
- the type for the classt
- Parameters:
t
- the class (or superclass) of a listener that is used as a key- Returns:
- a list of the listeners matching the key
-
remove
Remove a listener from a listener list. If the same listener was added twice, the most recently added listener is the one that is removed. The listener l's class or one of its superclasses must match the class t. The full list is comprised of a collection of sublists, each distinguished by a class t that serves as a key naming a sublist.- Type Parameters:
T
- the type for the classt
- Parameters:
t
- the class for the listenerl
- the listener, whose type or supertype must match the one provided by the argument t
-
toString
Get a string representation of this object.
-