<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 閱讀(2307) 評論(0)  編輯  收藏


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


    網站導航:
     
    主站蜘蛛池模板: 亚洲国产精品嫩草影院| 亚洲精品美女久久久久9999| 国内成人精品亚洲日本语音| 中文字幕免费视频| 亚洲精品国产成人专区| 亚洲成色999久久网站| 特级做A爰片毛片免费看无码| 国产亚洲精品不卡在线| 四虎影视久久久免费观看| 亚洲av成人一区二区三区在线观看| 亚洲人成网站影音先锋播放| 久久午夜免费鲁丝片| 亚洲AV日韩精品久久久久| 四虎影视成人永久免费观看视频| 在线观看免费大黄网站| 亚洲人成电影网站色www| 波多野结衣久久高清免费 | 久久亚洲AV无码精品色午夜| 99爱在线精品视频免费观看9| 亚洲色欲或者高潮影院| 日本阿v免费费视频完整版| 亚洲午夜无码久久久久| 免费看无码特级毛片| 亚洲最大福利视频网站| 国产视频精品免费视频| 亚洲成a人片77777kkkk| 日本zzzzwww大片免费| 亚洲成a人片在线观看无码 | aⅴ免费在线观看| 激情五月亚洲色图| 日韩免费无砖专区2020狼| 无码 免费 国产在线观看91| 精品久久久久久亚洲| 亚洲综合av一区二区三区| 国产免费av一区二区三区| 久久国产免费直播| 亚洲日本在线免费观看| 国产精品免费_区二区三区观看| 一个人看的www免费高清 | 亚洲一级大黄大色毛片| 四虎永久成人免费|