com.ibatis.common.util
Class PaginatedArrayList

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

public class PaginatedArrayList
extends java.lang.Object
implements PaginatedList

Implementation of PaginatedList backed by an ArrayList


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)
           
 boolean add(java.lang.Object o)
           
 boolean addAll(java.util.Collection c)
           
 boolean addAll(int index, java.util.Collection c)
           
 void clear()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection c)
           
 java.lang.Object get(int index)
           
 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)
           
 boolean isEmpty()
           
 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 (ie not first or last)?
 boolean isNextPageAvailable()
          Is a page available after the current page?
 boolean isPreviousPageAvailable()
          Is a page available before the current page?
 java.util.Iterator iterator()
           
 int lastIndexOf(java.lang.Object o)
           
 java.util.ListIterator listIterator()
           
 java.util.ListIterator listIterator(int index)
           
 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)
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection c)
           
 boolean retainAll(java.util.Collection c)
           
 java.lang.Object set(int index, java.lang.Object element)
           
 int size()
           
 java.util.List subList(int fromIndex, int toIndex)
           
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] a)
           
 
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
 

Constructor Detail

PaginatedArrayList

public PaginatedArrayList(int pageSize)
Parameters:
pageSize -

PaginatedArrayList

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

Parameters:
initialCapacity - - the initial size
pageSize - - the page size

PaginatedArrayList

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

Parameters:
c - - the collection to build the instance with
pageSize - - the page size
Method Detail

size

public int size()
Specified by:
size in interface java.util.List

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.List

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.List

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface java.util.List

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.List

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Specified by:
toArray in interface java.util.List

containsAll

public boolean containsAll(java.util.Collection c)
Specified by:
containsAll in interface java.util.List

get

public java.lang.Object get(int index)
Specified by:
get in interface java.util.List

indexOf

public int indexOf(java.lang.Object o)
Specified by:
indexOf in interface java.util.List

lastIndexOf

public int lastIndexOf(java.lang.Object o)
Specified by:
lastIndexOf in interface java.util.List

listIterator

public java.util.ListIterator listIterator()
Specified by:
listIterator in interface java.util.List

listIterator

public java.util.ListIterator listIterator(int index)
Specified by:
listIterator in interface java.util.List

subList

public java.util.List subList(int fromIndex,
                              int toIndex)
Specified by:
subList in interface java.util.List

add

public boolean add(java.lang.Object o)
Specified by:
add in interface java.util.List

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.List

addAll

public boolean addAll(java.util.Collection c)
Specified by:
addAll in interface java.util.List

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Specified by:
addAll in interface java.util.List

removeAll

public boolean removeAll(java.util.Collection c)
Specified by:
removeAll in interface java.util.List

retainAll

public boolean retainAll(java.util.Collection c)
Specified by:
retainAll in interface java.util.List

clear

public void clear()
Specified by:
clear in interface java.util.List

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Specified by:
set in interface java.util.List

add

public void add(int index,
                java.lang.Object element)
Specified by:
add in interface java.util.List

remove

public java.lang.Object remove(int index)
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
Returns:
The maximum number of items per page.

isFirstPage

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

Specified by:
isFirstPage in interface PaginatedList
Returns:
True if the current page is the first page or if only a single page exists.

isMiddlePage

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

Specified by:
isMiddlePage in interface PaginatedList
Returns:
True if the current page is not the first or last page, and more than one page exists (always returns false if only a single page exists).

isLastPage

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

Specified by:
isLastPage in interface PaginatedList
Returns:
True if the current page is the last page or if only a single page exists.

isNextPageAvailable

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

Specified by:
isNextPageAvailable in interface PaginatedList
Returns:
True if the next page is available

isPreviousPageAvailable

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

Specified by:
isPreviousPageAvailable in interface PaginatedList
Returns:
True if the previous page is available

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
Returns:
True if the page changed

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
Returns:
True if the page changed

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
Parameters:
pageNumber - The page to go to

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
Returns:
The current page