public class Pagination {
public static final int PAGESIZE=5; //分页每页的记录数
public static final String currentTag = "current"; //当前页
public static final String firstAction = "First"; //第一页
public static final String nextAction = "Next"; //下一页
public static final String previoAction = "Previo"; //前一页
public static final String lastAction = "Last"; //最后一页
public static final String gotoPageAction = "gotoPage"; //到第几页
private String paginationActionTag = "First";
private int pageSelect = 0;
private int start = 0;
private int end = 0;
private int count;
private int pageSize = PAGESIZE;
private int current =1;
public DivPageVO toDivPageVO() {
DivPageVO divPageVO = new DivPageVO();
divPageVO.setStartPos(this.getStart());
divPageVO.setEndPos(this.getEnd());
divPageVO.setPageSize(this.getPageSize());
return divPageVO;
}
public Pagination(int count) {
this.count = count;
this.paginationActionTag = "First";
this.start = 0;
this.end = 0;
this.pageSize = PAGESIZE;
this.current = 1;
}
public int getStart() {
if (getPaginationActionTag().equals(firstAction)) {
firstPage();
}
else if (getPaginationActionTag().equals(nextAction)) {
nextPage(getCurrent());
}
else if (getPaginationActionTag().equals(previoAction)) {
previoPage(getCurrent());
}
else if (getPaginationActionTag().equals(lastAction)) {
lastPage();
}
else if (getPaginationActionTag().equals(gotoPageAction)) {
gotoPage(getPageSelect());
}
start = getPageSize() * (getCurrent() - 1);
return start;
}