|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.levigo.util.base.glazedlists.AbstractEventList<E> com.levigo.util.base.glazedlists.TransformedList<E,E> com.levigo.util.base.glazedlists.FilterList<E>
public final class FilterList<E>
An EventList
that shows a subset of the elements of a source EventList
. This
subset is composed of all elements of the source EventList
that match the filter.
The filter can be static or dynamic. Changing the behaviour of the filter will change which elements of the source list are included.
Warning: This class breaks the contract required by
List
. See EventList
for an example.
Warning: This class is thread ready but not thread
safe. See EventList
for an example of thread safe code.
EventList Overview | |
Writable: | yes |
Concurrency: | thread ready, not thread safe |
Performance: | reads: O(log N), writes O(log N), filter changes O(N) |
Memory: | 0 to 26 bytes per element |
Unit Tests: | N/A |
Issues: | 1 2 7 46 187 254 312 |
Field Summary |
---|
Fields inherited from class com.levigo.util.base.glazedlists.TransformedList |
---|
source |
Fields inherited from class com.levigo.util.base.glazedlists.AbstractEventList |
---|
publisher, readWriteLock, updates |
Constructor Summary | |
---|---|
FilterList(EventList<E> source)
Creates a FilterList that includes a subset of the specified
source EventList . |
|
FilterList(EventList<E> source,
Matcher<? super E> matcher)
Convenience constructor for creating a FilterList and setting its
Matcher . |
|
FilterList(EventList<E> source,
MatcherEditor<? super E> matcherEditor)
Convenience constructor for creating a FilterList and setting its
MatcherEditor . |
Method Summary | |
---|---|
void |
dispose()
Releases the resources consumed by this TransformedList so that it
may eventually be garbage collected. |
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. |
void |
listChanged(ListEvent<E> listChanges)
When the underlying list changes, this notification allows the object to repaint itself or update itself as necessary. |
void |
setMatcher(Matcher<? super E> matcher)
Set the Matcher which specifies which elements shall be filtered. |
void |
setMatcherEditor(MatcherEditor<? super E> editor)
Set the MatcherEditor which provides a dynamic Matcher
to determine which elements shall be filtered. |
int |
size()
Returns the number of elements in this list. |
Methods inherited from class com.levigo.util.base.glazedlists.TransformedList |
---|
add, addAll, clear, get, remove, removeAll, retainAll, set |
Methods inherited from class com.levigo.util.base.glazedlists.AbstractEventList |
---|
add, addAll, addListEventListener, contains, containsAll, equals, getPublisher, getReadWriteLock, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeListEventListener, subList, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FilterList(EventList<E> source)
FilterList
that includes a subset of the specified
source EventList
.
public FilterList(EventList<E> source, Matcher<? super E> matcher)
FilterList
and setting its
Matcher
.
public FilterList(EventList<E> source, MatcherEditor<? super E> matcherEditor)
FilterList
and setting its
MatcherEditor
.
Method Detail |
---|
public void setMatcher(Matcher<? super E> matcher)
Matcher
which specifies which elements shall be filtered.
This will remove the current Matcher
or MatcherEditor
and refilter the entire list.
public void setMatcherEditor(MatcherEditor<? super E> editor)
MatcherEditor
which provides a dynamic Matcher
to determine which elements shall be filtered.
This will remove the current Matcher
or MatcherEditor
and refilter the entire list.
public void dispose()
TransformedList
so that it
may eventually be garbage collected.
A TransformedList
will be garbage collected without a call to
TransformedList.dispose()
, but not before its source EventList
is garbage
collected. By calling TransformedList.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.
dispose
in interface EventList<E>
dispose
in class TransformedList<E,E>
public final void listChanged(ListEvent<E> 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<E>
listChanged
in class TransformedList<E,E>
public final int size()
size
in interface Collection<E>
size
in interface List<E>
size
in class TransformedList<E,E>
protected final 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
.
getSourceIndex
in class TransformedList<E,E>
protected boolean isWritable()
EventList
is writable via this API.
Extending classes must override this method in order to make themselves writable.
isWritable
in class TransformedList<E,E>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |