Class CompositeList<E>
- java.lang.Object
-
- ca.odell.glazedlists.AbstractEventList<E>
-
- ca.odell.glazedlists.TransformedList<S,E>
-
- ca.odell.glazedlists.CollectionList<EventList<E>,E>
-
- ca.odell.glazedlists.CompositeList<E>
-
- All Implemented Interfaces:
ListEventListener<EventList<E>>,EventList<E>,java.lang.Iterable<E>,java.util.Collection<E>,java.util.EventListener,java.util.List<E>
public class CompositeList<E> extends CollectionList<EventList<E>,E>
AnEventListcomposed of multiple sourceEventLists. This list shows the contents of its source lists.Note that all contained
EventLists must use the sameListEventPublisherandReadWriteLock, particularly if thisEventListis to be used by multiple threads concurrently. To construct anEventListthat shares theListEventPublisherandReadWriteLockwith thisCompositeList, usecreateMemberList().Warning: This class is thread ready but not thread safe. See
EventListfor an example of thread safe code.EventList Overview Writable: only CollectionList.set(int,Object)andCollectionList.remove(int)Concurrency: not thread safe Performance: reads: O(log N), writes O(log N) Memory: 96 bytes per element Unit Tests: N/A Issues: 25 93 96 162 - Author:
- Jesse Wilson
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ca.odell.glazedlists.CollectionList
CollectionList.Model<E,S>
-
-
Field Summary
-
Fields inherited from class ca.odell.glazedlists.TransformedList
source
-
Fields inherited from class ca.odell.glazedlists.AbstractEventList
publisher, readWriteLock, updates
-
-
Constructor Summary
Constructors Constructor Description CompositeList()CompositeList(ListEventPublisher publisher, ReadWriteLock lock)CompositeList(ReadWriteLock lock)Deprecated.replaced byCompositeList(ListEventPublisher, ReadWriteLock), because prebuilt member lists should share lock and publisher with the CompositeList.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMemberList(EventList<E> member)Adds the specifiedEventListas a source to thisCompositeList.<E> EventList<E>createMemberList()Creates a newEventListthat shares itsReadWriteLockandListEventPublisherwith thisCompositeList.voidremoveMemberList(EventList<E> list)-
Methods inherited from class ca.odell.glazedlists.CollectionList
childEndingIndex, childStartingIndex, dispose, get, isWritable, listChanged, remove, set, size
-
Methods inherited from class ca.odell.glazedlists.TransformedList
add, addAll, clear, getSourceIndex, removeAll, retainAll
-
Methods inherited from class ca.odell.glazedlists.AbstractEventList
add, addAll, addListEventListener, contains, containsAll, equals, getPublisher, getReadWriteLock, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeListEventListener, subList, toArray, toArray, toString
-
-
-
-
Constructor Detail
-
CompositeList
public CompositeList()
-
CompositeList
public CompositeList(ReadWriteLock lock)
Deprecated.replaced byCompositeList(ListEventPublisher, ReadWriteLock), because prebuilt member lists should share lock and publisher with the CompositeList.Create aCompositeListthat uses the givenlock. Note that this lock will also be used whenbuilding new member lists.This can be a convenient constructor to use when the member lists are prebuilt ahead of time with a common
ReadWriteLockand it is desirable to compose their union with aCompositeList.- Parameters:
lock- theReadWriteLockto use within theCompositeList
-
CompositeList
public CompositeList(ListEventPublisher publisher, ReadWriteLock lock)
Create aCompositeListthat uses the givenpublisherandlock. Note that this publisher and lock will also be used whenbuilding new member lists.This can be a convenient constructor to use when the member lists are prebuilt ahead of time with a common
ListEventPublisherandReadWriteLockand it is desirable to compose their union with aCompositeList.- Parameters:
publisher- theListEventPublisherto use within theCompositeListlock- theReadWriteLockto use within theCompositeList
-
-
Method Detail
-
addMemberList
public void addMemberList(EventList<E> member)
Adds the specifiedEventListas a source to thisCompositeList.To ensure correct behaviour when this
CompositeListis used by multiple threads, the specified EventList has to share the sameReadWriteLockandListEventPublisherwith this CompositeList.- Throws:
java.lang.IllegalArgumentException- if the specified EventList uses a differentReadWriteLockorListEventPublisher- See Also:
createMemberList()
-
createMemberList
public <E> EventList<E> createMemberList()
Creates a newEventListthat shares itsReadWriteLockandListEventPublisherwith thisCompositeList. This is necessary when thisCompositeListwill be used by multiple threads.Note that the created
EventListmust be explicitly added as a member to thisCompositeListusingaddMemberList(EventList).- Returns:
- a new EventList appropriate for use as a {#link #addMemberList member list} of this CompositeList
-
-