001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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 String getString(long companyId, String key)
025                    throws Exception {
026    
027                    Object returnObj = PortalClassInvoker.invoke(
028                            false, _getStringMethodKey1, companyId, key);
029    
030                    if (returnObj != null) {
031                            return (String)returnObj;
032                    }
033                    else {
034                            return null;
035                    }
036            }
037    
038            public static String getString(String key)
039                    throws Exception {
040    
041                    Object returnObj = PortalClassInvoker.invoke(
042                            false, _getStringMethodKey2, key);
043    
044                    if (returnObj != null) {
045                            return (String)returnObj;
046                    }
047                    else {
048                            return null;
049                    }
050            }
051    
052            public static String[] getStringArray(
053                            long companyId, String name, String delimiter)
054                    throws Exception {
055    
056                    Object returnObj = PortalClassInvoker.invoke(
057                            false, _getStringArrayMethodKey1, companyId, name, delimiter);
058    
059                    if (returnObj != null) {
060                            return (String[])returnObj;
061                    }
062                    else {
063                            return null;
064                    }
065            }
066    
067            public static String[] getStringArray(
068                            long companyId, String name, String delimiter,
069                            String[] defaultValue)
070                    throws Exception {
071    
072                    Object returnObj = PortalClassInvoker.invoke(
073                            false, _getStringArrayMethodKey2, companyId, name, delimiter,
074                            defaultValue);
075    
076                    if (returnObj != null) {
077                            return (String[])returnObj;
078                    }
079                    else {
080                            return null;
081                    }
082            }
083    
084            public static String[] getStringArray(
085                            PortletPreferences preferences, long companyId, String name,
086                            String delimiter)
087                    throws Exception {
088    
089                    Object returnObj = PortalClassInvoker.invoke(
090                            false, _getStringArrayMethodKey3, preferences, companyId, name,
091                            delimiter);
092    
093                    if (returnObj != null) {
094                            return (String[])returnObj;
095                    }
096                    else {
097                            return null;
098                    }
099            }
100    
101            public static String[] getStringArray(
102                            PortletPreferences preferences, long companyId, String name,
103                            String delimiter, String[] defaultValue)
104                    throws Exception {
105    
106                    Object returnObj = PortalClassInvoker.invoke(
107                            false, _getStringArrayMethodKey4, preferences, companyId, name,
108                            delimiter, defaultValue);
109    
110                    if (returnObj != null) {
111                            return (String[])returnObj;
112                    }
113                    else {
114                            return null;
115                    }
116            }
117    
118            public static String[] getStringArray(String name, String delimiter)
119                    throws Exception {
120    
121                    Object returnObj = PortalClassInvoker.invoke(
122                            false, _getStringArrayMethodKey5, name, delimiter);
123    
124                    if (returnObj != null) {
125                            return (String[])returnObj;
126                    }
127                    else {
128                            return null;
129                    }
130            }
131    
132            public static String[] getStringArray(
133                            String name, String delimiter, String[] defaultValue)
134                    throws Exception {
135    
136                    Object returnObj = PortalClassInvoker.invoke(
137                            false, _getStringArrayMethodKey6, name, delimiter, defaultValue);
138    
139                    if (returnObj != null) {
140                            return (String[])returnObj;
141                    }
142                    else {
143                            return null;
144                    }
145            }
146    
147            private static final String _CLASS_NAME =
148                    "com.liferay.portal.util.PrefsPropsUtil";
149    
150            private static MethodKey _getStringArrayMethodKey1 = new MethodKey(
151                    _CLASS_NAME, "getStringArray", long.class, String.class, String.class);
152            private static MethodKey _getStringArrayMethodKey2 = new MethodKey(
153                    _CLASS_NAME, "getStringArray", long.class, String.class, String.class,
154                    String[].class);
155            private static MethodKey _getStringArrayMethodKey3 = new MethodKey(
156                    _CLASS_NAME, "getStringArray", PortletPreferences.class, long.class,
157                    String.class, String.class);
158            private static MethodKey _getStringArrayMethodKey4 = new MethodKey(
159                    _CLASS_NAME, "getStringArray", PortletPreferences.class, long.class,
160                    String.class, String.class, String[].class);
161            private static MethodKey _getStringArrayMethodKey5 = new MethodKey(
162                    _CLASS_NAME, "getStringArray", String.class, String.class);
163            private static MethodKey _getStringArrayMethodKey6 = new MethodKey(
164                    _CLASS_NAME, "getStringArray", String.class, String.class,
165                    String[].class);
166            private static MethodKey _getStringMethodKey1 = new MethodKey(
167                    _CLASS_NAME, "getString", long.class, String.class);
168            private static MethodKey _getStringMethodKey2 = new MethodKey(
169                    _CLASS_NAME, "getString", String.class);
170    
171    }