ca.odell.glazedlists

Class TransformedList<S,E>

Implemented Interfaces:
EventListener, EventList<E>, List, ListEventListener<E>
Known Direct Subclasses:
CachingList, CollectionList<S,E>, FileList, FilterList<E>, FreezableList<E>, FunctionList<S,E>, GroupingList<E>, NetworkList, ObservableElementList<E>, PopularityList<E>, RangeList<E>, SeparatorList<E>, SequenceList<E>, SortedList<E>, UniqueList<E>

public abstract class TransformedList<S,E>
extends AbstractEventList<E>
implements ListEventListener<E>

A convenience class for EventLists that decorate another EventList. Extending classes transform their source EventList by modifying the order, visibility and value of its elements.

Extending classes may implement the method getSourceIndex(int) to translate between indices of this and indices of the source.

Extending classes may implement the method isWritable() to make the source writable via this API.

Extending classes must explicitly call addListEventListener(ListEventListener) to receive change notifications from the source EventList.

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

Author:
Jesse Wilson

Field Summary

protected EventList
source
the event list to transform

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

publisher, readWriteLock, updates

Constructor Summary

TransformedList(EventList source)
Creates a TransformedList to transform the specified EventList.

Method Summary

void
add(int index, E value)
boolean
addAll(int index, E> values)
void
clear()
void
dispose()
Releases the resources consumed by this TransformedList so that it may eventually be garbage collected.
E
get(int index)
protected int
getSourceIndex(int mutationIndex)
Gets the index in the source EventList that corresponds to the specified index.
protected boolean
isWritable()
Gets whether the source EventList is writable via this API.
abstract void
listChanged(ListEvent listChanges)
E
remove(int index)
boolean
removeAll(Collection collection)
boolean
retainAll(Collection values)
E
set(int index, E value)
int
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

Field Details

source

protected EventList source
the event list to transform

Constructor Details

Method Details




dispose

public void dispose()
Releases the resources consumed by this TransformedList so that it may eventually be garbage collected.

A TransformedList will be garbage collected without a call to dispose(), but not before its source EventList is garbage collected. By calling dispose(), you allow the TransformedList to be garbage collected before its source EventList. This is necessary for situations where a TransformedList is short-lived but its source EventList is long-lived.

Warning: It is an error to call any method on a TransformedList after it has been disposed.



getSourceIndex

protected int getSourceIndex(int mutationIndex)
Gets the index in the source EventList that corresponds to the specified index. More formally, returns the index such that
this.get(i) == source.get(getSourceIndex(i)) for all legal values of i.

isWritable

protected boolean isWritable()
Gets whether the source EventList is writable via this API.

Extending classes must override this method in order to make themselves writable.


listChanged

public abstract void listChanged(ListEvent listChanges)






Glazed Lists, Copyright © 2003-2006 publicobject.com, O'Dell Engineering.
Documentation build by pbuilder at 2007-12-21 23:49