|
|||||||||
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.RangeList<E> com.levigo.util.base.glazedlists.ThresholdList<E>
public final class ThresholdList<E>
An EventList
that shows a range of the elements of the source EventList
. Each
element in the source EventList
is assigned an integer value via an ThresholdList.Evaluator
.
This integer is used to determine whether the element fits in the ThresholdList
s range.
By modifying the upper and lower thresholds in the range, the list can be filtered in a simple and powerful way.
The ThresholdList
lends itself to use with a slider widget for manipulating one of the
range's endpoints.
One use case for ThresholdList
is in a media player application. By creating a
ThresholdList.Evaluator
for a song's bitrate, the user could limit results to MP3 files between 192 and
320kbps.
Note that the elements in the ThresholdList
will be presented in order sorted by their
ThresholdList.Evaluator
value.
This EventList
supports all write operations.
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), change threshold O(log N) |
Memory: | 72 bytes per element |
Unit Tests: | N/A |
Issues: | 47 137 217 218 246 277 |
Nested Class Summary | |
---|---|
static interface |
ThresholdList.Evaluator<E>
Provide an integer value for a given Object in a
ThresholdList . |
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 | |
---|---|
ThresholdList(EventList<E> source,
String propertyName)
Creates a ThresholdList that provides range-filtering based on the
specified EventList based on the specified integer JavaBean property. |
|
ThresholdList(EventList<E> source,
ThresholdList.Evaluator<E> evaluator)
Creates a ThresholdList that provides range-filtering on the
specified EventList using the specified ThresholdList.Evaluator . |
Method Summary | |
---|---|
boolean |
contains(Object object)
Returns true if this list contains the specified element. |
void |
dispose()
Releases the resources consumed by this TransformedList so that it
may eventually be garbage collected. |
int |
getEndIndex()
Get the first index of the source EventList
that is beyond the range of this RangeList . |
ThresholdList.Evaluator<E> |
getEvaluator()
A convenience method to allow access to the ThresholdList.Evaluator
that was provided on construction. |
int |
getLowerThreshold()
Gets the lower threshold for this list |
int |
getStartIndex()
Get the first index of the source EventList
that is presented in this RangeList . |
int |
getUpperThreshold()
Gets the upper threshold for this list |
int |
indexOf(Object object)
Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element. |
int |
lastIndexOf(Object object)
Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element. |
void |
setLowerThreshold(E object)
Sets the lower threshold for this list to be the result of calling evaluate() on the given object. |
void |
setLowerThreshold(int lowerThreshold)
Sets the lower threshold for this list. |
void |
setRange(int startIndex,
int endIndex)
Set the range of values displayed by this RangeList . |
void |
setTailRange(int startIndex,
int endIndex)
Set the range to include the specified indices, offset from the end of the source EventList . |
void |
setUpperThreshold(E object)
Sets the upper threshold for this list to be the result of calling evaluate() on the given object. |
void |
setUpperThreshold(int upperThreshold)
Sets the upper threshold for this list. |
Methods inherited from class com.levigo.util.base.glazedlists.RangeList |
---|
adjustRange, getSourceIndex, isWritable, listChanged, setHeadRange, setMiddleRange, size |
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, containsAll, equals, getPublisher, getReadWriteLock, hashCode, isEmpty, iterator, 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 ThresholdList(EventList<E> source, String propertyName)
ThresholdList
that provides range-filtering based on the
specified EventList
based on the specified integer JavaBean property.
public ThresholdList(EventList<E> source, ThresholdList.Evaluator<E> evaluator)
ThresholdList
that provides range-filtering on the
specified EventList
using the specified ThresholdList.Evaluator
.
Method Detail |
---|
public void setLowerThreshold(E object)
evaluate()
on the given object.
This list can be used programmatically rather than hooking it up to a UI component. Calling this method directly while this list is connected to a particular widget could result in errors.
Warning: This method is
thread ready but not thread safe. See EventList
for an example
of thread safe code.
public void setLowerThreshold(int lowerThreshold)
This list can be used programmatically rather than hooking it up to a UI component. Calling this method directly while this list is connected to a particular widget could result in errors.
Warning: This method is
thread ready but not thread safe. See EventList
for an example
of thread safe code.
public int getLowerThreshold()
public void setUpperThreshold(E object)
evaluate()
on the given object.
This list can be used programmatically rather than hooking it up to a UI component. Calling this method directly while this list is connected to a particular widget could result in errors.
Warning: This method is
thread ready but not thread safe. See EventList
for an example
of thread safe code.
public void setUpperThreshold(int upperThreshold)
Warning: This method is
thread ready but not thread safe. See EventList
for an example
of thread safe code.
public int getUpperThreshold()
public ThresholdList.Evaluator<E> getEvaluator()
ThresholdList.Evaluator
that was provided on construction.
public boolean contains(Object object)
contains
in interface Collection<E>
contains
in interface List<E>
contains
in class AbstractEventList<E>
object
- element whose presence in this list is to be tested.
public int indexOf(Object object)
indexOf
in interface List<E>
indexOf
in class AbstractEventList<E>
object
- element to search for.
public int lastIndexOf(Object object)
lastIndexOf
in interface List<E>
lastIndexOf
in class AbstractEventList<E>
object
- element to search for.
public void setRange(int startIndex, int endIndex)
RangeList
.
setRange
in class RangeList<E>
startIndex
- the first index of the source EventList
to show, inclusiveendIndex
- the last index of the source EventList
to show, exclusivepublic void setTailRange(int startIndex, int endIndex)
EventList
. For example, to show the last five values, use:
RangeList.setTailRange(5, 0);
To include the 3rd last and 2nd last values, use:
RangeList.setTailRange(3, 1);
.
setTailRange
in class RangeList<E>
public int getStartIndex()
EventList
that is presented in this RangeList
.
getStartIndex
in class RangeList<E>
public int getEndIndex()
EventList
that is beyond the range of this RangeList
.
getEndIndex
in class RangeList<E>
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>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |