001    /**
002     * Copyright (c) 2000-2012 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 javax.portlet.PortletPreferences;
018    
019    /**
020     * @author Brian Wing Shun Chan
021     */
022    public class PrefsPropsUtil {
023    
024            public static boolean getBoolean(long companyId, String name)
025                    throws Exception {
026    
027                    Object returnObj = PortalClassInvoker.invoke(
028                            false, _getBooleanMethodKey1, companyId, name);
029    
030                    if (returnObj != null) {
031                            return (Boolean)returnObj;
032                    }
033                    else {
034                            return false;
035                    }
036            }
037    
038            public static boolean getBoolean(
039                            long companyId, String name, boolean defaultValue)
040                    throws Exception {
041    
042                    Object returnObj = PortalClassInvoker.invoke(
043                            false, _getBooleanMethodKey2, companyId, name, defaultValue);
044    
045                    if (returnObj != null) {
046                            return (Boolean)returnObj;
047                    }
048                    else {
049                            return false;
050                    }
051            }
052    
053            public static boolean getBoolean(String name) throws Exception {
054                    Object returnObj = PortalClassInvoker.invoke(
055                            false, _getBooleanMethodKey3, name);
056    
057                    if (returnObj != null) {
058                            return (Boolean)returnObj;
059                    }
060                    else {
061                            return false;
062                    }
063            }
064    
065            public static int getInteger(long companyId, String name)
066                    throws Exception {
067    
068                    Object returnObj = PortalClassInvoker.invoke(
069                            false, _getIntegerMethodKey1, companyId, name);
070    
071                    if (returnObj != null) {
072                            return (Integer)returnObj;
073                    }
074                    else {
075                            return 0;
076                    }
077            }
078    
079            public static int getInteger(long companyId, String name, int defaultValue)
080                    throws Exception {
081    
082                    Object returnObj = PortalClassInvoker.invoke(
083                            false, _getIntegerMethodKey2, companyId, name, defaultValue);
084    
085                    if (returnObj != null) {
086                            return (Integer)returnObj;
087                    }
088                    else {
089                            return 0;
090                    }
091            }
092    
093            public static int getInteger(String name) throws Exception {
094                    Object returnObj = PortalClassInvoker.invoke(
095                            false, _getIntegerMethodKey3, name);
096    
097                    if (returnObj != null) {
098                            return (Integer)returnObj;
099                    }
100                    else {
101                            return 0;
102                    }
103            }
104    
105            public static long getLong(long companyId, String name)
106                    throws Exception {
107    
108                    Object returnObj = PortalClassInvoker.invoke(
109                            false, _getLongMethodKey1, companyId, name);
110    
111                    if (returnObj != null) {
112                            return (Long)returnObj;
113                    }
114                    else {
115                            return 0;
116                    }
117            }
118    
119            public static long getLong(long companyId, String name, long defaultValue)
120                    throws Exception {
121    
122                    Object returnObj = PortalClassInvoker.invoke(
123                            false, _getLongMethodKey2, companyId, name, defaultValue);
124    
125                    if (returnObj != null) {
126                            return (Long)returnObj;
127                    }
128                    else {
129                            return 0;
130                    }
131            }
132    
133            public static long getLong(String name) throws Exception {
134                    Object returnObj = PortalClassInvoker.invoke(
135                            false, _getLongMethodKey3, name);
136    
137                    if (returnObj != null) {
138                            return (Long)returnObj;
139                    }
140                    else {
141                            return 0;
142                    }
143            }
144    
145            public static String getString(long companyId, String name)
146                    throws Exception {
147    
148                    Object returnObj = PortalClassInvoker.invoke(
149                            false, _getStringMethodKey1, companyId, name);
150    
151                    if (returnObj != null) {
152                            return (String)returnObj;
153                    }
154                    else {
155                            return null;
156                    }
157            }
158    
159            public static String getString(
160                            long companyId, String name, String defaultValue)
161                    throws Exception {
162    
163                    Object returnObj = PortalClassInvoker.invoke(
164                            false, _getStringMethodKey2, companyId, name, defaultValue);
165    
166                    if (returnObj != null) {
167                            return (String)returnObj;
168                    }
169                    else {
170                            return null;
171                    }
172            }
173    
174            public static String getString(String name) throws Exception {
175                    Object returnObj = PortalClassInvoker.invoke(
176                            false, _getStringMethodKey3, name);
177    
178                    if (returnObj != null) {
179                            return (String)returnObj;
180                    }
181                    else {
182                            return null;
183                    }
184            }
185    
186            public static String[] getStringArray(
187                            long companyId, String name, String delimiter)
188                    throws Exception {
189    
190                    Object returnObj = PortalClassInvoker.invoke(
191                            false, _getStringArrayMethodKey1, companyId, name, delimiter);
192    
193                    if (returnObj != null) {
194                            return (String[])returnObj;
195                    }
196                    else {
197                            return null;
198                    }
199            }
200    
201            public static String[] getStringArray(
202                            long companyId, String name, String delimiter,
203                            String[] defaultValue)
204                    throws Exception {
205    
206                    Object returnObj = PortalClassInvoker.invoke(
207                            false, _getStringArrayMethodKey2, companyId, name, delimiter,
208                            defaultValue);
209    
210                    if (returnObj != null) {
211                            return (String[])returnObj;
212                    }
213                    else {
214                            return null;
215                    }
216            }
217    
218            public static String[] getStringArray(
219                            PortletPreferences preferences, long companyId, String name,
220                            String delimiter)
221                    throws Exception {
222    
223                    Object returnObj = PortalClassInvoker.invoke(
224                            false, _getStringArrayMethodKey3, preferences, companyId, name,
225                            delimiter);
226    
227                    if (returnObj != null) {
228                            return (String[])returnObj;
229                    }
230                    else {
231                            return null;
232                    }
233            }
234    
235            public static String[] getStringArray(
236                            PortletPreferences preferences, long companyId, String name,
237                            String delimiter, String[] defaultValue)
238                    throws Exception {
239    
240                    Object returnObj = PortalClassInvoker.invoke(
241                            false, _getStringArrayMethodKey4, preferences, companyId, name,
242                            delimiter, defaultValue);
243    
244                    if (returnObj != null) {
245                            return (String[])returnObj;
246                    }
247                    else {
248                            return null;
249                    }
250            }
251    
252            public static String[] getStringArray(String name, String delimiter)
253                    throws Exception {
254    
255                    Object returnObj = PortalClassInvoker.invoke(
256                            false, _getStringArrayMethodKey5, name, delimiter);
257    
258                    if (returnObj != null) {
259                            return (String[])returnObj;
260                    }
261                    else {
262                            return null;
263                    }
264            }
265    
266            public static String[] getStringArray(
267                            String name, String delimiter, String[] defaultValue)
268                    throws Exception {
269    
270                    Object returnObj = PortalClassInvoker.invoke(
271                            false, _getStringArrayMethodKey6, name, delimiter, defaultValue);
272    
273                    if (returnObj != null) {
274                            return (String[])returnObj;
275                    }
276                    else {
277                            return null;
278                    }
279            }
280    
281            private static final String _CLASS_NAME =
282                    "com.liferay.portal.util.PrefsPropsUtil";
283    
284            private static MethodKey _getBooleanMethodKey1 = new MethodKey(
285                    _CLASS_NAME, "getBoolean", long.class, String.class);
286            private static MethodKey _getBooleanMethodKey2 = new MethodKey(
287                    _CLASS_NAME, "getBoolean", long.class, String.class, boolean.class);
288            private static MethodKey _getBooleanMethodKey3 = new MethodKey(
289                    _CLASS_NAME, "getBoolean", String.class);
290            private static MethodKey _getIntegerMethodKey1 = new MethodKey(
291                    _CLASS_NAME, "getInteger", long.class, String.class);
292            private static MethodKey _getIntegerMethodKey2 = new MethodKey(
293                    _CLASS_NAME, "getInteger", long.class, String.class, int.class);
294            private static MethodKey _getIntegerMethodKey3 = new MethodKey(
295                    _CLASS_NAME, "getInteger", String.class);
296            private static MethodKey _getLongMethodKey1 = new MethodKey(
297                    _CLASS_NAME, "getLong", long.class, String.class);
298            private static MethodKey _getLongMethodKey2 = new MethodKey(
299                    _CLASS_NAME, "getLong", long.class, String.class, long.class);
300            private static MethodKey _getLongMethodKey3 = new MethodKey(
301                    _CLASS_NAME, "getLong", String.class);
302            private static MethodKey _getStringArrayMethodKey1 = new MethodKey(
303                    _CLASS_NAME, "getStringArray", long.class, String.class, String.class);
304            private static MethodKey _getStringArrayMethodKey2 = new MethodKey(
305                    _CLASS_NAME, "getStringArray", long.class, String.class, String.class,
306                    String[].class);
307            private static MethodKey _getStringArrayMethodKey3 = new MethodKey(
308                    _CLASS_NAME, "getStringArray", PortletPreferences.class, long.class,
309                    String.class, String.class);
310            private static MethodKey _getStringArrayMethodKey4 = new MethodKey(
311                    _CLASS_NAME, "getStringArray", PortletPreferences.class, long.class,
312                    String.class, String.class, String[].class);
313            private static MethodKey _getStringArrayMethodKey5 = new MethodKey(
314                    _CLASS_NAME, "getStringArray", String.class, String.class);
315            private static MethodKey _getStringArrayMethodKey6 = new MethodKey(
316                    _CLASS_NAME, "getStringArray", String.class, String.class,
317                    String[].class);
318            private static MethodKey _getStringMethodKey1 = new MethodKey(
319                    _CLASS_NAME, "getString", long.class, String.class);
320            private static MethodKey _getStringMethodKey2 = new MethodKey(
321                    _CLASS_NAME, "getString", long.class, String.class, String.class);
322            private static MethodKey _getStringMethodKey3 = new MethodKey(
323                    _CLASS_NAME, "getString", String.class);
324    
325    }