|
|||||||||
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>
public class RangeList<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.
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(1), writes O(1), change range O(1) |
Memory: | 0 bytes per element |
Unit Tests: | N/A |
Issues: | 238 278 |
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 | |
---|---|
RangeList(EventList<E> 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)
Gets the index in the source EventList that corresponds to the
specified index. |
int |
getStartIndex()
Get the first index of the source EventList
that is presented in this RangeList . |
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 |
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, the startIndex offset from the front of the source EventList and the endIndex offset from the end
of the source EventList . |
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. |
void |
setTailRange(int startIndex,
int endIndex)
Set the range to include the specified indices, offset from the end of the source EventList . |
int |
size()
Returns the number of elements in this list. |
Methods inherited from class com.levigo.util.base.glazedlists.TransformedList |
---|
add, addAll, clear, dispose, 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 RangeList(EventList<E> source)
RangeList
that limits the specified EventList
to a desired range.
Method Detail |
---|
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>
@Deprecated public void setRange(int startIndex, int endIndex)
setHeadRange(int, int)
instead. The
introduction of setMiddleRange(int, int)
caused us to want a
consistent naming scheme for all set*Range methods.
RangeList
.
startIndex
- the first index of the source EventList
to show, inclusiveendIndex
- the last index of the source EventList
to show, exclusivepublic void setHeadRange(int startIndex, int endIndex)
RangeList
.
startIndex
- the first index of the source EventList
to show, inclusiveendIndex
- the last index of the source EventList
to show, exclusivepublic void setMiddleRange(int startIndex, int endIndex)
EventList
and the endIndex offset from the end
of the source EventList
.
For example, to include everything but the first element, use
RangeList.setMiddleRange(1, 0);
.
For example, to include everything but the last element, use
RangeList.setMiddleRange(0, 1);
.
public 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);
.
protected final void adjustRange()
RangeList
in response to changes in the
source list or the desired start and end indices.
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 final 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>
public int getStartIndex()
EventList
that is presented in this RangeList
.
public int getEndIndex()
EventList
that is beyond the range of this RangeList
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |