Class RangeList<E>
- java.lang.Object
-
- ca.odell.glazedlists.AbstractEventList<E>
-
- ca.odell.glazedlists.TransformedList<E,E>
-
- ca.odell.glazedlists.RangeList<E>
-
- All Implemented Interfaces:
ListEventListener<E>,EventList<E>,java.lang.Iterable<E>,java.util.Collection<E>,java.util.EventListener,java.util.List<E>
- Direct Known Subclasses:
ThresholdList
public class RangeList<E> extends TransformedList<E,E>
ThisEventListshows values from a continuous range of indices from a sourceEventList. 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
EventListfor 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 - Author:
- Jesse Wilson
-
-
Field Summary
-
Fields inherited from class ca.odell.glazedlists.TransformedList
source
-
Fields inherited from class ca.odell.glazedlists.AbstractEventList
publisher, readWriteLock, updates
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidadjustRange()Adjust the range of theRangeListin response to changes in the source list or the desired start and end indices.intgetEndIndex()protected intgetSourceIndex(int mutationIndex)Gets the index in the sourceEventListthat corresponds to the specified index.intgetStartIndex()protected booleanisWritable()Gets whether the sourceEventListis writable via this API.voidlistChanged(ListEvent<E> listChanges)When the underlying list changes, this notification allows the object to repaint itself or update itself as necessary.voidsetHeadRange(int startIndex, int endIndex)Set the range of values displayed by thisRangeList.voidsetMiddleRange(int startIndex, int endIndex)voidsetRange(int startIndex, int endIndex)Deprecated.2/15/2006 usesetHeadRange(int, int)instead.voidsetTailRange(int startIndex, int endIndex)Set the range to include the specified indices, offset from the end of the sourceEventList.intsize()Returns the number of elements in this list.-
Methods inherited from class ca.odell.glazedlists.TransformedList
add, addAll, clear, dispose, get, remove, removeAll, retainAll, set
-
Methods inherited from class ca.odell.glazedlists.AbstractEventList
add, addAll, addListEventListener, contains, containsAll, equals, getPublisher, getReadWriteLock, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeListEventListener, subList, toArray, toArray, toString
-
-
-
-
Method Detail
-
listChanged
public final void listChanged(ListEvent<E> listChanges)
When the underlying list changes, this notification allows the object to repaint itself or update itself as necessary.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.
- Specified by:
listChangedin interfaceListEventListener<E>- Specified by:
listChangedin classTransformedList<E,E>- Parameters:
listChanges- aListEventdescribing the changes to the list
-
setRange
public void setRange(int startIndex, int endIndex)Deprecated.2/15/2006 usesetHeadRange(int, int)instead. The introduction ofsetMiddleRange(int, int)caused us to want a consistent naming scheme for all set*Range methods.Set the range of values displayed by thisRangeList.
-
setHeadRange
public void setHeadRange(int startIndex, int endIndex)Set the range of values displayed by thisRangeList.
-
setMiddleRange
public void setMiddleRange(int startIndex, int endIndex)Set the range to include the specified indices, the startIndex offset from the front of the sourceEventListand the endIndex offset from the end of the sourceEventList.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);.
-
setTailRange
public void setTailRange(int startIndex, int endIndex)Set the range to include the specified indices, offset from the end of the sourceEventList. 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);.
-
adjustRange
protected final void adjustRange()
Adjust the range of theRangeListin response to changes in the source list or the desired start and end indices.
-
size
public final int size()
Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
-
getSourceIndex
protected final int getSourceIndex(int mutationIndex)
Gets the index in the sourceEventListthat corresponds to the specified index. More formally, returns the index such thatthis.get(i) == source.get(getSourceIndex(i))for all legal values ofi.- Overrides:
getSourceIndexin classTransformedList<E,E>
-
isWritable
protected final boolean isWritable()
Gets whether the sourceEventListis writable via this API.Extending classes must override this method in order to make themselves writable.
- Specified by:
isWritablein classTransformedList<E,E>
-
getStartIndex
public int getStartIndex()
-
getEndIndex
public int getEndIndex()
-
-