001
014
015 package com.liferay.portal.kernel.bean;
016
017 import com.liferay.portal.kernel.util.GetterUtil;
018 import com.liferay.portal.kernel.util.ParamUtil;
019
020 import javax.portlet.PortletRequest;
021
022 import javax.servlet.http.HttpServletRequest;
023
024
027 public class BeanParamUtil {
028
029 public static boolean getBoolean(
030 Object bean, HttpServletRequest request, String param) {
031
032 return getBoolean(bean, request, param, GetterUtil.DEFAULT_BOOLEAN);
033 }
034
035 public static boolean getBoolean(
036 Object bean, HttpServletRequest request, String param,
037 boolean defaultValue) {
038
039 defaultValue = BeanPropertiesUtil.getBoolean(bean, param, defaultValue);
040
041 return ParamUtil.get(request, param, defaultValue);
042 }
043
044 public static boolean getBoolean(
045 Object bean, PortletRequest portletRequest, String param) {
046
047 return getBoolean(
048 bean, portletRequest, param, GetterUtil.DEFAULT_BOOLEAN);
049 }
050
051 public static boolean getBoolean(
052 Object bean, PortletRequest portletRequest, String param,
053 boolean defaultValue) {
054
055 defaultValue = BeanPropertiesUtil.getBoolean(bean, param, defaultValue);
056
057 return ParamUtil.get(portletRequest, param, defaultValue);
058 }
059
060 public static boolean getBooleanSilent(
061 Object bean, HttpServletRequest request, String param) {
062
063 return getBooleanSilent(
064 bean, request, param, GetterUtil.DEFAULT_BOOLEAN);
065 }
066
067 public static boolean getBooleanSilent(
068 Object bean, HttpServletRequest request, String param,
069 boolean defaultValue) {
070
071 defaultValue = BeanPropertiesUtil.getBooleanSilent(
072 bean, param, defaultValue);
073
074 return ParamUtil.get(request, param, defaultValue);
075 }
076
077 public static boolean getBooleanSilent(
078 Object bean, PortletRequest portletRequest, String param) {
079
080 return getBooleanSilent(
081 bean, portletRequest, param, GetterUtil.DEFAULT_BOOLEAN);
082 }
083
084 public static boolean getBooleanSilent(
085 Object bean, PortletRequest portletRequest, String param,
086 boolean defaultValue) {
087
088 defaultValue = BeanPropertiesUtil.getBooleanSilent(
089 bean, param, defaultValue);
090
091 return ParamUtil.get(portletRequest, param, defaultValue);
092 }
093
094 public static double getDouble(
095 Object bean, HttpServletRequest request, String param) {
096
097 return getDouble(bean, request, param, GetterUtil.DEFAULT_DOUBLE);
098 }
099
100 public static double getDouble(
101 Object bean, HttpServletRequest request, String param,
102 double defaultValue) {
103
104 defaultValue = BeanPropertiesUtil.getDouble(bean, param, defaultValue);
105
106 return ParamUtil.get(request, param, defaultValue);
107 }
108
109 public static double getDouble(
110 Object bean, PortletRequest portletRequest, String param) {
111
112 return getDouble(
113 bean, portletRequest, param, GetterUtil.DEFAULT_DOUBLE);
114 }
115
116 public static double getDouble(
117 Object bean, PortletRequest portletRequest, String param,
118 double defaultValue) {
119
120 defaultValue = BeanPropertiesUtil.getDouble(bean, param, defaultValue);
121
122 return ParamUtil.get(portletRequest, param, defaultValue);
123 }
124
125 public static double getDoubleSilent(
126 Object bean, HttpServletRequest request, String param) {
127
128 return getDoubleSilent(bean, request, param, GetterUtil.DEFAULT_DOUBLE);
129 }
130
131 public static double getDoubleSilent(
132 Object bean, HttpServletRequest request, String param,
133 double defaultValue) {
134
135 defaultValue = BeanPropertiesUtil.getDoubleSilent(
136 bean, param, defaultValue);
137
138 return ParamUtil.get(request, param, defaultValue);
139 }
140
141 public static double getDoubleSilent(
142 Object bean, PortletRequest portletRequest, String param) {
143
144 return getDoubleSilent(
145 bean, portletRequest, param, GetterUtil.DEFAULT_DOUBLE);
146 }
147
148 public static double getDoubleSilent(
149 Object bean, PortletRequest portletRequest, String param,
150 double defaultValue) {
151
152 defaultValue = BeanPropertiesUtil.getDoubleSilent(
153 bean, param, defaultValue);
154
155 return ParamUtil.get(portletRequest, param, defaultValue);
156 }
157
158 public static int getInteger(
159 Object bean, HttpServletRequest request, String param) {
160
161 return getInteger(bean, request, param, GetterUtil.DEFAULT_INTEGER);
162 }
163
164 public static int getInteger(
165 Object bean, HttpServletRequest request, String param,
166 int defaultValue) {
167
168 defaultValue = BeanPropertiesUtil.getInteger(bean, param, defaultValue);
169
170 return ParamUtil.get(request, param, defaultValue);
171 }
172
173 public static int getInteger(
174 Object bean, PortletRequest portletRequest, String param) {
175
176 return getInteger(
177 bean, portletRequest, param, GetterUtil.DEFAULT_INTEGER);
178 }
179
180 public static int getInteger(
181 Object bean, PortletRequest portletRequest, String param,
182 int defaultValue) {
183
184 defaultValue = BeanPropertiesUtil.getInteger(bean, param, defaultValue);
185
186 return ParamUtil.get(portletRequest, param, defaultValue);
187 }
188
189 public static int getIntegerSilent(
190 Object bean, HttpServletRequest request, String param) {
191
192 return getIntegerSilent(
193 bean, request, param, GetterUtil.DEFAULT_INTEGER);
194 }
195
196 public static int getIntegerSilent(
197 Object bean, HttpServletRequest request, String param,
198 int defaultValue) {
199
200 defaultValue = BeanPropertiesUtil.getIntegerSilent(
201 bean, param, defaultValue);
202
203 return ParamUtil.get(request, param, defaultValue);
204 }
205
206 public static int getIntegerSilent(
207 Object bean, PortletRequest portletRequest, String param) {
208
209 return getIntegerSilent(
210 bean, portletRequest, param, GetterUtil.DEFAULT_INTEGER);
211 }
212
213 public static int getIntegerSilent(
214 Object bean, PortletRequest portletRequest, String param,
215 int defaultValue) {
216
217 defaultValue = BeanPropertiesUtil.getIntegerSilent(
218 bean, param, defaultValue);
219
220 return ParamUtil.get(portletRequest, param, defaultValue);
221 }
222
223 public static long getLong(
224 Object bean, HttpServletRequest request, String param) {
225
226 return getLong(bean, request, param, GetterUtil.DEFAULT_LONG);
227 }
228
229 public static long getLong(
230 Object bean, HttpServletRequest request, String param,
231 long defaultValue) {
232
233 defaultValue = BeanPropertiesUtil.getLong(bean, param, defaultValue);
234
235 return ParamUtil.get(request, param, defaultValue);
236 }
237
238 public static long getLong(
239 Object bean, PortletRequest portletRequest, String param) {
240
241 return getLong(bean, portletRequest, param, GetterUtil.DEFAULT_LONG);
242 }
243
244 public static long getLong(
245 Object bean, PortletRequest portletRequest, String param,
246 long defaultValue) {
247
248 defaultValue = BeanPropertiesUtil.getLong(bean, param, defaultValue);
249
250 return ParamUtil.get(portletRequest, param, defaultValue);
251 }
252
253 public static long getLongSilent(
254 Object bean, HttpServletRequest request, String param) {
255
256 return getLongSilent(bean, request, param, GetterUtil.DEFAULT_LONG);
257 }
258
259 public static long getLongSilent(
260 Object bean, HttpServletRequest request, String param,
261 long defaultValue) {
262
263 defaultValue = BeanPropertiesUtil.getLongSilent(
264 bean, param, defaultValue);
265
266 return ParamUtil.get(request, param, defaultValue);
267 }
268
269 public static long getLongSilent(
270 Object bean, PortletRequest portletRequest, String param) {
271
272 return getLongSilent(
273 bean, portletRequest, param, GetterUtil.DEFAULT_LONG);
274 }
275
276 public static long getLongSilent(
277 Object bean, PortletRequest portletRequest, String param,
278 long defaultValue) {
279
280 defaultValue = BeanPropertiesUtil.getLongSilent(
281 bean, param, defaultValue);
282
283 return ParamUtil.get(portletRequest, param, defaultValue);
284 }
285
286 public static String getString(
287 Object bean, HttpServletRequest request, String param) {
288
289 return getString(bean, request, param, GetterUtil.DEFAULT_STRING);
290 }
291
292 public static String getString(
293 Object bean, HttpServletRequest request, String param,
294 String defaultValue) {
295
296 defaultValue = BeanPropertiesUtil.getString(bean, param, defaultValue);
297
298 return ParamUtil.get(request, param, defaultValue);
299 }
300
301 public static String getString(
302 Object bean, PortletRequest portletRequest, String param) {
303
304 return getString(
305 bean, portletRequest, param, GetterUtil.DEFAULT_STRING);
306 }
307
308 public static String getString(
309 Object bean, PortletRequest portletRequest, String param,
310 String defaultValue) {
311
312 defaultValue = BeanPropertiesUtil.getString(bean, param, defaultValue);
313
314 return ParamUtil.get(portletRequest, param, defaultValue);
315 }
316
317 public static String getStringSilent(
318 Object bean, HttpServletRequest request, String param) {
319
320 return getStringSilent(bean, request, param, GetterUtil.DEFAULT_STRING);
321 }
322
323 public static String getStringSilent(
324 Object bean, HttpServletRequest request, String param,
325 String defaultValue) {
326
327 defaultValue = BeanPropertiesUtil.getStringSilent(
328 bean, param, defaultValue);
329
330 return ParamUtil.get(request, param, defaultValue);
331 }
332
333 public static String getStringSilent(
334 Object bean, PortletRequest portletRequest, String param) {
335
336 return getStringSilent(
337 bean, portletRequest, param, GetterUtil.DEFAULT_STRING);
338 }
339
340 public static String getStringSilent(
341 Object bean, PortletRequest portletRequest, String param,
342 String defaultValue) {
343
344 defaultValue = BeanPropertiesUtil.getStringSilent(
345 bean, param, defaultValue);
346
347 return ParamUtil.get(portletRequest, param, defaultValue);
348 }
349
350 }