org.silverpeas.util
Class ListSlice<T>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<T>
              extended by org.silverpeas.util.ListSlice<T>
All Implemented Interfaces:
Serializable, Cloneable, Iterable<T>, Collection<T>, List<T>, RandomAccess

public class ListSlice<T>
extends ArrayList<T>

This list represents a slice of a more complete lists and as such contains only the items that are part of this slice.

Author:
mmoquillon
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ListSlice(Collection<? extends T> collection)
          Constructs a new list slice with all the items of the specified collection.
ListSlice(int sliceBeginIndex, int sliceEndIndex)
          Constructs a new slice for a given list.
ListSlice(int sliceBeginIndex, int sliceEndIndex, int originalListSize)
          Constructs a new slice for a given list.
ListSlice(int sliceBeginIndex, int sliceEndIndex, List<? extends T> originalList)
          Constructs a new slice for a given list.
 
Method Summary
 int getBeginIndex()
          Gets the beginning index of this slice in the original list from which it comes.
 int getEndIndex()
          Gets the end index of this slice in the original list from which it comes.
 int getOriginalListSize()
          Gets the size of the list this slice comes from.
 void setOriginalListSize(int size)
          Sets the size of the list this slice comes from.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

ListSlice

public ListSlice(int sliceBeginIndex,
                 int sliceEndIndex)
Constructs a new slice for a given list.

Parameters:
sliceBeginIndex - the index from which this slice starts in the list.
sliceEndIndex - the index to which this slice ends in the list.

ListSlice

public ListSlice(int sliceBeginIndex,
                 int sliceEndIndex,
                 int originalListSize)
Constructs a new slice for a given list.

Parameters:
sliceBeginIndex - the index from which this slice starts in the list.
sliceEndIndex - the index to which this slice ends in the list.
originalListSize - the size of the list this slice comes from.

ListSlice

public ListSlice(int sliceBeginIndex,
                 int sliceEndIndex,
                 List<? extends T> originalList)
Constructs a new slice for a given list.

Parameters:
sliceBeginIndex - the index from which this slice starts in the list.
sliceEndIndex - the index to which this slice ends in the list.
originalList - the list from which this slice comes from.

ListSlice

public ListSlice(Collection<? extends T> collection)
Constructs a new list slice with all the items of the specified collection. This slice will cover the whole specified collection; this is it represents a whole list of the specified collection and as such the original list size is equal to its real size.

Parameters:
collection - a collection of items of type T
Method Detail

getBeginIndex

public int getBeginIndex()
Gets the beginning index of this slice in the original list from which it comes.

Returns:
the index at which this slice begins in the original list.

getEndIndex

public int getEndIndex()
Gets the end index of this slice in the original list from which it comes.

Returns:
the index at which this slice ends in the original list.

getOriginalListSize

public int getOriginalListSize()
Gets the size of the list this slice comes from.

Returns:
the size of the original list or -1 if no such information is set.

setOriginalListSize

public void setOriginalListSize(int size)
Sets the size of the list this slice comes from.



Copyright © 2016 Silverpeas. All Rights Reserved.