ca.odell.glazedlists

Class ThresholdList<E>

Implemented Interfaces:
EventListener, EventList<E>, List, ListEventListener<E>

public final class ThresholdList<E>
extends RangeList<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 ThresholdLists 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 java.util.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
Author:
Kevin Maltby

Nested Class Summary

static interface
ThresholdList.Evaluator
Provide an integer value for a given Object in a ThresholdList.

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

ThresholdList(EventList source, Evaluator evaluator)
Creates a ThresholdList that provides range-filtering on the specified EventList using the specified ThresholdList.Evaluator.
ThresholdList(EventList source, String propertyName)
Creates a ThresholdList that provides range-filtering based on the specified EventList based on the specified integer JavaBean property.

Method Summary

boolean
contains(Object object)
void
dispose()
int
getEndIndex()
Evaluator
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()
int
getUpperThreshold()
Gets the upper threshold for this list
int
indexOf(Object object)
int
lastIndexOf(Object object)
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)
void
setTailRange(int startIndex, int endIndex)
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 ca.odell.glazedlists.RangeList<E>

adjustRange, getEndIndex, getSourceIndex, getStartIndex, isWritable, listChanged, setHeadRange, setMiddleRange, setRange, setTailRange, 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

ThresholdList

public ThresholdList(EventList source,
                     Evaluator evaluator)
Creates a ThresholdList that provides range-filtering on the specified EventList using the specified ThresholdList.Evaluator.

ThresholdList

public ThresholdList(EventList source,
                     String propertyName)
Creates a ThresholdList that provides range-filtering based on the specified EventList based on the specified integer JavaBean property.

Method Details

contains

public boolean contains(Object object)
Overrides:
contains in interface AbstractEventList<E>

dispose

public void dispose()
Specified by:
dispose in interface EventList<E>
Overrides:
dispose in interface TransformedList<S,E>

getEndIndex

public int getEndIndex()
Overrides:
getEndIndex in interface RangeList<E>

getEvaluator

public Evaluator getEvaluator()

getLowerThreshold

public int getLowerThreshold()
Gets the lower threshold for this list

getStartIndex

public int getStartIndex()
Overrides:
getStartIndex in interface RangeList<E>

getUpperThreshold

public int getUpperThreshold()
Gets the upper threshold for this list

indexOf

public int indexOf(Object object)
Overrides:
indexOf in interface AbstractEventList<E>

lastIndexOf

public int lastIndexOf(Object object)
Overrides:
lastIndexOf in interface AbstractEventList<E>

setLowerThreshold

public void setLowerThreshold(E object)

setLowerThreshold

public void setLowerThreshold(int lowerThreshold)

setRange

public void setRange(int startIndex,
                     int endIndex)
Overrides:
setRange in interface RangeList<E>

setTailRange

public void setTailRange(int startIndex,
                         int endIndex)
Overrides:
setTailRange in interface RangeList<E>

setUpperThreshold

public void setUpperThreshold(E object)

setUpperThreshold

public void setUpperThreshold(int upperThreshold)

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