info.joseluismartin.dao
Class Page<T>

java.lang.Object
  extended by info.joseluismartin.dao.Page<T>
All Implemented Interfaces:
Paginator, Serializable, Cloneable

public class Page<T>
extends Object
implements Paginator, Cloneable, Serializable

A Page of Objects as result of query on PaginableDataSource Holds results for a page and info of Page definition page size and order.

Author:
Jose Luis Martin - (jlm@joseluismartin.info)
See Also:
Serialized Form

Nested Class Summary
static class Page.Order
           
 
Constructor Summary
Page()
           
Page(int pageSize)
           
Page(int pageSize, int page)
           
Page(int pageSize, int page, String sortName)
           
Page(int pageSize, int page, String sortName, Page.Order order)
           
 
Method Summary
 void addPaginatorListener(PaginatorListener listener)
          Add a PaginatorListner
 Page<T> clone()
           
 void firstPage()
          Go to first page
 int getCount()
           
 List<T> getData()
           
 Object getFilter()
           
 Page.Order getOrder()
           
 int getPage()
          Gets the current page number
 PageableDataSource<T> getPageableDataSource()
           
 int getPageSize()
          get the page size, ie the number of records in one page
 String getSortName()
           
 int getStartIndex()
          get the startIndex, ie the number of the first record of this page
 int getTotalPages()
          
 boolean hasNext()
          
 boolean hasPage(int indexPage)
          
 boolean hasPrevious()
          
 void lastPage()
          Go to last page
 void load()
           
 void nextPage()
          Go to next page
 void previousPage()
          Go to previous page
 void removePaginatorListener(PaginatorListener listener)
          Remove a PaginatorListener
 void setCount(int count)
          set the number of total records, ie the number of records in all pages
 void setData(List<T> data)
           
 void setFilter(Object filter)
           
 void setOrder(Page.Order order)
           
 void setOrderAsc()
           
 void setOrderDesc()
           
 void setPage(int indexPage)
          set the page number to index page if possible
 void setPageableDataSource(PageableDataSource<T> pageableDataSource)
           
 void setPageSize(int pageSize)
          Set the page size, ie, the number of records in one page
 void setSortName(String sortName)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Page

public Page(int pageSize,
            int page,
            String sortName,
            Page.Order order)

Page

public Page(int pageSize,
            int page,
            String sortName)

Page

public Page(int pageSize,
            int page)

Page

public Page(int pageSize)

Page

public Page()
Method Detail

getData

public List<T> getData()
Returns:
list of data objects

getCount

public int getCount()
Specified by:
getCount in interface Paginator
Returns:
the count

setCount

public void setCount(int count)
Description copied from interface: Paginator
set the number of total records, ie the number of records in all pages

Specified by:
setCount in interface Paginator
Parameters:
count - the count to set

getSortName

public String getSortName()
Returns:
the sortName

setSortName

public void setSortName(String sortName)
Parameters:
sortName - the sortName to set

getOrder

public Page.Order getOrder()
Returns:
the order

setOrder

public void setOrder(Page.Order order)
Parameters:
order - the order to set

setData

public void setData(List<T> data)
Parameters:
data - the data to set

setOrderAsc

public void setOrderAsc()

setOrderDesc

public void setOrderDesc()

getFilter

public Object getFilter()
Returns:
the filter

setFilter

public void setFilter(Object filter)
Parameters:
filter - the filter to set

clone

public Page<T> clone()
Overrides:
clone in class Object

getPageableDataSource

public PageableDataSource<T> getPageableDataSource()
Returns:
the pageableDataSource

hasNext

public boolean hasNext()

Specified by:
hasNext in interface Paginator
Returns:
true if there is records on next page
See Also:
Paginator.hasNext()

hasPage

public boolean hasPage(int indexPage)

Specified by:
hasPage in interface Paginator
Returns:
true if there is records on index page
See Also:
Paginator.hasPage(int)

hasPrevious

public boolean hasPrevious()

Specified by:
hasPrevious in interface Paginator
Returns:
true if there is records on previews page

setPage

public void setPage(int indexPage)
set the page number to index page if possible

Specified by:
setPage in interface Paginator
Parameters:
indexPage - the new page number
See Also:
Paginator.setPage(int)

getStartIndex

public int getStartIndex()
get the startIndex, ie the number of the first record of this page

Specified by:
getStartIndex in interface Paginator
Returns:
the start index

getTotalPages

public int getTotalPages()

Specified by:
getTotalPages in interface Paginator
Returns:
the number of pages
See Also:
Paginator.getTotalPages()

addPaginatorListener

public void addPaginatorListener(PaginatorListener listener)
Add a PaginatorListner

Specified by:
addPaginatorListener in interface Paginator
Parameters:
listener - the PaginatorListener to add

removePaginatorListener

public void removePaginatorListener(PaginatorListener listener)
Remove a PaginatorListener

Specified by:
removePaginatorListener in interface Paginator
Parameters:
listener - the PaginatorListener to remove

getPageSize

public int getPageSize()
Description copied from interface: Paginator
get the page size, ie the number of records in one page

Specified by:
getPageSize in interface Paginator
Returns:
the pageSize

setPageSize

public void setPageSize(int pageSize)
Description copied from interface: Paginator
Set the page size, ie, the number of records in one page

Specified by:
setPageSize in interface Paginator
Parameters:
pageSize - the pageSize to set

getPage

public int getPage()
Description copied from interface: Paginator
Gets the current page number

Specified by:
getPage in interface Paginator
Returns:
the page

firstPage

public void firstPage()
Go to first page

Specified by:
firstPage in interface Paginator
See Also:
Paginator.firstPage()

lastPage

public void lastPage()
Go to last page

Specified by:
lastPage in interface Paginator
See Also:
Paginator.lastPage()

nextPage

public void nextPage()
Go to next page

Specified by:
nextPage in interface Paginator
See Also:
Paginator.nextPage()

previousPage

public void previousPage()
Go to previous page

Specified by:
previousPage in interface Paginator
See Also:
Paginator.previousPage()

load

public void load()

setPageableDataSource

public void setPageableDataSource(PageableDataSource<T> pageableDataSource)
Parameters:
pageableDataSource - the pageableDataSource to set


Copyright © 2012 JDAL. All Rights Reserved.