pengpenglin的专栏
因为热爱,所以坚持。因为坚持,所以快乐!
登录
注册
全站
当前博客
空间
博客
好友
相册
留言
用户操作
[即时聊天]
[发私信]
[加为好友]
pengpenglin
ID:pengpenglin
共
62325
次访问,排名
1704
好友
0
人,关注者
1
人
pengpenglin的文章
原创 65 篇
翻译 0 篇
转载 6 篇
评论 96 篇
最近评论
SNNPSNNP:
wow gold
When you play a game of the day, the list of friends in the game whether there are always a few names of black
wow power leveling<……
qpyong:
学习下。
Zealcn:
楼主所言只是一个表象。duzhe兄的分析才是问题的根本所在。中国的程序员绝大多数跟欧美国家的程序员除了所处相同行业之外,其他方面可比性太少!这不是中国程序员本身的问题!
浮躁的原因来源于安全感缺失,各方面的安全感。
cnhzlt:
同意
chinalhcz:
写的可以,不错.
文章分类
J2EE Web
(RSS)
J2EE 框架
(RSS)
J2SE
(RSS)
Java 工具
(RSS)
Oracle SQL/PLSQL
(RSS)
Oracle 错误诊断
(RSS)
Oracle 调优
(RSS)
Oracle 工具
(RSS)
Oracle 管理
(RSS)
Oracle 体系结构
(RSS)
Oracle 应用专题
(RSS)
Unix/Linux
(RSS)
模式与重构
(RSS)
其他技术
(RSS)
软件工程与软件方法
(RSS)
音乐
(RSS)
杂谈
(RSS)
走过的路
(RSS)
收藏
相册
存档
2007年12月(10)
2007年11月(1)
2007年10月(12)
2007年09月(2)
2007年08月(10)
2007年07月(1)
2007年04月(2)
2007年02月(1)
2007年01月(1)
2006年05月(18)
2006年04月(2)
2006年01月(11)
软件项目交易
订阅我的博客
Java分页实例之-分页类
收藏
新一篇: JSP分页之-分页标签类
|
旧一篇: Oracle体系结构之-连接配置结构
package
com.dbtemplate.domain;
import
org.apache.log4j.Logger;
/** */
/**
* The Class PageInfo.
*/
public
class
PageInfo
...
{
/** */
/**
The logger.
*/
static
Logger logger
=
Logger.getLogger(PageInfo.
class
.getName());
/** */
/**
The total records.
*/
private
int
totalRecords;
/** */
/**
The total pages.
*/
private
int
totalPages;
/** */
/**
The page size.
*/
private
int
pageSize
=
10
;
/** */
/**
The current page no.
*/
private
int
currentPageNo;
/** */
/**
The previous page no.
*/
private
int
previousPageNo;
/** */
/**
The next page no.
*/
private
int
nextPageNo;
/** */
/**
The is first page.
*/
private
boolean
isFirstPage;
/** */
/**
The is last page.
*/
private
boolean
isLastPage;
/** */
/**
The has previous pag.
*/
private
boolean
hasPreviousPage;
/** */
/**
The has next page.
*/
private
boolean
hasNextPage;
/** */
/**
* Instantiates a new page info.
*
*
@param
totalRecords the total records
*/
public
PageInfo(
int
totalRecords,
int
pageSize)
...
{
logger.debug(
"
Start to initialize the page info.
"
);
//
设置总记录数
if
(totalRecords
>=
0
)
...
{
this
.totalRecords
=
totalRecords;
}
else
...
{
totalRecords
=
0
;
}
//
设置每页记录数
setPageSize(pageSize);
//
设置总页面数
if
(totalRecords
%
pageSize
==
0
)
...
{
totalPages
=
totalRecords
/
pageSize;
}
else
...
{
totalPages
=
(totalRecords
/
pageSize)
+
1
;
}
//
设置当前页
currentPageNo
=
1
;
}
/** */
/**
* Gets the current page no.
*
*
@return
the current page no
*/
public
int
getCurrentPageNo()
...
{
return
currentPageNo;
}
/** */
/**
* Sets the current page no.
*
*
@param
currentPageNo the new current page no
*/
public
void
setCurrentPageNo(
int
currentPageNo)
...
{
//
设置当前页
if
(currentPageNo
<
1
)
...
{
this
.currentPageNo
=
1
;
}
else
if
(currentPageNo
>
totalPages)
...
{
this
.currentPageNo
=
totalPages;
}
else
...
{
this
.currentPageNo
=
currentPageNo;
}
//
每次设置当前页时更新上一页、下一页、是否首页、是否末页、是否有上一页、是否有下一页标志
isFirstPage
=
(currentPageNo
==
1
)
?
true
:
false
;
isLastPage
=
(currentPageNo
==
totalPages)
?
true
:
false
;
hasPreviousPage
=
(currentPageNo
==
1
)
?
false
:
true
;
hasNextPage
=
(currentPageNo
==
totalPages)
?
false
:
true
;
previousPageNo
=
(hasPreviousPage)
?
(currentPageNo
-
1
):currentPageNo;
nextPageNo
=
(hasNextPage)
?
(currentPageNo
+
1
):currentPageNo;
}
/** */
/**
* Gets the current page size.
*
*
@return
the current page size
*/
public
int
getCurrentPageSize()
...
{
if
(totalRecords
==
0
)
...
{
return
0
;
}
else
if
(currentPageNo
<
totalPages)
...
{
//
非末页
return
pageSize;
}
else
...
{
//
末页
return
(totalRecords
-
(currentPageNo
-
1
)
*
pageSize);
}
}
/** */
/**
* Gets the current page start record.
*
*
@return
the current page start record
*/
public
int
getCurrentPageStartRecord()
...
{
return
(currentPageNo
-
1
)
*
pageSize
+
1
;
}
/** */
/**
* Gets the current page end record.
*
*
@return
the current page end record
*/
public
int
getCurrentPageEndRecord()
...
{
return
(currentPageNo
-
1
)
*
pageSize
+
getCurrentPageSize();
}
/** */
/**
* Checks if is has next page.
*
*
@return
true, if is has next page
*/
public
boolean
isHasNextPage()
...
{
return
hasNextPage;
}
/** */
/**
* Checks if is has previous pag.
*
*
@return
true, if is has previous pag
*/
public
boolean
isHasPreviousPage()
...
{
return
hasPreviousPage;
}
/** */
/**
* Checks if is first page.
*
*
@return
true, if is first page
*/
public
boolean
isFirstPage()
...
{
return
isFirstPage;
}
/** */
/**
* Checks if is last page.
*
*
@return
true, if is last page
*/
public
boolean
isLastPage()
...
{
return
isLastPage;
}
/** */
/**
* Gets the page size.
*
*
@return
the page size
*/
public
int
getPageSize()
...
{
return
pageSize;
}
/** */
/**
* Sets the page size.
*
*
@param
pageSize the new page size
*/
public
void
setPageSize(
int
pageSize)
...
{
this
.pageSize
=
(pageSize
<=
0
)
?
10
:pageSize;
}
/** */
/**
* Gets the previous page no.
*
*
@return
the previous page no
*/
public
int
getPreviousPageNo()
...
{
return
previousPageNo;
}
/** */
/**
* Gets the next page no.
*
*
@return
the next page no
*/
public
int
getNextPageNo()
...
{
return
nextPageNo;
}
/** */
/**
* Gets the total pages.
*
*
@return
the total pages
*/
public
int
getTotalPages()
...
{
return
totalPages;
}
/** */
/**
* Gets the total records.
*
*
@return
the total records
*/
public
int
getTotalRecords()
...
{
return
totalRecords;
}
}
发表于 @
2007年10月16日 22:09:00
|
评论(
loading...
)
|
编辑
新一篇: JSP分页之-分页标签类
|
旧一篇: Oracle体系结构之-连接配置结构
评论:没有评论。
发表评论
姓 名:
主 页:
校验码:
看不清,换一张
当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击
登录