?? pagelist.java
字號:
package com.wlpava.utils;
import java.util.*;
/**
* 實現通過調用IQuery實現分頁處理
* @author 蔡世友
*/
public class PageList implements IPageList {
private int rowCount;// 記錄數
private int pages;// 總頁數
private int currentPage;// 實際頁數
private List result;
private IQuery query;
public PageList() {
}
public PageList(IQuery q) {
this.query = q;
}
public void setQuery(IQuery q) {
query = q;
}
public List getResult() {
return result;
}
public void doList(int pageSize, int pageNo, String totalSQL, String queryHQL) {
List rs = null;
int total = query.getRows(totalSQL);
if (total > 0) {
this.rowCount = total;
this.pages = (this.rowCount + pageSize - 1) / pageSize; // 記算總頁數
int intPageNo = (pageNo > this.pages ? this.pages : pageNo);
if (intPageNo < 1)
intPageNo = 1;
this.currentPage = intPageNo;
if (pageSize > 0) {
query.setFirstResult((intPageNo - 1) * pageSize);
query.setMaxResults(pageSize);
}
rs = query.getResult(queryHQL);
}
result = rs;
}
public void doList(int pageSize, int pageNo, String totalSQL, String queryHQL, Collection paraValues) {
List rs = null;
query.setParaValues(paraValues);
int total = query.getRows(totalSQL);
if (total > 0) {
this.rowCount = total;
this.pages = (this.rowCount + pageSize - 1) / pageSize; // 記算總頁數
int intPageNo = (pageNo > this.pages ? this.pages : pageNo);
if (intPageNo < 1)
intPageNo = 1;
this.currentPage = intPageNo;
if (pageSize > 0) {
query.setFirstResult((intPageNo - 1) * pageSize);
query.setMaxResults(pageSize);
}
rs = query.getResult(queryHQL);
}
result = rs;
}
public int getPages() {
return pages;
}
public int getRowCount() {
return rowCount;
}
public int getCurrentPage() {
return currentPage;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -