Public class pagesplit {
Int page = 1; // request to display the page
Int COUNT = 1; // The total number of records.
Int currentpage = 1; // The currentpage is displayed.
Int pagecount = 1; // total number of pages
Int rows = 1; // number of lines displayed per page
List list = NULL;
/**
* Constructor 1
*
* @ Param list: list object for paging
*/
Public pagesplit (list ){
Super ();
This. List = List;
}
/**
* Constructor 2
*
* @ Param rows
* Number of lines displayed per page
* @ Param list
* List objects to be paged
*/
Public pagesplit (INT rows, list ){
Super ();
This. rows = rows;
This. List = List;
}
/**
* Return all content on the page. The result is still in list type.
*
* @ Param page: returns the content of the page.
* @ Return
*/
Public list currentlist (INT page ){
This. Page = page;
Currentpage = page;
Count = List. Size ();
Pagecount = (count + rows-1)/rows; // displays the number of rows based on the total number of records.
/* If the request page is smaller than 1, make the current page count equal to 1 */
If (currentpage <1 ){
Currentpage = 1;
}
/* If the number of request pages is greater than the total number of pages, set the current number of pages to the total number of pages */
If (currentpage> pagecount ){
Currentpage = pagecount;
}
List newlist;
/* Not full page */
If (currentpage-1) * Rows) + rows)> count ){
Return newlist = List. sublist (currentpage-1) * Rows, count );
}
/* The page is full */
Else {
Return newlist = List. sublist (currentpage-1) * Rows,
(Currentpage-1) * Rows) + rows );
}
}
Public int getpage (){
Return page;
}
Public void setpage (INT page ){
This. Page = page;
}
Public int getcount (){
Return count;
}
Public void setcount (INT count ){
This. Count = count;
}
Public int getcurrentpage (){
Return currentpage;
}
Public void setcurrentpage (INT currentpage ){
This. currentpage = currentpage;
}
Public int getpagecount (){
Return pagecount;
}
Public void setpagecount (INT pagecount ){
This. pagecount = pagecount;
}
Public int getrows (){
Return rows;
}
Public void setrows (INT rows ){
This. rows = rows;
}
}