package com.utils;
import java.util.List;
/**
* 分页实体类,保存当前分页状态变量
*
* @author
*/
public class Page {
// 总行数
private int rowCount;
// 总页数
private int pageCount;
// 每页有多少行
private int rowsPrePage=10;
// 当前是第几页
private int curPage;
// 每页的开始记录
private int beginIndex;
// 是否有上页
private boolean hasPrePage;
// 是否有下页
private boolean hasNextPage;
//保存查询记录
private List list;
public List getList() {
return list;
}
public void setList(List list) {
this.list = list;
}
public Page() {
}
public Page(int curPage) {
this.curPage = curPage;
}
/*
* rows:总行数pageRows:每页行数
*/
public void Init(int rows,int curPage) {
Init(rows, 10, curPage);
}
public void Init(int rows, int pageRows,int curPage) {
// 如果未设置当前页,默认为第一页
if (curPage < 0 || curPage == 0) {
curPage = 1;
}
// 得到总页数
this.pageCount = rows / pageRows;
if ((rows % pageRows) > 0) {
this.pageCount += 1;
}
if (curPage > this.pageCount) {
curPage = 1;
}
// 是否有上页
if (this.curPage == 1) {
this.hasPrePage = false;
}
// 是否有下页
if (this.curPage == this.pageCount) {
this.hasNextPage = false;
}
this.rowCount = rows;
this.rowsPrePage = pageRows;
this.beginIndex = (curPage - 1) * this.rowsPrePage;
this.curPage = curPage;
}
public Page(int rowCount, int pageCount, int rowsPrePage, int curPage,
int beginIndex, boolean hasPrePage, boolean hasNextPage) {
this.rowCount = rowCount;
this.pageCount = pageCount;
this.rowsPrePage = rowsPrePage;
this.beginIndex = beginIndex;
this.curPage = curPage;
this.hasNextPage = hasNextPage;
this.hasPrePage = hasNextPage;
}
public int getRowCount() {
return rowCount;
}
public void setRowCount(int rowCount) {
this.rowCount = rowCount;
}
public int getPageCount() {
return pageCount;
}
public void setPageCount(int pageCount) {
this.pageCount = pageCount;
}
public int getRowsPrePage() {
return rowsPrePage;
}
public void setRowsPrePage(int rowsPrePage) {
this.rowsPrePage = rowsPrePage;
}
public int getCurPage() {
return curPage;
}
public void setCurPage(int curPage) {
this.curPage = curPage;
}
public int getBeginIndex() {
return beginIndex;
}
public void setBeginIndex(int beginIndex) {
this.beginIndex = beginIndex;
}
public boolean isHasPrePage() {
return hasPrePage;
}
public void setHasPrePage(boolean hasPrePage) {
this.hasPrePage = hasPrePage;
}
public boolean isHasNextPage() {
return hasNextPage;
}
public void setHasNextPage(boolean hasNextPage) {
this.hasNextPage = hasNextPage;
}
}
import java.util.List;
/**
* 分页实体类,保存当前分页状态变量
*
* @author
*/
public class Page {
// 总行数
private int rowCount;
// 总页数
private int pageCount;
// 每页有多少行
private int rowsPrePage=10;
// 当前是第几页
private int curPage;
// 每页的开始记录
private int beginIndex;
// 是否有上页
private boolean hasPrePage;
// 是否有下页
private boolean hasNextPage;
//保存查询记录
private List list;
public List getList() {
return list;
}
public void setList(List list) {
this.list = list;
}
public Page() {
}
public Page(int curPage) {
this.curPage = curPage;
}
/*
* rows:总行数pageRows:每页行数
*/
public void Init(int rows,int curPage) {
Init(rows, 10, curPage);
}
public void Init(int rows, int pageRows,int curPage) {
// 如果未设置当前页,默认为第一页
if (curPage < 0 || curPage == 0) {
curPage = 1;
}
// 得到总页数
this.pageCount = rows / pageRows;
if ((rows % pageRows) > 0) {
this.pageCount += 1;
}
if (curPage > this.pageCount) {
curPage = 1;
}
// 是否有上页
if (this.curPage == 1) {
this.hasPrePage = false;
}
// 是否有下页
if (this.curPage == this.pageCount) {
this.hasNextPage = false;
}
this.rowCount = rows;
this.rowsPrePage = pageRows;
this.beginIndex = (curPage - 1) * this.rowsPrePage;
this.curPage = curPage;
}
public Page(int rowCount, int pageCount, int rowsPrePage, int curPage,
int beginIndex, boolean hasPrePage, boolean hasNextPage) {
this.rowCount = rowCount;
this.pageCount = pageCount;
this.rowsPrePage = rowsPrePage;
this.beginIndex = beginIndex;
this.curPage = curPage;
this.hasNextPage = hasNextPage;
this.hasPrePage = hasNextPage;
}
public int getRowCount() {
return rowCount;
}
public void setRowCount(int rowCount) {
this.rowCount = rowCount;
}
public int getPageCount() {
return pageCount;
}
public void setPageCount(int pageCount) {
this.pageCount = pageCount;
}
public int getRowsPrePage() {
return rowsPrePage;
}
public void setRowsPrePage(int rowsPrePage) {
this.rowsPrePage = rowsPrePage;
}
public int getCurPage() {
return curPage;
}
public void setCurPage(int curPage) {
this.curPage = curPage;
}
public int getBeginIndex() {
return beginIndex;
}
public void setBeginIndex(int beginIndex) {
this.beginIndex = beginIndex;
}
public boolean isHasPrePage() {
return hasPrePage;
}
public void setHasPrePage(boolean hasPrePage) {
this.hasPrePage = hasPrePage;
}
public boolean isHasNextPage() {
return hasNextPage;
}
public void setHasNextPage(boolean hasNextPage) {
this.hasNextPage = hasNextPage;
}
}