Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.ibatis.common.util
Class PaginatedArrayList  view PaginatedArrayList download PaginatedArrayList.java

java.lang.Object
  extended bycom.ibatis.common.util.PaginatedArrayList
All Implemented Interfaces:
java.util.Collection, java.lang.Iterable, java.util.List, PaginatedList

public class PaginatedArrayList
extends java.lang.Object
implements PaginatedList

Implementation of PaginatedList backed by an ArrayList


Field Summary
private static java.util.ArrayList EMPTY_LIST
           
private  int index
           
private  java.util.List list
           
private  java.util.List page
           
private  int pageSize
           
 
Constructor Summary
PaginatedArrayList(java.util.Collection c, int pageSize)
          Constructor to create an instance using an existing collection
PaginatedArrayList(int pageSize)
           
PaginatedArrayList(int initialCapacity, int pageSize)
          Constructor to set the initial size and the page size
 
Method Summary
 void add(int index, java.lang.Object element)
          Insert an element into the list at a given position (optional operation).
 boolean add(java.lang.Object o)
          Add an element to the end of the list (optional operation).
 boolean addAll(java.util.Collection c)
          Add the contents of a collection to the end of the list (optional operation).
 boolean addAll(int index, java.util.Collection c)
          Insert the contents of a collection into the list at a given position (optional operation).
 void clear()
          Clear the list, such that a subsequent call to isEmpty() would return true (optional operation).
 boolean contains(java.lang.Object o)
          Test whether this list contains a given object as one of its elements.
 boolean containsAll(java.util.Collection c)
          Test whether this list contains every element in a given collection.
 java.lang.Object get(int index)
          Get the element at a given index in this list.
 int getPageIndex()
          Returns the current page index, which is a zero based integer.
 int getPageSize()
          Returns the maximum number of items per page
 void gotoPage(int pageNumber)
          Moves to a specified page.
 int indexOf(java.lang.Object o)
          Obtain the first index at which a given object is to be found in this list.
 boolean isEmpty()
          Test whether this list is empty, that is, if size() == 0.
 boolean isFirstPage()
          Is the current page the first page?
 boolean isLastPage()
          Is the current page the last page?
 boolean isMiddlePage()
          Is the current page a middle page (i.e.
 boolean isNextPageAvailable()
          Is a page available after the current page?
 boolean isPreviousPageAvailable()
          Is a page available before the current page?
 java.util.Iterator iterator()
          Obtain an Iterator over this list, whose sequence is the list order.
 int lastIndexOf(java.lang.Object o)
          Obtain the last index at which a given object is to be found in this list.
 java.util.ListIterator listIterator()
          Obtain a ListIterator over this list, starting at the beginning.
 java.util.ListIterator listIterator(int index)
          Obtain a ListIterator over this list, starting at a given position.
 boolean nextPage()
          Moves to the next page after the current page.
 boolean previousPage()
          Moves to the page before the current page.
 java.lang.Object remove(int index)
          Remove the element at a given position in this list (optional operation).
 boolean remove(java.lang.Object o)
          Remove the first occurence of an object from this list (optional operation).
 boolean removeAll(java.util.Collection c)
          Remove all elements of a given collection from this list (optional operation).
private  void repaginate()
           
 boolean retainAll(java.util.Collection c)
          Remove all elements of this list that are not contained in a given collection (optional operation).
 java.lang.Object set(int index, java.lang.Object element)
          Replace an element of this list with another object (optional operation).
 int size()
          Get the number of elements in this list.
 java.util.List subList(int fromIndex, int toIndex)
          Obtain a List view of a subsection of this list, from fromIndex (inclusive) to toIndex (exclusive).
 java.lang.Object[] toArray()
          Copy the current contents of this list into an array.
 java.lang.Object[] toArray(java.lang.Object[] a)
          Copy the current contents of this list into an array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.List
equals, hashCode
 

Field Detail

EMPTY_LIST

private static final java.util.ArrayList EMPTY_LIST

list

private java.util.List list

page

private java.util.List page

pageSize

private int pageSize

index

private int index
Constructor Detail

PaginatedArrayList

public PaginatedArrayList(int pageSize)

PaginatedArrayList

public PaginatedArrayList(int initialCapacity,
                          int pageSize)
Constructor to set the initial size and the page size


PaginatedArrayList

public PaginatedArrayList(java.util.Collection c,
                          int pageSize)
Constructor to create an instance using an existing collection

Method Detail

repaginate

private void repaginate()

size

public int size()
Description copied from interface: java.util.List
Get the number of elements in this list. If the list contains more than Integer.MAX_VALUE elements, return Integer.MAX_VALUE.

Specified by:
size in interface java.util.List

isEmpty

public boolean isEmpty()
Description copied from interface: java.util.List
Test whether this list is empty, that is, if size() == 0.

Specified by:
isEmpty in interface java.util.List

contains

public boolean contains(java.lang.Object o)
Description copied from interface: java.util.List
Test whether this list contains a given object as one of its elements. This is defined as the existence of an element e such that o == null ? e == null : o.equals(e).

Specified by:
contains in interface java.util.List

iterator

public java.util.Iterator iterator()
Description copied from interface: java.util.List
Obtain an Iterator over this list, whose sequence is the list order.

Specified by:
iterator in interface java.util.List

toArray

public java.lang.Object[] toArray()
Description copied from interface: java.util.List
Copy the current contents of this list into an array.

Specified by:
toArray in interface java.util.List

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Description copied from interface: java.util.List
Copy the current contents of this list into an array. If the array passed as an argument has length less than that of this list, an array of the same run-time type as a, and length equal to the length of this list, is allocated using Reflection. Otherwise, a itself is used. The elements of this list are copied into it, and if there is space in the array, the following element is set to null. The resultant array is returned. Note: The fact that the following element is set to null is only useful if it is known that this list does not contain any null elements.

Specified by:
toArray in interface java.util.List

containsAll

public boolean containsAll(java.util.Collection c)
Description copied from interface: java.util.List
Test whether this list contains every element in a given collection.

Specified by:
containsAll in interface java.util.List

get

public java.lang.Object get(int index)
Description copied from interface: java.util.List
Get the element at a given index in this list.

Specified by:
get in interface java.util.List

indexOf

public int indexOf(java.lang.Object o)
Description copied from interface: java.util.List
Obtain the first index at which a given object is to be found in this list.

Specified by:
indexOf in interface java.util.List

lastIndexOf

public int lastIndexOf(java.lang.Object o)
Description copied from interface: java.util.List
Obtain the last index at which a given object is to be found in this list.

Specified by:
lastIndexOf in interface java.util.List

listIterator

public java.util.ListIterator listIterator()
Description copied from interface: java.util.List
Obtain a ListIterator over this list, starting at the beginning.

Specified by:
listIterator in interface java.util.List

listIterator

public java.util.ListIterator listIterator(int index)
Description copied from interface: java.util.List
Obtain a ListIterator over this list, starting at a given position. A first call to next() would return the same as get(index), and a first call to previous() would return the same as get(index - 1).

Specified by:
listIterator in interface java.util.List

subList

public java.util.List subList(int fromIndex,
                              int toIndex)
Description copied from interface: java.util.List
Obtain a List view of a subsection of this list, from fromIndex (inclusive) to toIndex (exclusive). If the two indices are equal, the sublist is empty. The returned list should be modifiable if and only if this list is modifiable. Changes to the returned list should be reflected in this list. If this list is structurally modified in any way other than through the returned list, the result of any subsequent operations on the returned list is undefined.

Specified by:
subList in interface java.util.List

add

public boolean add(java.lang.Object o)
Description copied from interface: java.util.List
Add an element to the end of the list (optional operation). If the list imposes restraints on what can be inserted, such as no null elements, this should be documented.

Specified by:
add in interface java.util.List

remove

public boolean remove(java.lang.Object o)
Description copied from interface: java.util.List
Remove the first occurence of an object from this list (optional operation). That is, remove the first element e such that o == null ? e == null : o.equals(e).

Specified by:
remove in interface java.util.List

addAll

public boolean addAll(java.util.Collection c)
Description copied from interface: java.util.List
Add the contents of a collection to the end of the list (optional operation). This operation is undefined if this list is modified during the operation (for example, if you try to insert a list into itself).

Specified by:
addAll in interface java.util.List

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Description copied from interface: java.util.List
Insert the contents of a collection into the list at a given position (optional operation). Shift all elements at that position to the right by the number of elements inserted. This operation is undefined if this list is modified during the operation (for example, if you try to insert a list into itself).

Specified by:
addAll in interface java.util.List

removeAll

public boolean removeAll(java.util.Collection c)
Description copied from interface: java.util.List
Remove all elements of a given collection from this list (optional operation). That is, remove every element e such that c.contains(e).

Specified by:
removeAll in interface java.util.List

retainAll

public boolean retainAll(java.util.Collection c)
Description copied from interface: java.util.List
Remove all elements of this list that are not contained in a given collection (optional operation). That is, remove every element e such that !c.contains(e).

Specified by:
retainAll in interface java.util.List

clear

public void clear()
Description copied from interface: java.util.List
Clear the list, such that a subsequent call to isEmpty() would return true (optional operation).

Specified by:
clear in interface java.util.List

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Description copied from interface: java.util.List
Replace an element of this list with another object (optional operation).

Specified by:
set in interface java.util.List

add

public void add(int index,
                java.lang.Object element)
Description copied from interface: java.util.List
Insert an element into the list at a given position (optional operation). This shifts all existing elements from that position to the end one index to the right. This version of add has no return, since it is assumed to always succeed if there is no exception.

Specified by:
add in interface java.util.List

remove

public java.lang.Object remove(int index)
Description copied from interface: java.util.List
Remove the element at a given position in this list (optional operation). Shifts all remaining elements to the left to fill the gap.

Specified by:
remove in interface java.util.List

getPageSize

public int getPageSize()
Description copied from interface: PaginatedList
Returns the maximum number of items per page

Specified by:
getPageSize in interface PaginatedList

isFirstPage

public boolean isFirstPage()
Description copied from interface: PaginatedList
Is the current page the first page?

Specified by:
isFirstPage in interface PaginatedList

isMiddlePage

public boolean isMiddlePage()
Description copied from interface: PaginatedList
Is the current page a middle page (i.e. not first or last)?

Specified by:
isMiddlePage in interface PaginatedList

isLastPage

public boolean isLastPage()
Description copied from interface: PaginatedList
Is the current page the last page?

Specified by:
isLastPage in interface PaginatedList

isNextPageAvailable

public boolean isNextPageAvailable()
Description copied from interface: PaginatedList
Is a page available after the current page?

Specified by:
isNextPageAvailable in interface PaginatedList

isPreviousPageAvailable

public boolean isPreviousPageAvailable()
Description copied from interface: PaginatedList
Is a page available before the current page?

Specified by:
isPreviousPageAvailable in interface PaginatedList

nextPage

public boolean nextPage()
Description copied from interface: PaginatedList
Moves to the next page after the current page. If the current page is the last page, wrap to the first page.

Specified by:
nextPage in interface PaginatedList

previousPage

public boolean previousPage()
Description copied from interface: PaginatedList
Moves to the page before the current page. If the current page is the first page, wrap to the last page.

Specified by:
previousPage in interface PaginatedList

gotoPage

public void gotoPage(int pageNumber)
Description copied from interface: PaginatedList
Moves to a specified page. If the specified page is beyond the last page, wrap to the first page. If the specified page is before the first page, wrap to the last page.

Specified by:
gotoPage in interface PaginatedList

getPageIndex

public int getPageIndex()
Description copied from interface: PaginatedList
Returns the current page index, which is a zero based integer. All paginated list implementations should know what index they are on, even if they don't know the ultimate boundaries (min/max).

Specified by:
getPageIndex in interface PaginatedList