//13年写的,今天(17)拷贝到博客园
packagecom.sicdt.sicsign.web.utils;importjava.io.Serializable;importjava.util.List;/***@authorshizhenwei
*
*@param用于向前台返还List所用*/
public class PageInfo implementsSerializable {private static final long serialVersionUID = 1L;//每页显示的记录数
privateInteger pageSize;//当前页码数
privateInteger pageNum;//总记录数
privateInteger rowCount;//总页码数
privateInteger pageCount;//查询的时候从多少记录开始
privateInteger rowStart;//每页显示多少页码
privateInteger everyPageTabsCount;//每页显示的开始页码数
privateInteger everyPageStart;//每页显示的结束页码数
privateInteger everyPageEnd;//是否有上一页
private boolean hasPrevious = false;//首页
privateInteger firstPageNum;//上一页
privateInteger priviousPageNum;//是否有下一页
private boolean hasNext = false;//下一页
privateInteger nextPageNum;//尾页
privateInteger endPageNum;//存放本次分页查询出来的数据
private Listlist;/*** 通过构造器计算出其他属性的值
*@parampageSize
*@parampageNum
*@paramrowCount*/
publicPageInfo(Integer pageNum,Integer pageSize,Integer rowCount,Integer everyPageTabsCount) {//每页显示的记录数
this.pageSize = pageSize == null ? 10: pageSize;//当前页码数
this.pageNum = pageNum == null ? 1: pageNum;//总记录数
this.rowCount = rowCount == null ? 0: rowCount;//每页显示多少页码 默认10,可以set
this.everyPageTabsCount = everyPageTabsCount == null ? 10: everyPageTabsCount;//总页码数
this.pageCount = (int) Math.ceil(this.rowCount * 1.0 / this.pageSize);//判断当前页码数是否大于总页码数
if (this.pageNum > this.pageCount && this.pageCount >= 1) {this.pageNum = this.pageCount;
}//查询的时候从多少记录开始
this.rowStart = (this.pageNum - 1) * this.pageSize;//每页显示的开始页码数
this.everyPageStart = (this.pageNum - this.everyPageTabsCount / 2) > 0 ? (this.pageNum - this.everyPageTabsCount / 2) : 1;/***** 无论从第几页开始都会以固定的页数进行显示,当总页数小于固定页数,将全部显示总页数****/
int cenNum = (int) Math.ceil((this.everyPageTabsCount / 2.0));if(this.pageCount>=this.everyPageTabsCount && this.pageNum<=(this.everyPageTabsCount / 2)){this.everyPageEnd = this.everyPageTabsCount;
}else if(this.pageCount<=this.everyPageTabsCount){this.everyPageEnd = this.pageCount;
}else{//每页显示的结束页码数
this.everyPageEnd = (this.pageNum + cenNum - 1) > this.pageCount ? this.pageCount : (this.pageNum + cenNum - 1);
}if(this.pageCount>=this.everyPageTabsCount && this.pageNum>(this.pageCount-(cenNum - 1))){this.everyPageStart=this.pageCount-(this.everyPageTabsCount-1);
}//是否有上一页
if (this.pageNum > 1) {this.hasPrevious = true;this.firstPageNum = 1;this.priviousPageNum = this.pageNum - 1;
}//是否有下一页
if (this.pageNum < this.pageCount) {this.hasNext = true;this.nextPageNum = this.pageNum + 1;this.endPageNum = this.pageCount;
}
}publicInteger getPageSize() {returnpageSize;
}publicInteger getPageNum() {returnpageNum;
}publicInteger getRowCount() {returnrowCount;
}publicInteger getPageCount() {returnpageCount;
}publicInteger getRowStart() {returnrowStart;
}publicInteger getEveryPageStart() {returneveryPageStart;
}publicInteger getEveryPageEnd() {returneveryPageEnd;
}public booleanisHasPrevious() {returnhasPrevious;
}publicInteger getFirstPageNum() {returnfirstPageNum;
}publicInteger getPriviousPageNum() {returnpriviousPageNum;
}public booleanisHasNext() {returnhasNext;
}publicInteger getNextPageNum() {returnnextPageNum;
}publicInteger getEndPageNum() {returnendPageNum;
}public ListgetList() {returnlist;
}public void setList(Listlist) {this.list =list;
}publicInteger getEveryPageTabsCount() {returneveryPageTabsCount;
}public voidsetEveryPageTabsCount(Integer everyPageTabsCount) {this.everyPageTabsCount =everyPageTabsCount;
}
}