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