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