import java.util.ArrayList;
public class PageIndex
{
private int pageSize; //每页要显示的行
private int pageNum; //总页数
private int pageId; //当前页
private int size; //结果集的长度
private ArrayList arraylist; //要分页的结果集
public PageIndex(){} //构造方法
public PageIndex(int pageSize,int pageId,ArrayList arraylist)
{
this.pageSize = pageSize;
this.pageId = pageId;
this.size = arraylist.size();
this.arraylist = arraylist;
}
public ArrayList Pagination()
{
if(size%pageSize==0)
{
pageNum = size/pageSize;
}
else
{
pageNum = size/pageSize+1;
}
int suffixindex = (pageId-1)*pageSize; //结果集下标的索引
ArrayList returnarray = new ArrayList();
for(int i = 0 ; i
{
returnarray.add(arraylist.get(suffixindex));
suffixindex++;
}
return returnarray;
}
public int getPageNum()
{
return this.pageNum; //返回总页数
}
public int getSize()
{
return this.size; //返回总结果集长度
}
}