org.gvsig.tools.paging
Class DefaultPagingCalculator

java.lang.Object
  extended by org.gvsig.tools.paging.DefaultPagingCalculator
All Implemented Interfaces:
PagingCalculator

public class DefaultPagingCalculator
extends Object
implements PagingCalculator

Default PagingCalculator implementation.

Author:
gvSIG team

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.gvsig.tools.paging.PagingCalculator
PagingCalculator.Sizeable
 
Field Summary
 
Fields inherited from interface org.gvsig.tools.paging.PagingCalculator
DEFAULT_PAGE_SIZE
 
Constructor Summary
DefaultPagingCalculator(PagingCalculator.Sizeable sizeable)
          Creates a new DefaultPagingCalculator, with the default page size (PagingCalculator.DEFAULT_PAGE_SIZE), setting the current page to the first one.
DefaultPagingCalculator(PagingCalculator.Sizeable sizeable, int maxPageSize)
          Creates a new DefaultPagingCalculator, setting the current page to the first one.
DefaultPagingCalculator(PagingCalculator.Sizeable sizeable, int maxPageSize, long currentPage)
          Creates a new DefaultPagingCalculator .
 
Method Summary
 long getCurrentPage()
          Returns the number of the currently loaded page of data (zero based).
 int getCurrentPageSize()
          Returns the number of elements of the current page.
 long getInitialIndex()
          Returns the index of the initial element of the current page into all the elements.
protected  long getLastIndex()
           
 int getMaxPageSize()
          Returns the current maximum number of values per page.
 long getNumPages()
          Returns the number of pages available, calculated with the total number of elements and the maximum number of elements per page.
 long getTotalSize()
          Returns the number of elements of the entire set of data.
 void setCurrentPage(long currentPage)
          Sets the current page number (zero based), and loads the elements for that page.
 void setMaxPageSize(int maxPageSize)
          Sets the current maximum number of elements per page.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultPagingCalculator

public DefaultPagingCalculator(PagingCalculator.Sizeable sizeable)
Creates a new DefaultPagingCalculator, with the default page size (PagingCalculator.DEFAULT_PAGE_SIZE), setting the current page to the first one.


DefaultPagingCalculator

public DefaultPagingCalculator(PagingCalculator.Sizeable sizeable,
                               int maxPageSize)
Creates a new DefaultPagingCalculator, setting the current page to the first one.

Parameters:
maxPageSize - the maximum page size

DefaultPagingCalculator

public DefaultPagingCalculator(PagingCalculator.Sizeable sizeable,
                               int maxPageSize,
                               long currentPage)
Creates a new DefaultPagingCalculator .

Parameters:
maxPageSize - the maximum page size
currentPage - the current page
Method Detail

getMaxPageSize

public int getMaxPageSize()
Description copied from interface: PagingCalculator
Returns the current maximum number of values per page.

Specified by:
getMaxPageSize in interface PagingCalculator
Returns:
the current maximum page size

setMaxPageSize

public void setMaxPageSize(int maxPageSize)
Description copied from interface: PagingCalculator
Sets the current maximum number of elements per page. As the page size changes, the current page of data is reloaded. All pages, but maybe the last one, will have this number of elements.

Specified by:
setMaxPageSize in interface PagingCalculator
Parameters:
maxPageSize - the maximum number of values per page

getCurrentPage

public long getCurrentPage()
Description copied from interface: PagingCalculator
Returns the number of the currently loaded page of data (zero based).

Specified by:
getCurrentPage in interface PagingCalculator
Returns:
the current page number

setCurrentPage

public void setCurrentPage(long currentPage)
Description copied from interface: PagingCalculator
Sets the current page number (zero based), and loads the elements for that page.

Specified by:
setCurrentPage in interface PagingCalculator
Parameters:
currentPage - the page to load

getInitialIndex

public long getInitialIndex()
Description copied from interface: PagingCalculator
Returns the index of the initial element of the current page into all the elements.

Specified by:
getInitialIndex in interface PagingCalculator
Returns:
the index of the initial element

getLastIndex

protected long getLastIndex()

getNumPages

public long getNumPages()
Description copied from interface: PagingCalculator
Returns the number of pages available, calculated with the total number of elements and the maximum number of elements per page.

Specified by:
getNumPages in interface PagingCalculator
Returns:
the number of pages available

getCurrentPageSize

public int getCurrentPageSize()
Description copied from interface: PagingCalculator
Returns the number of elements of the current page. All the pages, but maybe the last one, will have the maximum number of elements per page.

Specified by:
getCurrentPageSize in interface PagingCalculator
Returns:
the current page size

getTotalSize

public long getTotalSize()
Description copied from interface: PagingCalculator
Returns the number of elements of the entire set of data.

Specified by:
getTotalSize in interface PagingCalculator
Returns:
the number of elements


Copyright © 2004-2011 gvSIG. All Rights Reserved.