package com.supermarket.util;
import java.util.List;
public class PageUtil {
// public static final Integer ROWS_OF_PAGE=10;
private Integer num_of_page;
private List pageList;
private Integer pages;
private Integer pagenum;
public PageUtil(List list, Integer pagenum, Integer num_of_page) {
this.num_of_page = num_of_page;
if (list.size() % num_of_page == 0) {
pages = list.size() / num_of_page;
} else {
pages = list.size() / num_of_page + 1;
}
if (pagenum > pages) {
this.pagenum = 1;
} else {
this.pagenum = pagenum;
}
if (list.size() == 0) {
this.pageList = null;
return;
}
if (this.pagenum == pages) {
this.pageList = list.subList((this.pagenum - 1) * num_of_page, list.size());
return;
}
this.pageList = list.subList((this.pagenum - 1) * num_of_page, this.pagenum * num_of_page);
}
public List getPageList() {
return pageList;
}
public void setPageList(List pageList) {
this.pageList = pageList;
}
public Integer getPages() {
return pages;
}
public void setPages(Integer pages) {
this.pages = pages;
}
public Integer getPagenum() {
return pagenum;
}
public void setPagenum(Integer pagenum) {
this.pagenum = pagenum;
}
}