|
Nuxeo ECM Projects 5.4.3-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.nuxeo.common.collections.ListenerList
public class ListenerList
Internal class to maintain a list of listeners. This class is a thread-safe list that is optimized for frequent reads and infrequent writes. Copy on write is used to ensure readers can access the list without synchronization overhead. Readers are given access to the underlying array data structure for reading, with the trust that they will not modify the underlying array.
Copied from Eclipse source code: http://www.eclipse.org
Field Summary | |
---|---|
static int |
EQUALITY
Mode constant (value 0) indicating that listeners should be compared using equality. |
static int |
IDENTITY
Mode constant (value 1) indicating that listeners should be compared using identity. |
Constructor Summary | |
---|---|
ListenerList()
Creates a listener list. |
|
ListenerList(Comparator<?> comparator)
|
|
ListenerList(int mode,
Comparator<?> comparator)
Creates a listener list using the provided comparison mode. |
Method Summary | |
---|---|
void |
add(Object listener)
Adds the given listener to this list. |
Object[] |
getListeners()
Returns an array containing all the registered listeners. |
Object[] |
getListenersCopy()
|
boolean |
isEmpty()
Returns whether this listener list is empty. |
void |
remove(Object listener)
Removes the given listener from this list. |
int |
size()
Returns the number of registered listeners. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int EQUALITY
public static final int IDENTITY
Constructor Detail |
---|
public ListenerList()
public ListenerList(Comparator<?> comparator)
public ListenerList(int mode, Comparator<?> comparator)
Method Detail |
---|
public void add(Object listener)
This method is synchronized to protect against multiple threads adding or removing listeners concurrently. This does not block concurrent readers.
listener
- the listener to addpublic Object[] getListeners()
Note: callers must not modify the returned array.
public Object[] getListenersCopy()
public boolean isEmpty()
true
if there are no registered listeners, and
false
otherwisepublic void remove(Object listener)
This method is synchronized to protect against multiple threads adding or removing listeners concurrently. This does not block concurrent readers.
listener
- the listenerpublic int size()
|
Nuxeo ECM Projects 5.4.3-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |