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.util;
016    
017    import com.liferay.portal.kernel.exception.SystemException;
018    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
019    
020    import java.util.Properties;
021    
022    import javax.portlet.PortletPreferences;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     */
027    public class PrefsPropsUtil {
028    
029            public static boolean getBoolean(long companyId, String name)
030                    throws SystemException {
031    
032                    return getPrefsProps().getBoolean(companyId, name);
033            }
034    
035            public static boolean getBoolean(
036                            long companyId, String name, boolean defaultValue)
037                    throws SystemException {
038    
039                    return getPrefsProps().getBoolean(companyId, name, defaultValue);
040            }
041    
042            public static boolean getBoolean(
043                    PortletPreferences preferences, long companyId, String name) {
044    
045                    return getPrefsProps().getBoolean(preferences, companyId, name);
046            }
047    
048            public static boolean getBoolean(
049                    PortletPreferences preferences, long companyId, String name,
050                    boolean defaultValue) {
051    
052                    return getPrefsProps().getBoolean(
053                            preferences, companyId, name, defaultValue);
054            }
055    
056            public static boolean getBoolean(String name) throws SystemException {
057                    return getPrefsProps().getBoolean(name);
058            }
059    
060            public static boolean getBoolean(String name, boolean defaultValue)
061                    throws SystemException {
062    
063                    return getPrefsProps().getBoolean(name, defaultValue);
064            }
065    
066            public static String getContent(long companyId, String name)
067                    throws SystemException {
068    
069                    return getPrefsProps().getContent(companyId, name);
070            }
071    
072            public static String getContent(
073                    PortletPreferences preferences, long companyId, String name) {
074    
075                    return getPrefsProps().getContent(preferences, companyId, name);
076            }
077    
078            public static String getContent(String name) throws SystemException {
079                    return getPrefsProps().getContent(name);
080            }
081    
082            public static double getDouble(long companyId, String name)
083                    throws SystemException {
084    
085                    return getPrefsProps().getDouble(companyId, name);
086            }
087    
088            public static double getDouble(
089                            long companyId, String name, double defaultValue)
090                    throws SystemException {
091    
092                    return getPrefsProps().getDouble(companyId, name, defaultValue);
093            }
094    
095            public static double getDouble(
096                    PortletPreferences preferences, long companyId, String name) {
097    
098                    return getPrefsProps().getDouble(preferences, companyId, name);
099            }
100    
101            public static double getDouble(
102                    PortletPreferences preferences, long companyId, String name,
103                    double defaultValue) {
104    
105                    return getPrefsProps().getDouble(
106                            preferences, companyId, name, defaultValue);
107            }
108    
109            public static double getDouble(String name) throws SystemException {
110                    return getPrefsProps().getDouble(name);
111            }
112    
113            public static double getDouble(String name, double defaultValue)
114                    throws SystemException {
115    
116                    return getPrefsProps().getDouble(name, defaultValue);
117            }
118    
119            public static int getInteger(long companyId, String name)
120                    throws SystemException {
121    
122                    return getPrefsProps().getInteger(companyId, name);
123            }
124    
125            public static int getInteger(long companyId, String name, int defaultValue)
126                    throws SystemException {
127    
128                    return getPrefsProps().getInteger(companyId, name, defaultValue);
129            }
130    
131            public static int getInteger(
132                    PortletPreferences preferences, long companyId, String name) {
133    
134                    return getPrefsProps().getInteger(preferences, companyId, name);
135            }
136    
137            public static int getInteger(
138                    PortletPreferences preferences, long companyId, String name,
139                    int defaultValue) {
140    
141                    return getPrefsProps().getInteger(
142                            preferences, companyId, name, defaultValue);
143            }
144    
145            public static int getInteger(String name) throws SystemException {
146                    return getPrefsProps().getInteger(name);
147            }
148    
149            public static int getInteger(String name, int defaultValue)
150                    throws SystemException {
151    
152                    return getPrefsProps().getInteger(name, defaultValue);
153            }
154    
155            public static long getLong(long companyId, String name)
156                    throws SystemException {
157    
158                    return getPrefsProps().getLong(companyId, name);
159            }
160    
161            public static long getLong(long companyId, String name, long defaultValue)
162                    throws SystemException {
163    
164                    return getPrefsProps().getLong(companyId, name, defaultValue);
165            }
166    
167            public static long getLong(
168                    PortletPreferences preferences, long companyId, String name) {
169    
170                    return getPrefsProps().getLong(preferences, companyId, name);
171            }
172    
173            public static long getLong(
174                    PortletPreferences preferences, long companyId, String name,
175                    long defaultValue) {
176    
177                    return getPrefsProps().getLong(
178                            preferences, companyId, name, defaultValue);
179            }
180    
181            public static long getLong(String name) throws SystemException {
182                    return getPrefsProps().getLong(name);
183            }
184    
185            public static long getLong(String name, long defaultValue)
186                    throws SystemException {
187    
188                    return getPrefsProps().getLong(name, defaultValue);
189            }
190    
191            public static PortletPreferences getPreferences() throws SystemException {
192                    return getPrefsProps().getPreferences();
193            }
194    
195            public static PortletPreferences getPreferences(long companyId)
196                    throws SystemException {
197    
198                    return getPrefsProps().getPreferences(companyId);
199            }
200    
201            public static PrefsProps getPrefsProps() {
202                    PortalRuntimePermission.checkGetBeanProperty(PrefsPropsUtil.class);
203    
204                    return _prefsProps;
205            }
206    
207            public static Properties getProperties(
208                    PortletPreferences preferences, long companyId, String prefix,
209                    boolean removePrefix) {
210    
211                    return getPrefsProps().getProperties(
212                            preferences, companyId, prefix, removePrefix);
213            }
214    
215            public static Properties getProperties(String prefix, boolean removePrefix)
216                    throws SystemException {
217    
218                    return getPrefsProps().getProperties(prefix, removePrefix);
219            }
220    
221            public static short getShort(long companyId, String name)
222                    throws SystemException {
223    
224                    return getPrefsProps().getShort(companyId, name);
225            }
226    
227            public static short getShort(
228                            long companyId, String name, short defaultValue)
229                    throws SystemException {
230    
231                    return getPrefsProps().getShort(companyId, name, defaultValue);
232            }
233    
234            public static short getShort(
235                    PortletPreferences preferences, long companyId, String name) {
236    
237                    return getPrefsProps().getShort(preferences, companyId, name);
238            }
239    
240            public static short getShort(
241                    PortletPreferences preferences, long companyId, String name,
242                    short defaultValue) {
243    
244                    return getPrefsProps().getShort(
245                            preferences, companyId, name, defaultValue);
246            }
247    
248            public static short getShort(String name) throws SystemException {
249                    return getPrefsProps().getShort(name);
250            }
251    
252            public static short getShort(String name, short defaultValue)
253                    throws SystemException {
254    
255                    return getPrefsProps().getShort(name, defaultValue);
256            }
257    
258            public static String getString(long companyId, String name)
259                    throws SystemException {
260    
261                    return getPrefsProps().getString(companyId, name);
262            }
263    
264            public static String getString(
265                            long companyId, String name, String defaultValue)
266                    throws SystemException {
267    
268                    return getPrefsProps().getString(companyId, name, defaultValue);
269            }
270    
271            public static String getString(
272                    PortletPreferences preferences, long companyId, String name) {
273    
274                    return getPrefsProps().getString(preferences, companyId, name);
275            }
276    
277            public static String getString(
278                    PortletPreferences preferences, long companyId, String name,
279                    boolean defaultValue) {
280    
281                    return getPrefsProps().getString(
282                            preferences, companyId, name, defaultValue);
283            }
284    
285            public static String getString(
286                    PortletPreferences preferences, long companyId, String name,
287                    double defaultValue) {
288    
289                    return getPrefsProps().getString(
290                            preferences, companyId, name, defaultValue);
291            }
292    
293            public static String getString(
294                    PortletPreferences preferences, long companyId, String name,
295                    int defaultValue) {
296    
297                    return getPrefsProps().getString(
298                            preferences, companyId, name, defaultValue);
299            }
300    
301            public static String getString(
302                    PortletPreferences preferences, long companyId, String name,
303                    long defaultValue) {
304    
305                    return getPrefsProps().getString(
306                            preferences, companyId, name, defaultValue);
307            }
308    
309            public static String getString(
310                    PortletPreferences preferences, long companyId, String name,
311                    short defaultValue) {
312    
313                    return getPrefsProps().getString(
314                            preferences, companyId, name, defaultValue);
315            }
316    
317            public static String getString(
318                    PortletPreferences preferences, long companyId, String name,
319                    String defaultValue) {
320    
321                    return getPrefsProps().getString(
322                            preferences, companyId, name, defaultValue);
323            }
324    
325            public static String getString(String name) throws SystemException {
326                    return getPrefsProps().getString(name);
327            }
328    
329            public static String getString(String name, String defaultValue)
330                    throws SystemException {
331    
332                    return getPrefsProps().getString(name, defaultValue);
333            }
334    
335            public static String[] getStringArray(
336                            long companyId, String name, String delimiter)
337                    throws SystemException {
338    
339                    return getPrefsProps().getStringArray(companyId, name, delimiter);
340            }
341    
342            public static String[] getStringArray(
343                            long companyId, String name, String delimiter,
344                            String[] defaultValue)
345                    throws SystemException {
346    
347                    return getPrefsProps().getStringArray(
348                            companyId, name, delimiter, defaultValue);
349            }
350    
351            public static String[] getStringArray(
352                    PortletPreferences preferences, long companyId, String name,
353                    String delimiter) {
354    
355                    return getPrefsProps().getStringArray(
356                            preferences, companyId, name, delimiter);
357            }
358    
359            public static String[] getStringArray(
360                    PortletPreferences preferences, long companyId, String name,
361                    String delimiter, String[] defaultValue) {
362    
363                    return getPrefsProps().getStringArray(
364                            preferences, companyId, name, delimiter, defaultValue);
365            }
366    
367            public static String[] getStringArray(String name, String delimiter)
368                    throws SystemException {
369    
370                    return getPrefsProps().getStringArray(name, delimiter);
371            }
372    
373            public static String[] getStringArray(
374                            String name, String delimiter, String[] defaultValue)
375                    throws SystemException {
376    
377                    return getPrefsProps().getStringArray(name, delimiter, defaultValue);
378            }
379    
380            public static String getStringFromNames(long companyId, String... names)
381                    throws SystemException {
382    
383                    return getPrefsProps().getStringFromNames(companyId, names);
384            }
385    
386            public void setPrefsProps(PrefsProps prefsProps) {
387                    PortalRuntimePermission.checkSetBeanProperty(getClass());
388    
389                    _prefsProps = prefsProps;
390            }
391    
392            private static PrefsProps _prefsProps;
393    
394    }