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(boolean readOnly)
196                    throws SystemException {
197    
198                    return getPrefsProps().getPreferences(readOnly);
199            }
200    
201            public static PortletPreferences getPreferences(long companyId)
202                    throws SystemException {
203    
204                    return getPrefsProps().getPreferences(companyId);
205            }
206    
207            public static PortletPreferences getPreferences(
208                            long companyId, boolean readOnly)
209                    throws SystemException {
210    
211                    return getPrefsProps().getPreferences(companyId, readOnly);
212            }
213    
214            public static PrefsProps getPrefsProps() {
215                    PortalRuntimePermission.checkGetBeanProperty(PrefsPropsUtil.class);
216    
217                    return _prefsProps;
218            }
219    
220            public static Properties getProperties(
221                    PortletPreferences preferences, long companyId, String prefix,
222                    boolean removePrefix) {
223    
224                    return getPrefsProps().getProperties(
225                            preferences, companyId, prefix, removePrefix);
226            }
227    
228            public static Properties getProperties(String prefix, boolean removePrefix)
229                    throws SystemException {
230    
231                    return getPrefsProps().getProperties(prefix, removePrefix);
232            }
233    
234            public static short getShort(long companyId, String name)
235                    throws SystemException {
236    
237                    return getPrefsProps().getShort(companyId, name);
238            }
239    
240            public static short getShort(
241                            long companyId, String name, short defaultValue)
242                    throws SystemException {
243    
244                    return getPrefsProps().getShort(companyId, name, defaultValue);
245            }
246    
247            public static short getShort(
248                    PortletPreferences preferences, long companyId, String name) {
249    
250                    return getPrefsProps().getShort(preferences, companyId, name);
251            }
252    
253            public static short getShort(
254                    PortletPreferences preferences, long companyId, String name,
255                    short defaultValue) {
256    
257                    return getPrefsProps().getShort(
258                            preferences, companyId, name, defaultValue);
259            }
260    
261            public static short getShort(String name) throws SystemException {
262                    return getPrefsProps().getShort(name);
263            }
264    
265            public static short getShort(String name, short defaultValue)
266                    throws SystemException {
267    
268                    return getPrefsProps().getShort(name, defaultValue);
269            }
270    
271            public static String getString(long companyId, String name)
272                    throws SystemException {
273    
274                    return getPrefsProps().getString(companyId, name);
275            }
276    
277            public static String getString(
278                            long companyId, String name, String defaultValue)
279                    throws SystemException {
280    
281                    return getPrefsProps().getString(companyId, name, defaultValue);
282            }
283    
284            public static String getString(
285                    PortletPreferences preferences, long companyId, String name) {
286    
287                    return getPrefsProps().getString(preferences, companyId, name);
288            }
289    
290            public static String getString(
291                    PortletPreferences preferences, long companyId, String name,
292                    boolean defaultValue) {
293    
294                    return getPrefsProps().getString(
295                            preferences, companyId, name, defaultValue);
296            }
297    
298            public static String getString(
299                    PortletPreferences preferences, long companyId, String name,
300                    double defaultValue) {
301    
302                    return getPrefsProps().getString(
303                            preferences, companyId, name, defaultValue);
304            }
305    
306            public static String getString(
307                    PortletPreferences preferences, long companyId, String name,
308                    int defaultValue) {
309    
310                    return getPrefsProps().getString(
311                            preferences, companyId, name, defaultValue);
312            }
313    
314            public static String getString(
315                    PortletPreferences preferences, long companyId, String name,
316                    long defaultValue) {
317    
318                    return getPrefsProps().getString(
319                            preferences, companyId, name, defaultValue);
320            }
321    
322            public static String getString(
323                    PortletPreferences preferences, long companyId, String name,
324                    short defaultValue) {
325    
326                    return getPrefsProps().getString(
327                            preferences, companyId, name, defaultValue);
328            }
329    
330            public static String getString(
331                    PortletPreferences preferences, long companyId, String name,
332                    String defaultValue) {
333    
334                    return getPrefsProps().getString(
335                            preferences, companyId, name, defaultValue);
336            }
337    
338            public static String getString(String name) throws SystemException {
339                    return getPrefsProps().getString(name);
340            }
341    
342            public static String getString(String name, String defaultValue)
343                    throws SystemException {
344    
345                    return getPrefsProps().getString(name, defaultValue);
346            }
347    
348            public static String[] getStringArray(
349                            long companyId, String name, String delimiter)
350                    throws SystemException {
351    
352                    return getPrefsProps().getStringArray(companyId, name, delimiter);
353            }
354    
355            public static String[] getStringArray(
356                            long companyId, String name, String delimiter,
357                            String[] defaultValue)
358                    throws SystemException {
359    
360                    return getPrefsProps().getStringArray(
361                            companyId, name, delimiter, defaultValue);
362            }
363    
364            public static String[] getStringArray(
365                    PortletPreferences preferences, long companyId, String name,
366                    String delimiter) {
367    
368                    return getPrefsProps().getStringArray(
369                            preferences, companyId, name, delimiter);
370            }
371    
372            public static String[] getStringArray(
373                    PortletPreferences preferences, long companyId, String name,
374                    String delimiter, String[] defaultValue) {
375    
376                    return getPrefsProps().getStringArray(
377                            preferences, companyId, name, delimiter, defaultValue);
378            }
379    
380            public static String[] getStringArray(String name, String delimiter)
381                    throws SystemException {
382    
383                    return getPrefsProps().getStringArray(name, delimiter);
384            }
385    
386            public static String[] getStringArray(
387                            String name, String delimiter, String[] defaultValue)
388                    throws SystemException {
389    
390                    return getPrefsProps().getStringArray(name, delimiter, defaultValue);
391            }
392    
393            public static String getStringFromNames(long companyId, String... names)
394                    throws SystemException {
395    
396                    return getPrefsProps().getStringFromNames(companyId, names);
397            }
398    
399            public void setPrefsProps(PrefsProps prefsProps) {
400                    PortalRuntimePermission.checkSetBeanProperty(getClass());
401    
402                    _prefsProps = prefsProps;
403            }
404    
405            private static PrefsProps _prefsProps;
406    
407    }