zoukankan      html  css  js  c++  java
  • util(分页总类PageView)

    package com.guwenren.bean;
    
    import java.util.List;
    
    /**
     * 分页总类
     * @author guwenren
     *
     * @param <T>
     */
    public class PageView<T> {
        /** 分页数据 **/
        private List<T> records;
        /** 页码开始索引和结束索引 **/
        private PageIndex pageindex;
        /** 总页数 **/
        private long totalpage = 1;
        /** 每页显示记录数 **/
        private int maxresult = 12;
        /** 当前页 **/
        private int currentpage = 1;
        /** 总记录数 **/
        private long totalrecord;
        /** 页码数量 **/
        private int pagecode = 10;
    
        /** 要获取记录的开始索引 **/
        public int getFirstResult() {
            return (this.currentpage - 1) * this.maxresult;
        }
    
        public int getPagecode() {
            return pagecode;
        }
    
        public void setPagecode(int pagecode) {
            this.pagecode = pagecode;
        }
        public PageView(int currentpage) {
            this.currentpage = currentpage;
        }
        public PageView(int maxresult, int currentpage) {
            this.maxresult = maxresult;
            this.currentpage = currentpage;
        }
    
        public void setQueryResult(QueryResult<T> qr) {
            setTotalrecord(qr.getTotalrecord());
            setRecords(qr.getResultlist());
        }
    
        public long getTotalrecord() {
            return totalrecord;
        }
    
        public void setTotalrecord(long totalrecord) {
            this.totalrecord = totalrecord;
            setTotalpage(this.totalrecord % this.maxresult == 0 ? this.totalrecord / this.maxresult : this.totalrecord / this.maxresult + 1);
        }
    
        public List<T> getRecords() {
            return records;
        }
    
        public void setRecords(List<T> records) {
            this.records = records;
        }
    
        public PageIndex getPageindex() {
            return pageindex;
        }
    
        public long getTotalpage() {
            return totalpage;
        }
    
        public void setTotalpage(long totalpage) {
            this.totalpage = totalpage;
            this.pageindex = PageIndex.getPageIndex(pagecode, currentpage, totalpage);
        }
    
        public int getMaxresult() {
            return maxresult;
        }
    
        public int getCurrentpage() {
            return currentpage;
        }
    }
  • 相关阅读:
    HDU2546(01背包)
    HDU4283(KB22-G)
    POJ1651(KB-E)
    POJ2955(KB22-C 区间DP)
    POJ3264(KB7-G RMQ)
    POJ3468(KB7-C 线段树)
    POJ3616(KB12-R dp)
    Ubuntu16.04安装opencv for python/c++
    华中农业大学第五届程序设计大赛网络同步赛-L
    华中农业大学第五届程序设计大赛网络同步赛-K
  • 原文地址:https://www.cnblogs.com/guwenren/p/2994858.html
Copyright © 2011-2022 走看看