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   * Pagination support class for ElevateWord entities.
25   * Provides pagination functionality and holds search form parameters
26   * for elevate word management in the admin interface.
27   */
28  public class ElevateWordPager implements Serializable {
29  
30      private static final long serialVersionUID = 1L;
31  
32      /**
33       * Default constructor.
34       */
35      public ElevateWordPager() {
36          // Default constructor
37      }
38  
39      /** Default page size for pagination */
40      public static final int DEFAULT_PAGE_SIZE = 20;
41  
42      /** Default current page number */
43      public static final int DEFAULT_CURRENT_PAGE_NUMBER = 1;
44  
45      /** Total number of records available */
46      private int allRecordCount;
47  
48      /** Total number of pages available */
49      private int allPageCount;
50  
51      /** Flag indicating if previous page exists */
52      private boolean existPrePage;
53  
54      /** Flag indicating if next page exists */
55      private boolean existNextPage;
56  
57      /** List of page numbers for pagination display */
58      private List<Integer> pageNumberList;
59  
60      /** Number of records per page */
61      private int pageSize;
62  
63      /** Current page number */
64      private int currentPageNumber;
65  
66      /** Search parameter: elevate word ID */
67      public String id;
68  
69      /** Search parameter: suggest word */
70      public String suggestWord;
71  
72      /** Search parameter: boost value */
73      public String boost;
74  
75      /** Search parameter: created by user */
76      public String createdBy;
77  
78      /** Search parameter: creation time */
79      public String createdTime;
80  
81      /** Search parameter: version number */
82      public String versionNo;
83  
84      /**
85       * Clears all pagination data and search parameters.
86       * Resets counters, flags, and search form fields to their default values.
87       */
88      public void clear() {
89          allRecordCount = 0;
90          allPageCount = 0;
91          existPrePage = false;
92          existNextPage = false;
93          pageSize = getDefaultPageSize();
94          currentPageNumber = getDefaultCurrentPageNumber();
95  
96          id = null;
97          suggestWord = null;
98          boost = null;
99          createdBy = null;
100         createdTime = null;
101         versionNo = null;
102 
103     }
104 
105     /**
106      * Gets the default current page number.
107      *
108      * @return the default current page number
109      */
110     protected int getDefaultCurrentPageNumber() {
111         return DEFAULT_CURRENT_PAGE_NUMBER;
112     }
113 
114     /**
115      * Gets the total number of records available.
116      *
117      * @return the total record count
118      */
119     public int getAllRecordCount() {
120         return allRecordCount;
121     }
122 
123     /**
124      * Sets the total number of records available.
125      *
126      * @param allRecordCount the total record count
127      */
128     public void setAllRecordCount(final int allRecordCount) {
129         this.allRecordCount = allRecordCount;
130     }
131 
132     /**
133      * Gets the total number of pages available.
134      *
135      * @return the total page count
136      */
137     public int getAllPageCount() {
138         return allPageCount;
139     }
140 
141     /**
142      * Sets the total number of pages available.
143      *
144      * @param allPageCount the total page count
145      */
146     public void setAllPageCount(final int allPageCount) {
147         this.allPageCount = allPageCount;
148     }
149 
150     /**
151      * Checks if a previous page exists.
152      *
153      * @return true if previous page exists, false otherwise
154      */
155     public boolean isExistPrePage() {
156         return existPrePage;
157     }
158 
159     /**
160      * Sets the flag indicating if a previous page exists.
161      *
162      * @param existPrePage true if previous page exists, false otherwise
163      */
164     public void setExistPrePage(final boolean existPrePage) {
165         this.existPrePage = existPrePage;
166     }
167 
168     /**
169      * Checks if a next page exists.
170      *
171      * @return true if next page exists, false otherwise
172      */
173     public boolean isExistNextPage() {
174         return existNextPage;
175     }
176 
177     /**
178      * Sets the flag indicating if a next page exists.
179      *
180      * @param existNextPage true if next page exists, false otherwise
181      */
182     public void setExistNextPage(final boolean existNextPage) {
183         this.existNextPage = existNextPage;
184     }
185 
186     /**
187      * Gets the number of records per page.
188      * If page size is not set or invalid, returns the default page size.
189      *
190      * @return the page size
191      */
192     public int getPageSize() {
193         if (pageSize <= 0) {
194             pageSize = getDefaultPageSize();
195         }
196         return pageSize;
197     }
198 
199     /**
200      * Sets the number of records per page.
201      *
202      * @param pageSize the page size
203      */
204     public void setPageSize(final int pageSize) {
205         this.pageSize = pageSize;
206     }
207 
208     /**
209      * Gets the current page number.
210      * If current page number is not set or invalid, returns the default page number.
211      *
212      * @return the current page number
213      */
214     public int getCurrentPageNumber() {
215         if (currentPageNumber <= 0) {
216             currentPageNumber = getDefaultCurrentPageNumber();
217         }
218         return currentPageNumber;
219     }
220 
221     /**
222      * Sets the current page number.
223      *
224      * @param currentPageNumber the current page number
225      */
226     public void setCurrentPageNumber(final int currentPageNumber) {
227         this.currentPageNumber = currentPageNumber;
228     }
229 
230     /**
231      * Gets the list of page numbers for pagination display.
232      *
233      * @return the list of page numbers
234      */
235     public List<Integer> getPageNumberList() {
236         return pageNumberList;
237     }
238 
239     /**
240      * Sets the list of page numbers for pagination display.
241      *
242      * @param pageNumberList the list of page numbers
243      */
244     public void setPageNumberList(final List<Integer> pageNumberList) {
245         this.pageNumberList = pageNumberList;
246     }
247 
248     /**
249      * Gets the default page size from the system configuration.
250      *
251      * @return the default page size
252      */
253     protected int getDefaultPageSize() {
254         return ComponentUtil.getFessConfig().getPagingPageSizeAsInteger();
255     }
256 
257 }