ca.odell.glazedlists

Class CollectionList<S,E>

Implemented Interfaces:
EventListener, EventList<E>, List, ListEventListener<E>
Known Direct Subclasses:
CompositeList<E>

public class CollectionList<S,E>
extends TransformedList<S,E>
implements ListEventListener<E>

A list that acts like a tree in that it contains child elements to nodes contained in another list. An example usage would be to wrap a parent list containing albums and use the CollectionList to display the songs on the album.

The actual mapping from the parent list to the child list (album to songs in the above example) is done by a CollectionList.Model that is provided to the constructor.

Note that any EventLists returned by the CollectionList.Model must use the same ListEventPublisher and ReadWriteLock as this CollectionList. This is necessary in order for CollectionList to operate correctly under mult-threaded conditions. An IllegalArgumentException will be raised if this invariant is violated.

Warning: This class is thread ready but not thread safe. See EventList for an example of thread safe code.

EventList Overview
Writable:only set(int,Object) and remove(int)
Concurrency:thread ready, not thread safe
Performance:reads: O(log N), writes O(log N)
Memory:96 bytes per element
Unit Tests:N/A
Issues: 96 162 257 265
Authors:
Rob Eden
Jesse Wilson
See Also:
CollectionList.Model

Nested Class Summary

static interface
CollectionList.Model
Provides the logic to map a parent object (e.g.

Field Summary

Fields inherited from class ca.odell.glazedlists.TransformedList<S,E>

source

Fields inherited from class ca.odell.glazedlists.AbstractEventList<E>

publisher, readWriteLock, updates

Constructor Summary

CollectionList(EventList source, Model model)
Create a CollectionList with its contents being the children of the elements in the specified source EventList.

Method Summary

int
childEndingIndex(int parentIndex)
Return the index of the last child in the CollectionList for the given parent index.
int
childStartingIndex(int parentIndex)
Return the index of the first child in the CollectionList for the given parent index.
void
dispose()
E
get(int index)
protected boolean
isWritable()
void
listChanged(ListEvent listChanges)
Handle changes in the parent list.
E
remove(int index)
E
set(int index, E value)
int
size()

Methods inherited from class ca.odell.glazedlists.TransformedList<S,E>

add, addAll, clear, dispose, get, getSourceIndex, isWritable, listChanged, remove, removeAll, retainAll, set, size

Methods inherited from class ca.odell.glazedlists.AbstractEventList<E>

T[] toArray, add, add, addAll, addAll, addListEventListener, clear, contains, containsAll, equals, get, getPublisher, getReadWriteLock, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeListEventListener, retainAll, set, size, subList, toArray, toString

Constructor Details

CollectionList

public CollectionList(EventList source,
                      Model model)
Create a CollectionList with its contents being the children of the elements in the specified source EventList.
Parameters:
source - an EventList of Objects from each of which the model can extract child elements
model - the logic for extracting children from each source element

Method Details


Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by pbuilder at 2009-07-14 22:05