View Javadoc
1   /*
2    * Copyright 2012-2025 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  /**
24   * Pager for role type management.
25   */
26  public class RoleTypePager implements Serializable {
27  
28      /**
29       * Constructor.
30       */
31      public RoleTypePager() {
32          super();
33      }
34  
35      private static final long serialVersionUID = 1L;
36  
37      /**
38       * Default page size for pagination.
39       */
40      public static final int DEFAULT_PAGE_SIZE = 20;
41  
42      /**
43       * Default current page number for pagination.
44       */
45      public static final int DEFAULT_CURRENT_PAGE_NUMBER = 1;
46  
47      /**
48       * Total number of records.
49       */
50      private int allRecordCount;
51  
52      /**
53       * Total number of pages.
54       */
55      private int allPageCount;
56  
57      /**
58       * Flag indicating whether a previous page exists.
59       */
60      private boolean existPrePage;
61  
62      /**
63       * Flag indicating whether a next page exists.
64       */
65      private boolean existNextPage;
66  
67      /**
68       * List of page numbers for pagination navigation.
69       */
70      private List<Integer> pageNumberList;
71  
72      /**
73       * Number of records per page.
74       */
75      private int pageSize;
76  
77      /**
78       * Current page number in pagination.
79       */
80      private int currentPageNumber;
81  
82      /**
83       * ID of the role type.
84       */
85      public String id;
86  
87      /**
88       * Name of the role type.
89       */
90      public String name;
91  
92      /**
93       * Value of the role type.
94       */
95      public String value;
96  
97      /**
98       * Sort order of the role type.
99       */
100     public String sortOrder;
101 
102     /**
103      * The user who created the role type.
104      */
105     public String createdBy;
106 
107     /**
108      * The time when the role type was created.
109      */
110     public String createdTime;
111 
112     /**
113      * Version number of the role type.
114      */
115     public String versionNo;
116 
117     /**
118      * Clears the pager's state.
119      */
120     public void clear() {
121         allRecordCount = 0;
122         allPageCount = 0;
123         existPrePage = false;
124         existNextPage = false;
125         pageSize = getDefaultPageSize();
126         currentPageNumber = getDefaultCurrentPageNumber();
127 
128         id = null;
129         name = null;
130         value = null;
131         sortOrder = null;
132         createdBy = null;
133         createdTime = null;
134         versionNo = null;
135 
136     }
137 
138     /**
139      * Gets the default current page number.
140      * @return The default current page number.
141      */
142     protected int getDefaultCurrentPageNumber() {
143         return DEFAULT_CURRENT_PAGE_NUMBER;
144     }
145 
146     /**
147      * Gets the total number of records.
148      * @return The total number of records.
149      */
150     public int getAllRecordCount() {
151         return allRecordCount;
152     }
153 
154     /**
155      * Sets the total number of records.
156      * @param allRecordCount The total number of records.
157      */
158     public void setAllRecordCount(final int allRecordCount) {
159         this.allRecordCount = allRecordCount;
160     }
161 
162     /**
163      * Gets the total number of pages.
164      * @return The total number of pages.
165      */
166     public int getAllPageCount() {
167         return allPageCount;
168     }
169 
170     /**
171      * Sets the total number of pages.
172      * @param allPageCount The total number of pages.
173      */
174     public void setAllPageCount(final int allPageCount) {
175         this.allPageCount = allPageCount;
176     }
177 
178     /**
179      * Checks if a previous page exists.
180      * @return true if a previous page exists, false otherwise.
181      */
182     public boolean isExistPrePage() {
183         return existPrePage;
184     }
185 
186     /**
187      * Sets whether a previous page exists.
188      * @param existPrePage true if a previous page exists, false otherwise.
189      */
190     public void setExistPrePage(final boolean existPrePage) {
191         this.existPrePage = existPrePage;
192     }
193 
194     /**
195      * Checks if a next page exists.
196      * @return true if a next page exists, false otherwise.
197      */
198     public boolean isExistNextPage() {
199         return existNextPage;
200     }
201 
202     /**
203      * Sets whether a next page exists.
204      * @param existNextPage true if a next page exists, false otherwise.
205      */
206     public void setExistNextPage(final boolean existNextPage) {
207         this.existNextPage = existNextPage;
208     }
209 
210     /**
211      * Gets the page size.
212      * @return The page size.
213      */
214     public int getPageSize() {
215         if (pageSize <= 0) {
216             pageSize = getDefaultPageSize();
217         }
218         return pageSize;
219     }
220 
221     /**
222      * Sets the page size.
223      * @param pageSize The page size.
224      */
225     public void setPageSize(final int pageSize) {
226         this.pageSize = pageSize;
227     }
228 
229     /**
230      * Gets the current page number.
231      * @return The current page number.
232      */
233     public int getCurrentPageNumber() {
234         if (currentPageNumber <= 0) {
235             currentPageNumber = getDefaultCurrentPageNumber();
236         }
237         return currentPageNumber;
238     }
239 
240     /**
241      * Sets the current page number.
242      * @param currentPageNumber The current page number.
243      */
244     public void setCurrentPageNumber(final int currentPageNumber) {
245         this.currentPageNumber = currentPageNumber;
246     }
247 
248     /**
249      * Gets the list of page numbers.
250      * @return The list of page numbers.
251      */
252     public List<Integer> getPageNumberList() {
253         return pageNumberList;
254     }
255 
256     /**
257      * Sets the list of page numbers.
258      * @param pageNumberList The list of page numbers.
259      */
260     public void setPageNumberList(final List<Integer> pageNumberList) {
261         this.pageNumberList = pageNumberList;
262     }
263 
264     /**
265      * Gets the default page size from the Fess configuration.
266      * @return The default page size.
267      */
268     protected int getDefaultPageSize() {
269         return ComponentUtil.getFessConfig().getPagingPageSizeAsInteger();
270     }
271 
272 }