Package ca.odell.glazedlists
Interface EventList<E>
-
- All Superinterfaces:
java.util.Collection<E>,java.lang.Iterable<E>,java.util.List<E>
- All Known Implementing Classes:
AbstractEventList,BasicEventList,CachingList,CollectionList,CompositeList,DebugList,FileList,FilterList,FreezableList,FunctionList,GroupingList,NetworkList,ObservableElementList,PluggableList,PopularityList,RangeList,SeparatorList,SequenceList,SortedList,ThresholdList,TransactionList,TransformedList,UniqueList
public interface EventList<E> extends java.util.List<E>An observableList.ListEventListeners can register to be notified when this list changes. AListEventrepresents these changes to anEventList.EventLists may be writable or read-only. Consult the Javadoc for yourEventListif you are unsure.Warning:
EventLists are thread ready but not thread safe. If you are sharing anEventListbetween 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:
EventLists may break the contract required byList. For example, when youadd()on aSortedList, it will ignore the specified index so that the element will be inserted in sorted order.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddListEventListener(ListEventListener<? super E> listChangeListener)Registers the specified listener to receive change updates for this list.voiddispose()Disposing an EventList will make it eligible for garbage collection.ListEventPublishergetPublisher()Get the publisher used to distributeListEvents.ReadWriteLockgetReadWriteLock()Gets the lock required to share this list between multiple threads.voidremoveListEventListener(ListEventListener<? super E> listChangeListener)Removes the specified listener from receiving change updates for this list.-
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray
-
-
-
-
Method Detail
-
addListEventListener
void addListEventListener(ListEventListener<? super E> listChangeListener)
Registers the specified listener to receive change updates for this list.- Parameters:
listChangeListener- event listener != null- Throws:
java.lang.NullPointerException- if the specified listener is null
-
removeListEventListener
void removeListEventListener(ListEventListener<? super E> listChangeListener)
Removes the specified listener from receiving change updates for this list.- Parameters:
listChangeListener- event listener != null- Throws:
java.lang.NullPointerException- if the specified listener is nulljava.lang.IllegalArgumentException- if the specified listener wasn't added before
-
getReadWriteLock
ReadWriteLock getReadWriteLock()
Gets the lock required to share this list between multiple threads. It's always defined.- Returns:
- a re-entrant
ReadWriteLockthat guarantees thread safe access to this list.
-
getPublisher
ListEventPublisher getPublisher()
Get the publisher used to distributeListEvents. It's always defined.
-
dispose
void dispose()
Disposing an EventList will make it eligible for garbage collection. Some EventLists install themselves as listeners to related objects so disposing them is necessary.Warning: It is an error to call any method on an
EventListafter it has been disposed.
-
-