📄 pager.java
字号:
/**
* <ol>
* @author 袁 军
* <br>Time: 2005-08-23
* <br>Company: 湖北工业大学计算机学院
* <br>Email: yuan_junl@163.com
* </ol>
* 页面类,代表每一个页面
* @version 1.0
*/
public class Pager {
private long totalRows; //总行数
private long pageSize = 2; //每页显示的行数
private long currentPage; //当前页号
private long totalPages; //总页数
private long startRow; //当前页在数据库中的起始行
public Pager() {
}
public Pager(long _totalRows) {
totalRows = _totalRows;
totalPages=totalRows/pageSize;
long mod=totalRows%pageSize;
if(mod>0){
totalPages++;
}
currentPage = 1;
startRow = 0;
}
public long getStartRow() {
return startRow;
}
public long getTotalPages() {
return totalPages;
}
public long getCurrentPage() {
return currentPage;
}
public long getPageSize() {
return pageSize;
}
public void setTotalRows(long totalRows) {
this.totalRows = totalRows;
}
public void setStartRow(long startRow) {
this.startRow = startRow;
}
public void setTotalPages(long totalPages) {
this.totalPages = totalPages;
}
public void setCurrentPage(long currentPage) {
this.currentPage = currentPage;
}
public void setPageSize(long pageSize) {
this.pageSize = pageSize;
}
public long getTotalRows() {
return totalRows;
}
public void first() {
currentPage = 1;
startRow = 0;
}
public void previous() {
if (currentPage == 1) {
return;
}
currentPage--;
startRow = (currentPage - 1) * pageSize;
}
public void next() {
if (currentPage < totalPages) {
currentPage++;
}
startRow = (currentPage - 1) * pageSize;
}
public void last() {
currentPage = totalPages;
startRow = (currentPage - 1) * pageSize;
}
public void refresh(long _currentPage) {
currentPage = _currentPage;
setStartRow((_currentPage-1)*pageSize);
totalPages=totalRows/pageSize;
long mod=totalRows%pageSize;
if(mod>0){
totalPages++;
}
if (currentPage > totalPages) {
last();
}
if(currentPage<1){
first();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -