001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.bean;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    
019    import javax.servlet.http.HttpServletRequest;
020    
021    /**
022     * @author Brian Wing Shun Chan
023     */
024    public class BeanPropertiesUtil {
025    
026            public static void copyProperties(Object source, Object target) {
027                    getBeanProperties().copyProperties(source, target);
028            }
029    
030            public static void copyProperties(
031                    Object source, Object target, Class<?> editable) {
032    
033                    getBeanProperties().copyProperties(source, target, editable);
034            }
035    
036            public static void copyProperties(
037                    Object source, Object target, String[] ignoreProperties) {
038    
039                    getBeanProperties().copyProperties(source, target, ignoreProperties);
040            }
041    
042            public static BeanProperties getBeanProperties() {
043                    PortalRuntimePermission.checkGetBeanProperty(BeanPropertiesUtil.class);
044    
045                    return _beanProperties;
046            }
047    
048            public static boolean getBoolean(Object bean, String param) {
049                    return getBeanProperties().getBoolean(bean, param);
050            }
051    
052            public static boolean getBoolean(
053                    Object bean, String param, boolean defaultValue) {
054    
055                    return getBeanProperties().getBoolean(bean, param, defaultValue);
056            }
057    
058            public static boolean getBooleanSilent(Object bean, String param) {
059                    return getBeanProperties().getBooleanSilent(bean, param);
060            }
061    
062            public static boolean getBooleanSilent(
063                    Object bean, String param, boolean defaultValue) {
064    
065                    return getBeanProperties().getBooleanSilent(bean, param, defaultValue);
066            }
067    
068            public static byte getByte(Object bean, String param) {
069                    return getBeanProperties().getByte(bean, param);
070            }
071    
072            public static byte getByte(Object bean, String param, byte defaultValue) {
073                    return getBeanProperties().getByte(bean, param, defaultValue);
074            }
075    
076            public static byte getByteSilent(Object bean, String param) {
077                    return getBeanProperties().getByteSilent(bean, param);
078            }
079    
080            public static byte getByteSilent(
081                    Object bean, String param, byte defaultValue) {
082    
083                    return getBeanProperties().getByteSilent(bean, param, defaultValue);
084            }
085    
086            public static double getDouble(Object bean, String param) {
087                    return getBeanProperties().getDouble(bean, param);
088            }
089    
090            public static double getDouble(
091                    Object bean, String param, double defaultValue) {
092    
093                    return getBeanProperties().getDouble(bean, param, defaultValue);
094            }
095    
096            public static double getDoubleSilent(Object bean, String param) {
097                    return getBeanProperties().getDoubleSilent(bean, param);
098            }
099    
100            public static double getDoubleSilent(
101                    Object bean, String param, double defaultValue) {
102    
103                    return getBeanProperties().getDoubleSilent(bean, param, defaultValue);
104            }
105    
106            public static float getFloat(Object bean, String param) {
107                    return getBeanProperties().getFloat(bean, param);
108            }
109    
110            public static float getFloat(
111                    Object bean, String param, float defaultValue) {
112    
113                    return getBeanProperties().getFloat(bean, param, defaultValue);
114            }
115    
116            public static float getFloatSilent(Object bean, String param) {
117                    return getBeanProperties().getFloatSilent(bean, param);
118            }
119    
120            public static float getFloatSilent(
121                    Object bean, String param, float defaultValue) {
122    
123                    return getBeanProperties().getFloatSilent(bean, param, defaultValue);
124            }
125    
126            public static int getInteger(Object bean, String param) {
127                    return getBeanProperties().getInteger(bean, param);
128            }
129    
130            public static int getInteger(Object bean, String param, int defaultValue) {
131                    return getBeanProperties().getInteger(bean, param, defaultValue);
132            }
133    
134            public static int getIntegerSilent(Object bean, String param) {
135                    return getBeanProperties().getIntegerSilent(bean, param);
136            }
137    
138            public static int getIntegerSilent(
139                    Object bean, String param, int defaultValue) {
140    
141                    return getBeanProperties().getIntegerSilent(bean, param, defaultValue);
142            }
143    
144            public static long getLong(Object bean, String param) {
145                    return getBeanProperties().getLong(bean, param);
146            }
147    
148            public static long getLong(Object bean, String param, long defaultValue) {
149                    return getBeanProperties().getLong(bean, param, defaultValue);
150            }
151    
152            public static long getLongSilent(Object bean, String param) {
153                    return getBeanProperties().getLongSilent(bean, param);
154            }
155    
156            public static long getLongSilent(
157                    Object bean, String param, long defaultValue) {
158    
159                    return getBeanProperties().getLongSilent(bean, param, defaultValue);
160            }
161    
162            public static Object getObject(Object bean, String param) {
163                    return getBeanProperties().getObject(bean, param);
164            }
165    
166            public static Object getObject(
167                    Object bean, String param, Object defaultValue) {
168    
169                    return getBeanProperties().getObject(bean, param, defaultValue);
170            }
171    
172            public static Object getObjectSilent(Object bean, String param) {
173                    return getBeanProperties().getObjectSilent(bean, param);
174            }
175    
176            public static Object getObjectSilent(
177                    Object bean, String param, Object defaultValue) {
178    
179                    return getBeanProperties().getObjectSilent(bean, param, defaultValue);
180            }
181    
182            public static Class<?> getObjectType(Object bean, String param) {
183                    return getBeanProperties().getObjectType(bean, param);
184            }
185    
186            public static Class<?> getObjectType(
187                    Object bean, String param, Class<?> defaultValue) {
188    
189                    return getBeanProperties().getObjectType(bean, param, defaultValue);
190            }
191    
192            public static Class<?> getObjectTypeSilent(Object bean, String param) {
193                    return getBeanProperties().getObjectType(bean, param);
194            }
195    
196            public static Class<?> getObjectTypeSilent(
197                    Object bean, String param, Class<?> defaultValue) {
198    
199                    return getBeanProperties().getObjectType(bean, param, defaultValue);
200            }
201    
202            public static short getShort(Object bean, String param) {
203                    return getBeanProperties().getShort(bean, param);
204            }
205    
206            public static short getShort(
207                    Object bean, String param, short defaultValue) {
208    
209                    return getBeanProperties().getShort(bean, param, defaultValue);
210            }
211    
212            public static short getShortSilent(Object bean, String param) {
213                    return getBeanProperties().getShortSilent(bean, param);
214            }
215    
216            public static short getShortSilent(
217                    Object bean, String param, short defaultValue) {
218    
219                    return getBeanProperties().getShortSilent(bean, param, defaultValue);
220            }
221    
222            public static String getString(Object bean, String param) {
223                    return getBeanProperties().getString(bean, param);
224            }
225    
226            public static String getString(
227                    Object bean, String param, String defaultValue) {
228    
229                    return getBeanProperties().getString(bean, param, defaultValue);
230            }
231    
232            public static String getStringSilent(Object bean, String param) {
233                    return getBeanProperties().getStringSilent(bean, param);
234            }
235    
236            public static String getStringSilent(
237                    Object bean, String param, String defaultValue) {
238    
239                    return getBeanProperties().getStringSilent(bean, param, defaultValue);
240            }
241    
242            public static void setProperties(Object bean, HttpServletRequest request) {
243                    getBeanProperties().setProperties(bean, request);
244            }
245    
246            public static void setProperty(Object bean, String param, Object value) {
247                    getBeanProperties().setProperty(bean, param, value);
248            }
249    
250            public void setBeanProperties(BeanProperties beanProperties) {
251                    PortalRuntimePermission.checkSetBeanProperty(getClass());
252    
253                    _beanProperties = beanProperties;
254            }
255    
256            private static BeanProperties _beanProperties;
257    
258    }