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 class for web configuration settings.
25   * Provides pagination functionality and search criteria for web configuration listings.
26   */
27  public class WebConfigPager implements Serializable {
28  
29      /**
30       * Default constructor.
31       */
32      public WebConfigPager() {
33          // Default constructor
34      }
35  
36      private static final long serialVersionUID = 1L;
37  
38      /**
39       * Default page size for pagination.
40       */
41      public static final int DEFAULT_PAGE_SIZE = 20;
42  
43      /**
44       * Default current page number.
45       */
46      public static final int DEFAULT_CURRENT_PAGE_NUMBER = 1;
47  
48      /**
49       * Total number of records.
50       */
51      private int allRecordCount;
52  
53      /**
54       * Total number of pages.
55       */
56      private int allPageCount;
57  
58      /**
59       * Flag indicating if a previous page exists.
60       */
61      private boolean existPrePage;
62  
63      /**
64       * Flag indicating if a next page exists.
65       */
66      private boolean existNextPage;
67  
68      /**
69       * List of page numbers for pagination.
70       */
71      private List<Integer> pageNumberList;
72  
73      /**
74       * Number of records per page.
75       */
76      private int pageSize;
77  
78      /**
79       * Current page number.
80       */
81      private int currentPageNumber;
82  
83      /**
84       * Search criteria: configuration ID.
85       */
86      public String id;
87  
88      /**
89       * Search criteria: configuration name.
90       */
91      public String name;
92  
93      /**
94       * Search criteria: target URLs.
95       */
96      public String urls;
97  
98      /**
99       * Search criteria: user agent string.
100      */
101     public String userAgent;
102 
103     /**
104      * Search criteria: number of threads.
105      */
106     public String numOfThread;
107 
108     /**
109      * Search criteria: interval time.
110      */
111     public String intervalTime;
112 
113     /**
114      * Search criteria: boost value.
115      */
116     public String boost;
117 
118     /**
119      * Search criteria: availability status.
120      */
121     public String available;
122 
123     /**
124      * Search criteria: sort order.
125      */
126     public String sortOrder;
127 
128     /**
129      * Search criteria: creator user.
130      */
131     public String createdBy;
132 
133     /**
134      * Search criteria: creation time.
135      */
136     public String createdTime;
137 
138     /**
139      * Search criteria: version number.
140      */
141     public String versionNo;
142 
143     /**
144      * Search criteria: configuration description.
145      */
146     public String description;
147 
148     /**
149      * Clears all pager data and search criteria.
150      */
151     public void clear() {
152         allRecordCount = 0;
153         allPageCount = 0;
154         existPrePage = false;
155         existNextPage = false;
156         pageSize = getDefaultPageSize();
157         currentPageNumber = getDefaultCurrentPageNumber();
158 
159         id = null;
160         name = null;
161         urls = null;
162         userAgent = null;
163         numOfThread = null;
164         intervalTime = null;
165         boost = null;
166         available = null;
167         sortOrder = null;
168         createdBy = null;
169         createdTime = null;
170         versionNo = null;
171         description = null;
172 
173     }
174 
175     /**
176      * Gets the default current page number.
177      *
178      * @return The default current page number
179      */
180     protected int getDefaultCurrentPageNumber() {
181         return DEFAULT_CURRENT_PAGE_NUMBER;
182     }
183 
184     /**
185      * Gets the total number of records.
186      *
187      * @return The total record count
188      */
189     public int getAllRecordCount() {
190         return allRecordCount;
191     }
192 
193     /**
194      * Sets the total number of records.
195      *
196      * @param allRecordCount The total record count
197      */
198     public void setAllRecordCount(final int allRecordCount) {
199         this.allRecordCount = allRecordCount;
200     }
201 
202     /**
203      * Gets the total number of pages.
204      *
205      * @return The total page count
206      */
207     public int getAllPageCount() {
208         return allPageCount;
209     }
210 
211     /**
212      * Sets the total number of pages.
213      *
214      * @param allPageCount The total page count
215      */
216     public void setAllPageCount(final int allPageCount) {
217         this.allPageCount = allPageCount;
218     }
219 
220     /**
221      * Checks if a previous page exists.
222      *
223      * @return True if a previous page exists, false otherwise
224      */
225     public boolean isExistPrePage() {
226         return existPrePage;
227     }
228 
229     /**
230      * Sets whether a previous page exists.
231      *
232      * @param existPrePage True if a previous page exists
233      */
234     public void setExistPrePage(final boolean existPrePage) {
235         this.existPrePage = existPrePage;
236     }
237 
238     /**
239      * Checks if a next page exists.
240      *
241      * @return True if a next page exists, false otherwise
242      */
243     public boolean isExistNextPage() {
244         return existNextPage;
245     }
246 
247     /**
248      * Sets whether a next page exists.
249      *
250      * @param existNextPage True if a next page exists
251      */
252     public void setExistNextPage(final boolean existNextPage) {
253         this.existNextPage = existNextPage;
254     }
255 
256     /**
257      * Gets the page size.
258      *
259      * @return The number of records per page
260      */
261     public int getPageSize() {
262         if (pageSize <= 0) {
263             pageSize = getDefaultPageSize();
264         }
265         return pageSize;
266     }
267 
268     /**
269      * Sets the page size.
270      *
271      * @param pageSize The number of records per page
272      */
273     public void setPageSize(final int pageSize) {
274         this.pageSize = pageSize;
275     }
276 
277     /**
278      * Gets the current page number.
279      *
280      * @return The current page number
281      */
282     public int getCurrentPageNumber() {
283         if (currentPageNumber <= 0) {
284             currentPageNumber = getDefaultCurrentPageNumber();
285         }
286         return currentPageNumber;
287     }
288 
289     /**
290      * Sets the current page number.
291      *
292      * @param currentPageNumber The current page number
293      */
294     public void setCurrentPageNumber(final int currentPageNumber) {
295         this.currentPageNumber = currentPageNumber;
296     }
297 
298     /**
299      * Gets the list of page numbers for pagination.
300      *
301      * @return The list of page numbers
302      */
303     public List<Integer> getPageNumberList() {
304         return pageNumberList;
305     }
306 
307     /**
308      * Sets the list of page numbers for pagination.
309      *
310      * @param pageNumberList The list of page numbers
311      */
312     public void setPageNumberList(final List<Integer> pageNumberList) {
313         this.pageNumberList = pageNumberList;
314     }
315 
316     /**
317      * Gets the default page size from configuration.
318      *
319      * @return The default page size
320      */
321     protected int getDefaultPageSize() {
322         return ComponentUtil.getFessConfig().getPagingPageSizeAsInteger();
323     }
324 
325 }