<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Java Blog for Alex Wan

    Let life be beautiful like summer flowers and death like autumn leaves.

    統計

    留言簿(10)

    BlogJava

    Blogs

    DIV+CSS

    JQuery相關

    友情鏈接

    常去的地方

    數據供應

    閱讀排行榜

    評論排行榜

    java中簡單的翻頁功能的實現(PageManager)

    package util;
    import java.util.List;

    public class PageManager
    {
        private List allRecords = null;//collection儲存同一類型的對象的集合
        private int currentPage = 0;//當前頁碼
        private int totalPage = 0;//總頁數
        private int recordPerPage = -1;//每頁的對象數
        private int totalCount=0;//總的對象數
     //初始化
     public PageManager(List allRecords, int recordPerPage)
        {
            if (allRecords == null || recordPerPage < 1) return;

            this.allRecords = allRecords;
            this.recordPerPage = recordPerPage;
            this.totalCount=allRecords.size();
            if (allRecords.size() % recordPerPage == 0)
                this.totalPage = allRecords.size() / recordPerPage;
            else
                this.totalPage = allRecords.size() / recordPerPage + 1;
            this.currentPage = 0;
        }
        //獲取所有對象集合
        public List getAllRecords()
        {
         return this.allRecords;
        }
     //獲取當前頁的的對象集合
        public List getCurrentPage()
        {
         return getPage(currentPage);
        }
        //根據序號獲取該對象所在的頁的對象集合
        public List getThePage(int recordno)
        {
         if (this.allRecords == null || this.allRecords.size() == 0)
            {
                this.currentPage = 0;
                return null;
            }
            int pageNo=1;
            if (recordno < 1) pageNo = 1;
           
            else if (recordno > this.allRecords.size())
             pageNo = this.totalPage;
            else
            {
             pageNo=recordno/this.recordPerPage+1;
            }
            this.currentPage = pageNo;
           
            int pageStart = (pageNo - 1) * this.recordPerPage;
            int pageEnd = pageStart + this.recordPerPage - 1;
            if (pageEnd > this.allRecords.size() - 1) pageEnd = this.allRecords.size() - 1;
           
            List result =this.allRecords.subList(pageStart, pageEnd+1);       
            return result;
        }
       //根據頁碼獲取改頁的對象集合
        public List getPage(int pageNo)
        {
            if (this.allRecords == null || this.allRecords.size() == 0)
            {
                this.currentPage = 0;
                return null;
            }
           
            if (pageNo < 1) pageNo = 1;
            if (pageNo > this.totalPage) pageNo = this.totalPage;
            this.currentPage = pageNo;
           
            int pageStart = (pageNo - 1) * this.recordPerPage;
            int pageEnd = pageStart + this.recordPerPage - 1;
            if (pageEnd > this.allRecords.size() - 1) pageEnd = this.allRecords.size() - 1;
            List result =this.allRecords.subList(pageStart, pageEnd+1);
            return result;
        }
        //獲取下一頁的對象集合
        public List getNextPage()
        {
            return getPage(this.currentPage + 1);
        }
         //獲取上一頁的對象集合
        public List getPreviousPage()
        {
            return getPage(this.currentPage - 1);
        }
       //獲取第一頁的對象集合 
        public List getFirstPage()
        {
            return getPage(1);
        }
      //獲取最后一頁的對象集合
        public List getLastPage()
        {
            return getPage(this.totalPage);
        }
       //獲取總頁數
     public int getTotalPage() {
      return totalPage;
     }
     //獲取當前頁碼 
     public int getCurrentPageCount()
     {
      return this.currentPage;
     }
     //獲取對象總數
     public int getTotalCount() {
      return totalCount;
     }


    }



    Let life be beautiful like summer flowers and death like autumn leaves.

    posted on 2008-06-07 10:19 Alexwan 閱讀(2300) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 久久精品国产亚洲精品2020| 亚洲午夜久久久久久久久久| 日本视频在线观看永久免费| 一边摸一边桶一边脱免费视频| 一本天堂ⅴ无码亚洲道久久| 亚洲av无码国产精品色午夜字幕 | 无遮挡国产高潮视频免费观看| 亚洲一区二区三区深夜天堂| 亚洲国产一区国产亚洲 | 免费夜色污私人影院网站| 亚洲JIZZJIZZ妇女| 农村寡妇一级毛片免费看视频| 久久亚洲AV成人无码国产最大| 亚洲国产精品网站在线播放| 麻豆亚洲AV成人无码久久精品 | 亚洲一区免费视频| 亚洲欧美日韩中文二区| 亚洲日本VA午夜在线电影| 亚洲GV天堂GV无码男同| 国产男女爽爽爽免费视频 | 国产成人亚洲综合无| 深夜a级毛片免费视频| 一出一进一爽一粗一大视频免费的 | 亚洲精品自偷自拍无码| 边摸边吃奶边做爽免费视频99| 免费高清A级毛片在线播放| eeuss影院ss奇兵免费com| 三年片在线观看免费观看大全一 | 国产亚洲精品精品精品| 久久国产乱子伦精品免费强| 精品免费人成视频app| 免费中文字幕一级毛片| 亚洲精品综合一二三区在线| 亚洲av无码一区二区三区四区| 中文字幕成人免费高清在线| 99久久精品日本一区二区免费 | 免费一级毛片在线播放视频| 国产自产拍精品视频免费看| 久久精品亚洲中文字幕无码网站 | 国产日韩亚洲大尺度高清| 亚洲欧洲无码一区二区三区|