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 character mapping management with pagination support.
25   * Provides pagination functionality for character mapping lists.
26   */
27  public class CharMappingPager implements Serializable {
28  
29      private static final long serialVersionUID = 1L;
30  
31      /** Total number of records across all pages. */
32      private int allRecordCount;
33  
34      /** Total number of pages available. */
35      private int allPageCount;
36  
37      /** Flag indicating if a previous page exists. */
38      private boolean existPrePage;
39  
40      /** Flag indicating if a next page exists. */
41      private boolean existNextPage;
42  
43      /** List of page numbers for pagination navigation. */
44      private List<Integer> pageNumberList;
45  
46      /** Number of records to display per page. */
47      private int pageSize;
48  
49      /** Current page number being displayed. */
50      private int currentPageNumber;
51  
52      /** Character mapping ID for search filtering. */
53      public String id;
54  
55      /**
56       * Default constructor for CharMappingPager.
57       */
58      public CharMappingPager() {
59          // Default constructor
60      }
61  
62      /**
63       * Clears all search criteria and resets pagination settings.
64       */
65      public void clear() {
66          allRecordCount = 0;
67          allPageCount = 0;
68          existPrePage = false;
69          existNextPage = false;
70          pageSize = getDefaultPageSize();
71          currentPageNumber = getDefaultCurrentPageNumber();
72  
73          id = null;
74      }
75  
76      /**
77       * Gets the default page size from configuration.
78       * @return The default page size.
79       */
80      protected int getDefaultPageSize() {
81          return ComponentUtil.getFessConfig().getPagingPageSizeAsInteger();
82      }
83  
84      /**
85       * Gets the default current page number.
86       * @return The default current page number.
87       */
88      protected int getDefaultCurrentPageNumber() {
89          return 1;
90      }
91  
92      /**
93       * Gets the total number of records.
94       * @return The total record count.
95       */
96      public int getAllRecordCount() {
97          return allRecordCount;
98      }
99  
100     /**
101      * Sets the total number of records.
102      * @param allRecordCount The total record count.
103      */
104     public void setAllRecordCount(final int allRecordCount) {
105         this.allRecordCount = allRecordCount;
106     }
107 
108     /**
109      * Gets the total number of pages.
110      * @return The total page count.
111      */
112     public int getAllPageCount() {
113         return allPageCount;
114     }
115 
116     /**
117      * Sets the total number of pages.
118      * @param allPageCount The total page count.
119      */
120     public void setAllPageCount(final int allPageCount) {
121         this.allPageCount = allPageCount;
122     }
123 
124     /**
125      * Checks if there is a previous page.
126      * @return True if a previous page exists, false otherwise.
127      */
128     public boolean isExistPrePage() {
129         return existPrePage;
130     }
131 
132     /**
133      * Sets the existence of a previous page.
134      * @param existPrePage True if a previous page exists.
135      */
136     public void setExistPrePage(final boolean existPrePage) {
137         this.existPrePage = existPrePage;
138     }
139 
140     /**
141      * Checks if there is a next page.
142      * @return True if a next page exists, false otherwise.
143      */
144     public boolean isExistNextPage() {
145         return existNextPage;
146     }
147 
148     /**
149      * Sets the existence of a next page.
150      * @param existNextPage True if a next page exists.
151      */
152     public void setExistNextPage(final boolean existNextPage) {
153         this.existNextPage = existNextPage;
154     }
155 
156     /**
157      * Gets the page size for pagination.
158      * @return The page size.
159      */
160     public int getPageSize() {
161         if (pageSize <= 0) {
162             pageSize = getDefaultPageSize();
163         }
164         return pageSize;
165     }
166 
167     /**
168      * Sets the page size for pagination.
169      * @param pageSize The page size.
170      */
171     public void setPageSize(final int pageSize) {
172         this.pageSize = pageSize;
173     }
174 
175     /**
176      * Gets the current page number.
177      * @return The current page number.
178      */
179     public int getCurrentPageNumber() {
180         if (currentPageNumber <= 0) {
181             currentPageNumber = getDefaultCurrentPageNumber();
182         }
183         return currentPageNumber;
184     }
185 
186     /**
187      * Sets the current page number.
188      * @param currentPageNumber The current page number.
189      */
190     public void setCurrentPageNumber(final int currentPageNumber) {
191         this.currentPageNumber = currentPageNumber;
192     }
193 
194     /**
195      * Gets the list of page numbers for pagination navigation.
196      * @return The list of page numbers.
197      */
198     public List<Integer> getPageNumberList() {
199         return pageNumberList;
200     }
201 
202     /**
203      * Sets the list of page numbers for pagination navigation.
204      * @param pageNumberList The list of page numbers.
205      */
206     public void setPageNumberList(final List<Integer> pageNumberList) {
207         this.pageNumberList = pageNumberList;
208     }
209 }