ca.odell.glazedlists

Class RangeList<E>

Implemented Interfaces:
EventListener, EventList<E>, List, ListEventListener<E>
Known Direct Subclasses:
ThresholdList<E>

public class RangeList<E>
extends TransformedList<S,E>

This EventList shows values from a continuous range of indices from a source EventList. It can be used to limit the length of a list to a desired size.

EventList Overview
Writable:yes
Concurrency:thread ready, not thread safe
Performance:reads: O(1), writes O(1), change range O(1)
Memory:0 bytes per element
Unit Tests:N/A
Issues: 238 278
Author:
Jesse Wilson

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

RangeList(EventList source)
Create a new RangeList that limits the specified EventList to a desired range.

Method Summary

protected void
adjustRange()
Adjust the range of the RangeList in response to changes in the source list or the desired start and end indices.
int
getEndIndex()
Get the first index of the source EventList that is beyond the range of this RangeList.
protected int
getSourceIndex(int mutationIndex)
int
getStartIndex()
Get the first index of the source EventList that is presented in this RangeList.
protected boolean
isWritable()
void
listChanged(ListEvent listChanges)
void
setHeadRange(int startIndex, int endIndex)
Set the range of values displayed by this RangeList.
void
setMiddleRange(int startIndex, int endIndex)
Set the range to include the specified indices, offset from the end of the source EventList.
void
setRange(int startIndex, int endIndex)
Deprecated. 2/15/2006 use setHeadRange(int,int) instead.
void
setTailRange(int startIndex, int endIndex)
Set the range to include the specified indices, offset from the end of the source EventList.
int
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

RangeList

public RangeList(EventList source)
Create a new RangeList that limits the specified EventList to a desired range.

Method Details

adjustRange

protected final void adjustRange()
Adjust the range of the RangeList in response to changes in the source list or the desired start and end indices.

getEndIndex

public int getEndIndex()
Get the first index of the source EventList that is beyond the range of this RangeList.

getSourceIndex

protected final int getSourceIndex(int mutationIndex)
Overrides:
getSourceIndex in interface TransformedList<S,E>

getStartIndex

public int getStartIndex()

isWritable

protected final boolean isWritable()
Overrides:
isWritable in interface TransformedList<S,E>

listChanged

public final void listChanged(ListEvent listChanges)
Specified by:
listChanged in interface ListEventListener<E>

setHeadRange

public void setHeadRange(int startIndex,
                         int endIndex)
Parameters:
startIndex - the first index of the source EventList to show, inclusive
endIndex - the last index of the source EventList to show, exclusive

setMiddleRange

public void setMiddleRange(int startIndex,
                           int endIndex)
Set the range to include the specified indices, offset from the end of the source 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);.


setRange

public void setRange(int startIndex,
                     int endIndex)

Deprecated. 2/15/2006 use setHeadRange(int,int) instead. The introduction of setMiddleRange(int,int) caused us to want a consistent naming scheme for all set*Range methods.

Set the range of values displayed by this RangeList.
Parameters:
startIndex - the first index of the source EventList to show, inclusive
endIndex - the last index of the source EventList to show, exclusive

setTailRange

public void setTailRange(int startIndex,
                         int endIndex)
Set the range to include the specified indices, offset from the end of the source 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);.


size

public final int size()
Overrides:
size in interface TransformedList<S,E>

Glazed Lists, Copyright © 2003-2006 publicobject.com, O'Dell Engineering.
Documentation build by buildd at 2008-01-04 14:38