public abstract class TransformedList<S,E> extends AbstractEventList<E> implements ListEventListener<S>
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 AbstractEventList.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.
| Modifier and Type | Field and Description |
|---|---|
protected EventList<S> |
source
the event list to transform
|
publisher, readWriteLock, updates| Modifier | Constructor and Description |
|---|---|
protected |
TransformedList(EventList<S> source)
Creates a
TransformedList to transform the specified EventList. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
E value)
Inserts the specified element at the specified position in this list
(optional operation).
|
boolean |
addAll(int index,
java.util.Collection<? extends E> values)
Inserts all of the elements in the specified collection into this
list at the specified position (optional operation).
|
void |
clear()
Removes all of the elements from this list (optional operation).
|
void |
dispose()
Releases the resources consumed by this
TransformedList so that it
may eventually be garbage collected. |
E |
get(int index)
Returns the element at the specified position in this list.
|
protected int |
getSourceIndex(int mutationIndex)
Gets the index in the source
EventList that corresponds to the
specified index. |
protected abstract boolean |
isWritable()
Gets whether the source
EventList is writable via this API. |
abstract void |
listChanged(ListEvent<S> listChanges)
When the underlying list changes, this notification allows the
object to repaint itself or update itself as necessary.
|
E |
remove(int index)
Removes the element at the specified position in this list (optional
operation).
|
boolean |
removeAll(java.util.Collection<?> collection)
Removes from this list all the elements that are contained in the
specified collection (optional operation).
|
boolean |
retainAll(java.util.Collection<?> values)
Retains only the elements in this list that are contained in the
specified collection (optional operation).
|
E |
set(int index,
E value)
Replaces the element at the specified position in this list with the
specified element (optional operation).
|
int |
size()
Returns the number of elements in this list.
|
add, addAll, addListEventListener, contains, containsAll, equals, getPublisher, getReadWriteLock, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeListEventListener, subList, toArray, toArray, toStringprotected TransformedList(EventList<S> source)
TransformedList to transform the specified EventList.source - the EventList to transformprotected int getSourceIndex(int mutationIndex)
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.protected abstract boolean isWritable()
EventList is writable via this API.
Extending classes must override this method in order to make themselves writable.
public abstract void listChanged(ListEvent<S> listChanges)
It is mandatory that the calling thread has obtained the write lock on the source list. This is because the calling thread will have written to the source list to cause this event. This condition guarantees that no writes can occur while the listener is handling this event. It is an error to write to the source list while processing an event.
listChanged in interface ListEventListener<S>listChanges - a ListEvent describing the changes to the listpublic void add(int index,
E value)
add in interface java.util.List<E>add in class AbstractEventList<E>index - index at which the specified element is to be inserted.value - element to be inserted.public boolean addAll(int index,
java.util.Collection<? extends E> values)
addAll in interface java.util.List<E>addAll in class AbstractEventList<E>index - index at which to insert first element from the specified
collection.values - elements to be inserted into this list.public void clear()
clear in interface java.util.Collection<E>clear in interface java.util.List<E>clear in class AbstractEventList<E>public E get(int index)
get in interface java.util.List<E>get in class AbstractEventList<E>index - index of element to return.public E remove(int index)
remove in interface java.util.List<E>remove in class AbstractEventList<E>index - the index of the element to removed.public boolean removeAll(java.util.Collection<?> collection)
removeAll in interface java.util.Collection<E>removeAll in interface java.util.List<E>removeAll in class AbstractEventList<E>collection - collection that defines which elements will be removed from
this list.AbstractEventList.remove(Object),
AbstractEventList.contains(Object)public boolean retainAll(java.util.Collection<?> values)
retainAll in interface java.util.Collection<E>retainAll in interface java.util.List<E>retainAll in class AbstractEventList<E>values - collection that defines which elements this set will retain.AbstractEventList.remove(Object),
AbstractEventList.contains(Object)public E set(int index, E value)
set in interface java.util.List<E>set in class AbstractEventList<E>index - index of element to replace.value - element to be stored at the specified position.public int size()
size in interface java.util.Collection<E>size in interface java.util.List<E>size in class AbstractEventList<E>public void dispose()
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.
Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by buildd at 2016-02-14 5:12