View Javadoc
1   /*
2    * Copyright 2012-2021 CodeLibs Project and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.codelibs.fess.app.pager;
17  
18  import java.io.Serializable;
19  import java.util.List;
20  
21  import org.codelibs.fess.util.ComponentUtil;
22  
23  public class UserPager implements Serializable {
24  
25      private static final long serialVersionUID = 1L;
26  
27      public static final int DEFAULT_PAGE_SIZE = 20;
28  
29      public static final int DEFAULT_CURRENT_PAGE_NUMBER = 1;
30  
31      private int allRecordCount;
32  
33      private int allPageCount;
34  
35      private boolean existPrePage;
36  
37      private boolean existNextPage;
38  
39      private List<Integer> pageNumberList;
40  
41      private int pageSize;
42  
43      private int currentPageNumber;
44  
45      public String id;
46  
47      public String name;
48  
49      public String[] roles;
50  
51      public String[] groups;
52  
53      public String versionNo;
54  
55      public void clear() {
56          allRecordCount = 0;
57          allPageCount = 0;
58          existPrePage = false;
59          existNextPage = false;
60          pageSize = getDefaultPageSize();
61          currentPageNumber = getDefaultCurrentPageNumber();
62  
63          id = null;
64          roles = null;
65          groups = null;
66          versionNo = null;
67  
68      }
69  
70      protected int getDefaultCurrentPageNumber() {
71          return DEFAULT_CURRENT_PAGE_NUMBER;
72      }
73  
74      public int getAllRecordCount() {
75          return allRecordCount;
76      }
77  
78      public void setAllRecordCount(final int allRecordCount) {
79          this.allRecordCount = allRecordCount;
80      }
81  
82      public int getAllPageCount() {
83          return allPageCount;
84      }
85  
86      public void setAllPageCount(final int allPageCount) {
87          this.allPageCount = allPageCount;
88      }
89  
90      public boolean isExistPrePage() {
91          return existPrePage;
92      }
93  
94      public void setExistPrePage(final boolean existPrePage) {
95          this.existPrePage = existPrePage;
96      }
97  
98      public boolean isExistNextPage() {
99          return existNextPage;
100     }
101 
102     public void setExistNextPage(final boolean existNextPage) {
103         this.existNextPage = existNextPage;
104     }
105 
106     public int getPageSize() {
107         if (pageSize <= 0) {
108             pageSize = getDefaultPageSize();
109         }
110         return pageSize;
111     }
112 
113     public void setPageSize(final int pageSize) {
114         this.pageSize = pageSize;
115     }
116 
117     public int getCurrentPageNumber() {
118         if (currentPageNumber <= 0) {
119             currentPageNumber = getDefaultCurrentPageNumber();
120         }
121         return currentPageNumber;
122     }
123 
124     public void setCurrentPageNumber(final int currentPageNumber) {
125         this.currentPageNumber = currentPageNumber;
126     }
127 
128     public List<Integer> getPageNumberList() {
129         return pageNumberList;
130     }
131 
132     public void setPageNumberList(final List<Integer> pageNumberList) {
133         this.pageNumberList = pageNumberList;
134     }
135 
136     protected int getDefaultPageSize() {
137         return ComponentUtil.getFessConfig().getPagingPageSizeAsInteger();
138     }
139 
140 }