package com.mrjava.dvpms.commons;
import java.util.List;
/**
* 分页表
* @author 李易烜-修改
* 2009-6-17
*/
public class PaginationTable {
private List> entryList;//> 数据
private int totalNumOfRows;// 总行数
private int rowsPerPage = 10;// 每页行数
private int beginIndex = 0;//---> 当前页起始行
private int endIndex;//-----> 终止页
private int pageIndex;//----> 当前页
private int pageCount;//----> 总页数
/** 分页计算-重载1() */
public PaginationTable(){ }
/** 分页计算-重载2(总行数, 终止页) */
public PaginationTable(int totalNumOfRows, int pageIndex) {
//super();
if(pageIndex<=0){
pageIndex=1;
}
this.totalNumOfRows = totalNumOfRows;
if(totalNumOfRows%rowsPerPage==0){
this.pageCount = this.totalNumOfRows/rowsPerPage;
}else {
this.pageCount = this.totalNumOfRows/rowsPerPage+1;
}
if(pageIndex > pageCount){
pageIndex = pageCount;
}
this.pageIndex = pageIndex;
if(totalNumOfRows > 0){
this.beginIndex = (pageIndex-1)*rowsPerPage;
}
this.endIndex = pageIndex*rowsPerPage;
endIndex = endIndex>this.totalNumOfRows ? this.totalNumOfRows : endIndex;
}
/** 分页计算-重载3(每页行数, 总行数, 终止页) */
public PaginationTable(int rowsPerPage, int totalNumOfRows, int pageIndex) {
//super();
this.rowsPerPage = rowsPerPage;
if(pageIndex<=0){
pageIndex=1;
}
this.totalNumOfRows = totalNumOfRows;
if(totalNumOfRows%rowsPerPage==0){
this.pageCount = this.totalNumOfRows/rowsPerPage;
}else {
this.pageCount = this.totalNumOfRows/rowsPerPage+1;
}
if(pageIndex > pageCount){
pageIndex = pageCount;
}
this.pageIndex = pageIndex;
if(totalNumOfRows > 0){
this.beginIndex = (pageIndex-1)*rowsPerPage;
}
this.endIndex = pageIndex*rowsPerPage;
endIndex = endIndex>this.totalNumOfRows ? this.totalNumOfRows : endIndex;
}
/** 总页数,最少一页,0行也按一页计算 */
public int getTotalNumOfPage() {
return this.totalNumOfRows / this.rowsPerPage + 1;
}
/** 数据 */
public List> getEntryList() {
return entryList;
}
public void setEntryList(List> entryList) {
this.entryList = entryList;
}
/** 总行数 */
public int getTotalNumOfRows() {
return totalNumOfRows;
}
public void setTotalNumOfRows(int totalNumOfRows) {
this.totalNumOfRows = totalNumOfRows;
}
/** 每页行数 */
public int getRowsPerPage() {
return rowsPerPage;
}
public void setRowsPerPage(int rowsPerPage) {
this.rowsPerPage = rowsPerPage;
}
/** 当前页起始行 */
public int getBeginIndex() {
return beginIndex;
}
public void setBeginIndex(int beginIndex) {
this.beginIndex = beginIndex;
}
/** 终止页 */
public int getEndIndex() {
return endIndex;
}
public void setEndIndex(int endIndex) {
this.endIndex = endIndex;
}
/** 当前页 */
public int getPageIndex() {
return pageIndex;
}
public void setPageIndex(int pageIndex) {
this.pageIndex = pageIndex;
}
/** 总页数 */
public int getPageCount() {
return pageCount;
}
public void setPageCount(int pageCount) {
this.pageCount = pageCount;
}
}
2.Action调用