package www.csdn.net.news.util;
public class Pagination {
// 分页的封装
private int pageSize;
private int countPage;
private int nowPage;
private int startIndex = 0;
public Pagination(int countPage, int nowPage,int pageSize) {
this.pageSize=pageSize;
this.countPage = countPage;
this.nowPage = nowPage;
init();
}
private void init() {
// 判断当前页是否合法
if (nowPage <= 1) {
this.nowPage = 1;
} else if (nowPage >= countPage) {
this.nowPage = countPage;
} else {
this.nowPage = nowPage;
}
this.startIndex = (this.nowPage - 1) * pageSize;
}
public int getNowPage() {
return nowPage;
}
public void setNowPage(int nowPage) {
this.nowPage = nowPage;
init();
}
public int getPageSize() {
return pageSize;
}
public int getCountPage() {
return countPage;
}
public int getStartIndex() {
return startIndex;
}
}