001    /**
002     * Copyright (c) 2000-2010 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 String getString(long companyId, String key)
025                    throws Exception {
026    
027                    Object returnObj = PortalClassInvoker.invoke(
028                            _CLASS, _METHOD_GET_STRING, new LongWrapper(companyId), key, false);
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                            _CLASS, _METHOD_GET_STRING, key, false);
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                            _CLASS, _METHOD_GET_STRING_ARRAY, new LongWrapper(companyId), name,
058                            delimiter, false);
059    
060                    if (returnObj != null) {
061                            return (String[])returnObj;
062                    }
063                    else {
064                            return null;
065                    }
066            }
067    
068            public static String[] getStringArray(
069                            long companyId, String name, String delimiter,
070                            String[] defaultValue)
071                    throws Exception {
072    
073                    Object returnObj = PortalClassInvoker.invoke(
074                            _CLASS, _METHOD_GET_STRING_ARRAY, new LongWrapper(companyId), name,
075                            delimiter, defaultValue, false);
076    
077                    if (returnObj != null) {
078                            return (String[])returnObj;
079                    }
080                    else {
081                            return null;
082                    }
083            }
084    
085            public static String[] getStringArray(
086                            PortletPreferences preferences, long companyId, String name,
087                            String delimiter)
088                    throws Exception {
089    
090                    Object returnObj = PortalClassInvoker.invoke(
091                            _CLASS, _METHOD_GET_STRING_ARRAY, preferences,
092                            new LongWrapper(companyId), name, delimiter, false);
093    
094                    if (returnObj != null) {
095                            return (String[])returnObj;
096                    }
097                    else {
098                            return null;
099                    }
100            }
101    
102            public static String[] getStringArray(
103                            PortletPreferences preferences, long companyId, String name,
104                            String delimiter, String[] defaultValue)
105                    throws Exception {
106    
107                    Object returnObj = PortalClassInvoker.invoke(
108                            _CLASS, _METHOD_GET_STRING_ARRAY, preferences,
109                            new LongWrapper(companyId), name, delimiter, defaultValue, false);
110    
111                    if (returnObj != null) {
112                            return (String[])returnObj;
113                    }
114                    else {
115                            return null;
116                    }
117            }
118    
119            public static String[] getStringArray(String name, String delimiter)
120                    throws Exception {
121    
122                    Object returnObj = PortalClassInvoker.invoke(
123                            _CLASS, _METHOD_GET_STRING_ARRAY, name, delimiter, false);
124    
125                    if (returnObj != null) {
126                            return (String[])returnObj;
127                    }
128                    else {
129                            return null;
130                    }
131            }
132    
133            public static String[] getStringArray(
134                            String name, String delimiter, String[] defaultValue)
135                    throws Exception {
136    
137                    Object returnObj = PortalClassInvoker.invoke(
138                            _CLASS, _METHOD_GET_STRING_ARRAY, name, delimiter, defaultValue,
139                            false);
140    
141                    if (returnObj != null) {
142                            return (String[])returnObj;
143                    }
144                    else {
145                            return null;
146                    }
147            }
148    
149            private static final String _CLASS =
150                    "com.liferay.portal.util.PrefsPropsUtil";
151    
152            private static final String _METHOD_GET_STRING = "getString";
153    
154            private static final String _METHOD_GET_STRING_ARRAY = "getStringArray";
155    
156    }