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