/**
* <p>
* Title:Page.java
* </p>
* <p>
* @version 1.0
*/
package cn.surveystore.common.util;
import java.io.Serializable;
public class Page implements Serializable {
/**
*
*/
private static final long serialVersionUID = -8756311063389960015L;
/**
* 当前页数
*/
private int pageNow;
/**
* 每页显示记录的条数
*/
private int pageSize;
/**
* 总记录数
*/
private int totalCount;
/**
* 总页数
*/
private int totalPageCount;
/**
* 跳转url
*/
private String url;
/**
* 通过构造函数 传入 总记录数 和 当前页
*
* @param totalCount
* @param pageNow
*/
public Page(int totalCount, int pageNow, int pageSize, String url) {
this.totalCount = totalCount;
this.pageNow = pageNow;
this.pageSize = pageSize;
this.url = url;
}
/**
* 取得选择记录的初始位置
*
* @return
*/
public int getStartPos() {
return (pageNow - 1) * pageSize;
}
/**
* @return the pageNow
*/
public int getPageNow() {
return pageNow;
}
/**
* @param pageNow
* the pageNow to set
*/
public void setPageNow(int pageNow) {
this.pageNow = pageNow;
}
/**
* @return the pageSize
*/
public int getPageSize() {
return pageSize;
}
/**
* @param pageSize
* the pageSize to set
*/
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
/**
* @return the totalCount
*/
public int getTotalCount() {
return totalCount;
}
/**
* @param totalCount
* the totalCount to set
*/
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
/**
* 总页数,总页数=总记录数/总页数
*
* @return the totalPageCount
*/
public int getTotalPageCount() {
totalPageCount = getTotalCount() / getPageSize();
return (totalCount % pageSize == 0) ? totalPageCount
: totalPageCount + 1;
}
/**
* @param totalPageCount
* the totalPageCount to set
*/
public void setTotalPageCount(int totalPageCount) {
this.totalPageCount = totalPageCount;
}
/**
* @return the url
*/
public String getUrl() {
return url;
}
/**
* @param url
* the url to set
*/
public void setUrl(String url) {
this.url = url;
}
/**
* 是否是第一页
*
* @return
*/
public boolean isHasFirst() {
return (pageNow == 1) ? false : true;
}
/**
* 是否有首页
*
* @return
*/
public boolean isHasPre() {
return isHasFirst() ? true : false;
}
/**
* 是否有下一页
*
* @return
*/
public boolean isHasNext() {
return isHasLast() ? true : false;
}
/**
* 是否有尾页
*
* @return
*/
public boolean isHasLast() {
return (pageNow == getTotalCount()) ? false : true;
}
}
Page类
最新推荐文章于 2024-08-04 18:08:30 发布