public class WeakEventListenerList extends Object
EventListenerList
, but does not create the risk of memory leaks when maintaining listener lists
for global objects.
The list is fully synchronized and safe to be used in multi-threading environments.Constructor and Description |
---|
WeakEventListenerList()
Creates a new listener list with a increment of 10.
|
Modifier and Type | Method and Description |
---|---|
<T extends EventListener> |
add(Class<T> t,
T l)
Adds a new listener of the given type to this list.
|
int |
getListenerCount(Class<?> t)
Counts the number of listeners of a given type that are contained in this list.
|
<T extends EventListener> |
getListeners(Class<T> t)
Returns all listeners of the given type that are stored in this list.
|
int |
getSize()
Returns the number of listeners of any type stored in this eventlistener list.
|
<T extends EventListener> |
remove(Class<T> t,
T l)
Removes an existing listener of the given type from this eventlistener list.
|
public WeakEventListenerList()
public <T extends EventListener> void add(Class<T> t, T l)
T
- the type of the listener, must be a subclass of java.util.EventListener
.t
- the type of the listener.l
- the listener.public <T extends EventListener> void remove(Class<T> t, T l)
T
- the type of the listener, must be a subclass of java.util.EventListener
.t
- the type of the listener.l
- the listener.public int getSize()
public int getListenerCount(Class<?> t)
t
- the type of the listener.public <T extends EventListener> T[] getListeners(Class<T> t)
T
- a implementation or derived interface of EventListener.t
- the type of the listener to be retrieved.