org.nuiton.util
Class PagerUtil

java.lang.Object
  extended by org.nuiton.util.PagerUtil

public class PagerUtil
extends Object

Common methods to deal with a pager.

Since:
2.4
Author:
tchemit

Constructor Summary
PagerUtil()
           
 
Method Summary
static
<E> List<E>
getPage(List<E> elements, int page, int pageSize)
          Get the elements of the lists using the pager datas:

elements:all elements of the pager pageSize: number of elements in a page page: the requested page number starting at 1

static org.apache.commons.lang3.tuple.Pair<Integer,Integer> getPageBound(int totalCount, int page, int pageSize)
          Compute the pager bound given his datas: totalCount: count of all elements of the pager pageSize: number of elements in a page page: the requested page number starting at 1
static int getTotalPage(int totalCount, int pageSize)
          Given a total count of elements and a page size, compute the number of pages available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PagerUtil

public PagerUtil()
Method Detail

getTotalPage

public static int getTotalPage(int totalCount,
                               int pageSize)
Given a total count of elements and a page size, compute the number of pages available.

Parameters:
totalCount - total count of elements in the pager
pageSize - size of a page
Returns:
the number of available pages

getPageBound

public static org.apache.commons.lang3.tuple.Pair<Integer,Integer> getPageBound(int totalCount,
                                                                                int page,
                                                                                int pageSize)
Compute the pager bound given his datas:

Parameters:
totalCount - total count of elements in the pager
page - pager page number (starting at 1)
pageSize - number of elements in a page
Returns:
the bound of start and end index of the requested elements of the pager

getPage

public static <E> List<E> getPage(List<E> elements,
                                  int page,
                                  int pageSize)
Get the elements of the lists using the pager datas:

Type Parameters:
E - n'importe quel type
Parameters:
elements - all pager elements
page - pager page number (starting at 1)
pageSize - number of elements in a page
Returns:
la liste une fois filtrée


Copyright © 2004-2012 CodeLutin. All Rights Reserved.