ca.odell.glazedlists
public interface EventList<E> extends java.util.List<E>
List
. ListEventListener
s can register to be
notified when this list changes.
EventList
s may be writable or read-only. Consult the Javadoc for
your EventList
if you are unsure.
Warning: EventList
s
are thread ready but not thread safe. If you are sharing an EventList
between multiple threads, you can add thread safety by using the built-in
locks:
EventList myList = ... myList.getReadWriteLock().writeLock().lock(); try { // access myList here if(myList.size() > 3) { System.out.println(myList.get(3)); myList.remove(3); } } finally { myList.getReadWriteLock().writeLock().unlock(); }Note that you are also required to acquire and hold the lock during the construction of an EventList if concurrent modifications are possible in your environment, like so:
EventList source = ... SortedList sorted; source.getReadWriteLock().readLock().lock(); try { sorted = new SortedList(source); } finally { source.getReadWriteLock().readLock().unlock(); }
Warning: EventList
s
may break the contract required by List
. For example, when
you add()
on a SortedList
, it will ignore the specified
index so that the element will be inserted in sorted order.
Modifier and Type | Method and Description |
---|---|
void |
addListEventListener(ListEventListener<? super E> listChangeListener)
Registers the specified listener to receive change updates for this list.
|
void |
dispose()
Disposing an EventList will make it eligible for garbage collection.
|
ListEventPublisher |
getPublisher()
Get the publisher used to distribute
ListEvent s. |
ReadWriteLock |
getReadWriteLock()
Gets the lock required to share this list between multiple threads.
|
void |
removeListEventListener(ListEventListener<? super E> listChangeListener)
Removes the specified listener from receiving change updates for this list.
|
void addListEventListener(ListEventListener<? super E> listChangeListener)
void removeListEventListener(ListEventListener<? super E> listChangeListener)
ReadWriteLock getReadWriteLock()
ReadWriteLock
that guarantees thread safe
access to this list.ListEventPublisher getPublisher()
ListEvent
s.void dispose()
Warning: It is an error
to call any method on an EventList
after it has been disposed.
Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by pbuser at 2014-03-20 3:42