Class WeakEventListenerList
- java.lang.Object
-
- org.pentaho.reporting.libraries.designtime.swing.WeakEventListenerList
-
public class WeakEventListenerList extends Object
An event listener list that stores the listeners as weak references. This list behaves like theEventListenerList
, 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.- Author:
- Thomas Morgner
-
-
Constructor Summary
Constructors Constructor Description WeakEventListenerList()
Creates a new listener list with a increment of 10.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends EventListener>
voidadd(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>
T[]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>
voidremove(Class<T> t, T l)
Removes an existing listener of the given type from this eventlistener list.
-
-
-
Method Detail
-
add
public <T extends EventListener> void add(Class<T> t, T l)
Adds a new listener of the given type to this list.- Type Parameters:
T
- the type of the listener, must be a subclass ofjava.util.EventListener
.- Parameters:
t
- the type of the listener.l
- the listener.
-
remove
public <T extends EventListener> void remove(Class<T> t, T l)
Removes an existing listener of the given type from this eventlistener list.- Type Parameters:
T
- the type of the listener, must be a subclass ofjava.util.EventListener
.- Parameters:
t
- the type of the listener.l
- the listener.
-
getSize
public int getSize()
Returns the number of listeners of any type stored in this eventlistener list.- Returns:
- the overall size of this list.
-
getListenerCount
public int getListenerCount(Class<?> t)
Counts the number of listeners of a given type that are contained in this list.- Parameters:
t
- the type of the listener.- Returns:
- the number of listeners.
-
getListeners
public <T extends EventListener> T[] getListeners(Class<T> t)
Returns all listeners of the given type that are stored in this list.- Type Parameters:
T
- a implementation or derived interface of EventListener.- Parameters:
t
- the type of the listener to be retrieved.- Returns:
- the array containing all listeners.
-
-