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>
AnEventList
composed of multiple sourceEventList
s. This list shows the contents of its source lists.Note that all contained
EventList
s must use the sameListEventPublisher
andReadWriteLock
, particularly if thisEventList
is to be used by multiple threads concurrently. To construct anEventList
that shares theListEventPublisher
andReadWriteLock
with thisCompositeList
, usecreateMemberList()
.Warning: This class is thread ready but not thread safe. See
EventList
for 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 void
addMemberList(EventList<E> member)
Adds the specifiedEventList
as a source to thisCompositeList
.<E> EventList<E>
createMemberList()
Creates a newEventList
that shares itsReadWriteLock
andListEventPublisher
with thisCompositeList
.void
removeMemberList(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 aCompositeList
that 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
ReadWriteLock
and it is desirable to compose their union with aCompositeList
.- Parameters:
lock
- theReadWriteLock
to use within theCompositeList
-
CompositeList
public CompositeList(ListEventPublisher publisher, ReadWriteLock lock)
Create aCompositeList
that uses the givenpublisher
andlock
. 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
ListEventPublisher
andReadWriteLock
and it is desirable to compose their union with aCompositeList
.- Parameters:
publisher
- theListEventPublisher
to use within theCompositeList
lock
- theReadWriteLock
to use within theCompositeList
-
-
Method Detail
-
addMemberList
public void addMemberList(EventList<E> member)
Adds the specifiedEventList
as a source to thisCompositeList
.To ensure correct behaviour when this
CompositeList
is used by multiple threads, the specified EventList has to share the sameReadWriteLock
andListEventPublisher
with this CompositeList.- Throws:
java.lang.IllegalArgumentException
- if the specified EventList uses a differentReadWriteLock
orListEventPublisher
- See Also:
createMemberList()
-
createMemberList
public <E> EventList<E> createMemberList()
Creates a newEventList
that shares itsReadWriteLock
andListEventPublisher
with thisCompositeList
. This is necessary when thisCompositeList
will be used by multiple threads.Note that the created
EventList
must be explicitly added as a member to thisCompositeList
usingaddMemberList(EventList)
.- Returns:
- a new EventList appropriate for use as a {#link #addMemberList member list} of this CompositeList
-
-