随笔的一个记录。
有两个参考类,
Java代码
importjava.util.List;
/**
* 分页显示对象
* @param
*/
publicclassPageView {
/** 分页数据 **/
privateList records;
/** 页码开始索引和结束索引 **/
privatePageIndex pageindex;
/** 总页数 **/
privatelongtotalpage =1;
/** 每页显示记录数 **/
privateintmaxresult =12;
/** 当前页 **/
privateintcurrentpage =1;
/** 总记录数 **/
privatelongtotalrecord;
/** 页码数量 **/
privateintpagecode =10;
/** 要获取记录的开始索引 **/
publicintgetFirstResult() {
return(this.currentpage-1) *this.maxresult;
}
publicintgetPagecode() {
returnpagecode;
}
publicvoidsetPagecode(intpagecode) {
this.pagecode = pagecode;
}
publicPageView(intmaxresult,intcurrentpage) {
this.maxresult = maxresult;
this.currentpage = currentpage;
}
publicvoidsetQueryResult(QueryResult qr){
setTotalrecord(qr.getTotal());
setRecords(qr.getResultList());
}
publiclonggetTotalrecord() {
returntotalrecord;
}
publicvoidsetTotalrecord(longtotalrecord) {
this.totalrecord = totalrecord;
setTotalpage(this.totalrecord %this.maxresult ==0?this.totalrecord /this.maxresult :this.totalrecord /this.maxresult +1);
}
publicList getRecords() {