用于实现基本的分页操作工具类
来源:互联网 发布:数字病理 人工智能 编辑:程序博客网 时间:2024/06/15 01:25
package
com.fww.practice.page;
import
java.util.List;
/**
* 类功能说明 :作为分页使用
* @Description:
* @author FWW
* @date 2014年7月2日 下午5:45:49
*/
public
class
Page {
/**
* 总的记录数
*/
private
int
rowCounts;
/**
* 每一页可以显示的记录数
*/
private
int
pageSize;
/**
* 当前的页面
*/
private
int
currentPage;
/**
* 开始的记录数
*/
private
int
startRow;
/**
* 记录数折换成导航显示的个数
*/
private
int
navCounts;
/**
* 第一页
*/
private
int
firstPage;
/**
* 最后一页
*/
private
int
lastPage;
/**
* 页面显示的导航起始位置
*/
private
int
beginNav;
/**
* 页面显示的导航结束的位置
*/
private
int
endNav;
/**
* 上一页
*/
private
int
prePage;
/**
* 下一页
*/
private
int
nextPage;
/**
* 固定的导航数
*/
private
int
navNum;
/**
* 获取的记录集合
*/
@SuppressWarnings
(
"rawtypes"
)
private
List pageDatas;
public
int
getRowCounts() {
return
rowCounts;
}
public
void
setRowCounts(
int
rowCounts) {
this
.rowCounts = rowCounts;
}
public
int
getPageSize() {
return
pageSize;
}
public
void
setPageSize(
int
pageSize) {
this
.pageSize = pageSize;
}
public
int
getCurrentPage() {
return
currentPage;
}
public
void
setCurrentPage(
int
currentPage) {
this
.currentPage = currentPage;
}
public
int
getStartRow() {
return
startRow;
}
public
void
setStartRow(
int
startRow) {
this
.startRow = startRow;
}
public
int
getNavCounts() {
return
navCounts;
}
public
void
setNavCounts(
int
navCounts) {
this
.navCounts = navCounts;
}
public
int
getFirstPage() {
return
firstPage;
}
public
void
setFirstPage(
int
firstPage) {
this
.firstPage = firstPage;
}
public
int
getLastPage() {
return
lastPage;
}
public
void
setLastPage(
int
lastPage) {
this
.lastPage = lastPage;
}
public
int
getBeginNav() {
return
beginNav;
}
public
void
setBeginNav(
int
beginNav) {
this
.beginNav = beginNav;
}
public
int
getEndNav() {
return
endNav;
}
public
void
setEndNav(
int
endNav) {
this
.endNav = endNav;
}
public
int
getPrePage() {
return
prePage;
}
public
void
setPrePage(
int
prePage) {
this
.prePage = prePage;
}
public
int
getNextPage() {
return
nextPage;
}
public
void
setNextPage(
int
nextPage) {
this
.nextPage = nextPage;
}
public
int
getNavNum() {
return
navNum;
}
public
void
setNavNum(
int
navNum) {
this
.navNum = navNum;
}
@SuppressWarnings
(
"rawtypes"
)
public
List getPageDatas() {
return
pageDatas;
}
@SuppressWarnings
(
"rawtypes"
)
public
void
setPageDatas(List pageDatas) {
this
.pageDatas = pageDatas;
}
/**
* @param rowCounts 总得记录实体个数
* @param pageSize 页面可以显示的实体个数
* @param currentPage 当前页码
* @param navNum 固定显示的最多导航数
*/
public
Page(
int
rowCounts,
int
pageSize,
int
currentPage,
int
navNum) {
//记录实体总数
this
.rowCounts = rowCounts;
//一页可以显示的记录实体的个数
this
.pageSize = pageSize;
//第一页
this
.firstPage =
1
;
//固定的导航数
this
.navNum = navNum;
//运用总的实体数折算出来的可以显示的导航数
this
.navCounts = (
int
)(rowCounts+pageSize-
1
)/pageSize;
//当前的页面: 首页和当前页中的最大的
this
.currentPage = Math.max(currentPage, firstPage);
//当前的页面: 折算出来的可以显示的最大页数和当前页中的最小的一个
this
.currentPage = Math.min(currentPage,
this
.navCounts);
//起始显示的实体在数据库中的位置
this
.startRow = Math.max(
0
, (
this
.currentPage-
1
)*pageSize);
//尾页
this
.lastPage =
this
.navCounts;
//上一页
this
.prePage = Math.max(
this
.currentPage-
1
, firstPage);
//下一页
this
.nextPage = Math.min(
this
.currentPage+
1
, lastPage);
//起始的导航数
this
.beginNav = Math.max(
this
.firstPage,
this
.currentPage-
this
.navNum/
2
);
//最后的一个导航数
this
.endNav = Math.min(
this
.lastPage,
this
.beginNav+
this
.navNum-
1
);
if
(lastPage - beginNav<(navNum-
1
)){
this
.beginNav = Math.max(
this
.firstPage,
this
.endNav-
this
.navNum+
1
);
}
}
public
Page() {
}
}
0 0
- 用于实现基本的分页操作工具类
- JDBC实现用于操作数据库Mysql的工具类JDBCTools
- ThumbnailUtils:用于实现缩略图的工具类
- JDBC实现用于操作数据库Mysql的工具类JDBCTools和DAO--完整可用版
- 数组操作工具类 (实现集合类部分功能,用于Array的增、删、改、查等操作)
- 用于分页的辅助类
- JAVA——用于操作数组的工具类Arrays
- 用于操作基本数据类型的流对象
- Hibernate实现分页的工具类
- Android分页工具类的实现
- 用于分页的PageBean
- 用于管理 Active Directory 的 11 个基本工具
- 用于管理 Active Directory 的 11 个基本工具
- 用于管理 Active Directory 的 11 个基本工具
- SQL 语句--用于实现分页
- FreeMarker编写一个用于实现分页效果的通用指令
- 分页的工具类
- jsp 分页操作的实现
- handler基础知识转载
- 【BZOJ】【P2301】【HAOI2011】【Problem b】【题解】【莫比乌斯反演】
- PHP 中命名空间的作用
- POJ 3130 How I Mathematician Wonder What You Are! 半平面交求多边形内核是否存在
- FFmpeg filter HOWTO
- 用于实现基本的分页操作工具类
- 2014.10.20 周一-事务
- 利用HttpListenerRequest监听HTTP请求并接收cookie的
- hdu 2089 不要62(数位DP)
- Python(2) variable
- eclipse 搭建 python开发环境之快捷方法
- 线程池
- 【产品经理】产品经理如何才能入门
- 学习线路