<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.

    統(tǒng)計

    留言簿(10)

    BlogJava

    Blogs

    DIV+CSS

    JQuery相關(guān)

    友情鏈接

    常去的地方

    數(shù)據(jù)供應(yīng)

    閱讀排行榜

    評論排行榜

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

    package util;
    import java.util.List;

    public class PageManager
    {
        private List allRecords = null;//collection儲存同一類型的對象的集合
        private int currentPage = 0;//當(dāng)前頁碼
        private int totalPage = 0;//總頁數(shù)
        private int recordPerPage = -1;//每頁的對象數(shù)
        private int totalCount=0;//總的對象數(shù)
     //初始化
     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;
        }
     //獲取當(dāng)前頁的的對象集合
        public List getCurrentPage()
        {
         return getPage(currentPage);
        }
        //根據(jù)序號獲取該對象所在的頁的對象集合
        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;
        }
       //根據(jù)頁碼獲取改頁的對象集合
        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);
        }
       //獲取總頁數(shù)
     public int getTotalPage() {
      return totalPage;
     }
     //獲取當(dāng)前頁碼 
     public int getCurrentPageCount()
     {
      return this.currentPage;
     }
     //獲取對象總數(shù)
     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)  編輯  收藏


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


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 国产一级淫片视频免费看| 成人免费观看一区二区| 亚洲国产成人乱码精品女人久久久不卡| 亚洲成人黄色在线| 成人午夜免费福利视频| 亚洲国产成人精品青青草原| 国色精品卡一卡2卡3卡4卡免费 | 很黄很色很刺激的视频免费| 亚洲精品午夜国产va久久| 中文字幕无码免费久久99| 亚洲日韩精品无码专区加勒比| 在线观看无码的免费网站| 亚洲AV日韩AV一区二区三曲| 国产精品99久久免费| 免费国产黄网站在线看| 国产亚洲一区二区三区在线| 黄页免费在线观看| 亚洲网址在线观看| 噼里啪啦电影在线观看免费高清| 亚洲中文字幕一区精品自拍| www国产亚洲精品久久久日本| 久草免费福利在线| 亚洲AV无码久久精品成人 | 成年女人免费视频播放体验区| 亚洲精品亚洲人成在线| 亚洲av无码成人精品区在线播放| 久久免费99精品国产自在现线 | 亚洲一级高清在线中文字幕| 日韩免费一级毛片| a一级爱做片免费| 99ri精品国产亚洲| 色吊丝最新永久免费观看网站| 免费无码午夜福利片| 亚洲AV日韩AV高潮无码专区| 无码人妻一区二区三区免费手机| 黄色一级免费网站| 久久久久亚洲av无码专区喷水| 在线不卡免费视频| 韩日电影在线播放免费版| 亚洲精品国产第1页| 亚洲精品和日本精品|