package com.jpsycn.kfwggl.common.crawl; import java.util.ArrayList; import java.util.List; public class PageListBean {

private int currentPage = 1;  //当前页

private int rowsCountPerPage = 5;  //每页的数据条数

private int totalPage = 0;  //共有多少页

private int totalCount = 0; //共有多少行数据

private List dataList = null; //待分页的数据

private List tempDataList = null;  //每页的数据

public PageListBean() {

}

@SuppressWarnings("unchecked")

public List getPaper(List dataList/* 待分页的数据 */, int rowsCount/* 每页显示的行数 */)

{

initPageList(dataList, rowsCount);

tempDataList = new ArrayList();

//currentPage * rowsCountPerPage 定位到当前页的数据数

//currentPage * rowsCountPerPage - rowsCountPerPage 定位到当前页的第一条数据

for(int i = currentPage * rowsCountPerPage - rowsCountPerPage; i < currentPage * rowsCountPerPage; i++) {

if(i >= totalCount) break;

tempDataList.add(dataList.get(i));

}

return tempDataList;

}

//待分页的数据,设置记录数,每页记录数,总页数

private void initPageList(List dataList, int rowsCount) {

this.dataList = dataList;

totalCount = dataList.size();

rowsCountPerPage = rowsCount;

if(totalCount % rowsCountPerPage == 0) {

totalPage = totalCount / rowsCountPerPage;

} else {

totalPage = totalCount / rowsCountPerPage + 1;

}

}

public int getCurrentPage() {

return currentPage;

}

public void setCurrentPage(int currentPage) {

this.currentPage = currentPage;

}

public int getRowsCountPerPage() {

return rowsCountPerPage;

}

public void setRowsCountPerPage(int rowsCountPerPage) {

this.rowsCountPerPage = rowsCountPerPage;

}

public int getTotalPage() {

return totalPage;

}

public void setTotalPage(int totalPage) {

this.totalPage = totalPage;

}

public int getTotalCount() {

return totalCount;

}

public void setTotalCount(int totalCount) {

this.totalCount = totalCount;

}

public List getDataList() {

return dataList;

}

public void setDataList(List dataList) {

this.dataList = dataList;

}

@SuppressWarnings("unchecked")

public static void main(String[] args) {

List da = new ArrayList();

for(int i = 0; i < 25; i++) {

da.add(i+1);

}

PageListBean bean = new PageListBean();

List pagerList = bean.getPaper(da, 5);

bean.setCurrentPage(bean.getTotalPage());

pagerList = bean.getPaper(da, 5);

for(int b = 0; b < pagerList.size(); b++) {

System.out.println(pagerList.get(b));

}

} }

不连数据库List分页的更多相关文章

  1. oracle,mysql,SqlServer三种数据库的分页查询的实例。

    MySql: MySQL数据库实现分页比较简单,提供了 LIMIT函数.一般只需要直接写到sql语句后面就行了.LIMIT子 句可以用来限制由SELECT语句返回过来的数据数量,它有一个或两个参数,如 ...

  2. 盘点几种数据库的分页SQL的写法(转)

    Data序列——盘点几种数据库的分页SQL的写法http://www.cnblogs.com/fireasy/archive/2013/04/10/3013088.html

  3. 通过 DynamicLinq 简单实现 N-Tier 部署下的服务端数据库通用分页

    通过 DynamicLinq 简单实现 N-Tier 部署下的服务端数据库通用分页 YbSoftwareFactory 的 YbRapidSolution for WinForm 插件使用CSLA.N ...

  4. MySQL、SQLServer2000(及SQLServer2005)和ORCALE三种数据库实现分页查询的方法

    在这里主要讲解一下MySQL.SQLServer2000(及SQLServer2005)和ORCALE三种数据库实现分页查询的方法. 可能会有人说这些网上都有,但我的主要目的是把这些知识通过我实际的应 ...

  5. Sybase数据库的分页功能

    项目中需要用到Sybase数据库的分页功能,想尽各种办法都没有成功,最后用如下的存储过程成功实现功能,记录备忘. ),@start int, @pageSize int as begin declar ...

  6. 我的sql数据库存储过程分页- -

    以前用到数据库存储过程分页的时候都是用 not in 但是最近工作的时候,随着数据库记录的不断增大,发现not in的效率 真的不行 虽然都设置了索引,但是当记录达到10w的时候就发现不行了,都是需要 ...

  7. postgreSQL数据库limit分页、排序

    postgreSQL数据库limit分页.排序 语法: select * from persons limit  A  offset  B; 解释: A就是你需要多少行: B就是查询的起点位置. 示例 ...

  8. 分页查询信息(使用jdbc连接mysql数据库实现分页查询任务)

             分页查询信息       使用jdbc连接mysql数据库实现分页查询任务 通过mysql数据库提供的分页机制,实现商品信息的分页查询功能,将查询到的信息显示到jsp页面上. 本项目 ...

  9. oracle,mysql,SqlServer三种数据库的分页查询

    MySql: MySQL数据库实现分页比较简单,提供了 LIMIT函数.一般只需要直接写到sql语句后面就行了.LIMIT子 句可以用来限制由SELECT语句返回过来的数据数量,它有一个或两个参数,如 ...

  10. YbSoftwareFactory 代码生成插件【十四】:通过 DynamicLinq 简单实现 N-Tier 部署下的服务端数据库通用分页

    YbSoftwareFactory 的 YbRapidSolution for WinForm 插件使用CSLA.NET作为业务层,CSLA.NET的一个强大的特性是支持 N-Tiers 部署.只需非 ...

随机推荐

  1. hdu-acm steps Common Subsequence

    /*这道题是很明显的dp题,状态方程有点不大好想,也许是我刚刚接触dp的缘故吧.dp[i][j]表示字符串s1取前i个字符s2取前j个字符时最大公共子序列的大小,这样的如果s1[i]==s2[j],d ...

  2. 7. Add a networking service

    Controller Node: 1. sudo vi /etc/nova/nova.conf [DEFAULT] ... network_api_class = nova.network.api.A ...

  3. 安装nfs服务器

    服务器和客户端都有一下操作 groupadd nginx useradd -r -g nginx nginx -s /sbin/nologin id nginx 查看nginx的id yum inst ...

  4. Frenetic QuickInstall

    Frenetic a family of network programming languages 官方网站:Frenetic Github:Frenetic QuickInstall 第一步,先安 ...

  5. TP中不区分大小写__APP__和__URL__的注意事项

    控制器命名为 : AuthGroupAction.class.php 问题 : 在控制器跳转中.如果模板跳转时地址的大小写错了..就会报无法加载模块 报错 : 无法加载模块:Authgroup 解决办 ...

  6. 解决蓝屏代吗0x0000007B的几种常见办法

        解决蓝屏代吗0x0000007B的几种常见办法 0x0000007B 蓝屏代码的分析 ◆错误分析:Windows在启动过程中无法访问系统分区或启动卷. 网络上经过收集,主要有四种可能.第一是新 ...

  7. Ubuntu下搭建NodeJS+Express WEB开发框架

    Ubuntu下搭建NodeJS+Express WEB开发框架 2012-12-27 15:06 作者: NodeJSNet 来源: 本站 浏览: 2,966 次阅读 我要评论暂无评论 字号: 大 中 ...

  8. 大话数据结构(五)(java程序)——顺序存储结构的插入与删除

    获得元素操作 对于线性表的顺序存储结构来说,我们要实现getElement操作,即将线性表的第i个位置元素返回即可 插入操作 插入算法思路: 1.如果插入位置不合理,抛出异常 2.如果插入表的长度大于 ...

  9. PureBasic 读取文件中一行的两个数据例子

    , "Test1.txt") ; if the file could be read, we continue... , "Test2.txt") ) = ; ...

  10. 九 spring和mybatis整合

    1       spring和mybatis整合 1.1     整合思路 需要spring通过单例方式管理SqlSessionFactory. spring和mybatis整合生成代理对象,使用Sq ...