import java.util.List;
public class PageBean<T> {
private int pageSize;
private int currentPage;
private int totalPage;
private int startIndex;
private int totalRecords;
private List<T> beanList;
private int startPage;
private int endPage;
public PageBean(int currentPage,int totalRecords,int pageSize){
this.currentPage=currentPage;
this.totalRecords=totalRecords;
this.pageSize=pageSize;
startIndex=(currentPage-1)*pageSize;
totalPage=(int) Math.ceil(totalRecords*1.0/pageSize);
if(totalPage<=9){
startPage=1;
endPage=totalPage;
}else{
startPage=currentPage-4;
endPage=currentPage+4;
if(startPage<1){
startPage=1;
endPage=9;
}
if(endPage>totalPage){
startPage=totalPage-8;
endPage=totalPage;
}
}
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getCurrentPage() {
return currentPage;
}
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public int getStartIndex() {
return startIndex;
}
public void setStartIndex(int startIndex) {
this.startIndex = startIndex;
}
public int getTotalRecords() {
return totalRecords;
}
public void setTotalRecords(int totalRecords) {
this.totalRecords = totalRecords;
}
public List<T> getBeanList() {
return beanList;
}
public void setBeanList(List<T> beanList) {
this.beanList = beanList;
}
public int getStartPage() {
return startPage;
}
public void setStartPage(int startPage) {
this.startPage = startPage;
}
public int getEndPage() {
return endPage;
}
public void setEndPage(int endPage) {
this.endPage = endPage;
}
}
|