1 package com.haoyisheng.util;
 2 
 3 import java.io.Serializable;
 4 import java.util.List;
 5 
 6 /**
 7  * page list Model
 8  * @author gong.xiangfei
 9  */
10 public class PageModel<T> implements Serializable{
11 
12     private static final long serialVersionUID = 1L;
13     /**
14      * The pr. page maximum can display of the record number default 10
15      */
16     private int page_list_count=10;
17     /**
18      * Current page
19      */
20     @SuppressWarnings("unused")
21     private int curpage;
22 
23     /**
24      * The current page result gathers
25      */
26     private List<T> datas;
27 
28     /**
29      * Satisfy a condition of total recording a number
30      */
31     private int total;
32 
33     private int offset;
34 
35     @SuppressWarnings("unused")
36     private int pagecount;
37 
38     public PageModel(){
39         this.offset= PageNumberFilter.getOffSet();
40     }
41 
42     public PageModel(int total,List<T> datas,int offset){
43         this.total=total;
44         this.datas=datas;
45         this.offset=offset;
46     }
47     /**
48      * Total number of pages,in view use el ${xx.pagecount}
49      * @return int
50      */
51     public int getPageCount() {
52         return (total==0?0:total/page_list_count)+(total%page_list_count==0?0:1);
53     }
54     /**
55      * Current page NO
56      * @return int
57      */
58     public int getCurpage() {
59         return offset/page_list_count+1;
60     }
61 
62     public List<T> getDatas() {
63         return datas;
64     }
65 
66     public int getTotal() {
67 
68         return total;
69     }
70 
71     public void setCurpage(int curpage) {
72         this.curpage = curpage;
73     }
74 
75     public void setDatas(List<T> datas) {
76         this.datas = datas;
77     }
78 
79     public void setTotal(int total) {
80         this.total = total;
81     }
82 
83     public void setPage_list_count(int page_list_count) {
84         this.page_list_count = page_list_count;
85     }
86 
87     public int getPage_list_count() {
88         return page_list_count;
89     }
90 
91     public void setOffset(int offset) {
92         this.offset = offset;
93     }
94 
95     public int getOffset() {
96         return offset;
97     }
98 
99 }

 

posted on 2016-06-29 15:16  Sharpest  阅读(738)  评论(0编辑  收藏  举报