1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.util;
16  
17  import javax.portlet.PortletPreferences;
18  
19  /**
20   * <a href="PrefsPropsUtil.java.html"><b><i>View Source</i></b></a>
21   *
22   * @author Brian Wing Shun Chan
23   */
24  public class PrefsPropsUtil {
25  
26      public static String getString(long companyId, String key)
27          throws Exception {
28  
29          Object returnObj = PortalClassInvoker.invoke(
30              _CLASS, _METHOD_GET_STRING, new LongWrapper(companyId), key, false);
31  
32          if (returnObj != null) {
33              return (String)returnObj;
34          }
35          else {
36              return null;
37          }
38      }
39  
40      public static String getString(String key)
41          throws Exception {
42  
43          Object returnObj = PortalClassInvoker.invoke(
44              _CLASS, _METHOD_GET_STRING, key, false);
45  
46          if (returnObj != null) {
47              return (String)returnObj;
48          }
49          else {
50              return null;
51          }
52      }
53  
54      public static String[] getStringArray(
55              long companyId, String name, String delimiter)
56          throws Exception {
57  
58          Object returnObj = PortalClassInvoker.invoke(
59              _CLASS, _METHOD_GET_STRING_ARRAY, new LongWrapper(companyId), name,
60              delimiter, false);
61  
62          if (returnObj != null) {
63              return (String[])returnObj;
64          }
65          else {
66              return null;
67          }
68      }
69  
70      public static String[] getStringArray(
71              long companyId, String name, String delimiter,
72              String[] defaultValue)
73          throws Exception {
74  
75          Object returnObj = PortalClassInvoker.invoke(
76              _CLASS, _METHOD_GET_STRING_ARRAY, new LongWrapper(companyId), name,
77              delimiter, defaultValue, false);
78  
79          if (returnObj != null) {
80              return (String[])returnObj;
81          }
82          else {
83              return null;
84          }
85      }
86  
87      public static String[] getStringArray(
88              PortletPreferences preferences, long companyId, String name,
89              String delimiter)
90          throws Exception {
91  
92          Object returnObj = PortalClassInvoker.invoke(
93              _CLASS, _METHOD_GET_STRING_ARRAY, preferences,
94              new LongWrapper(companyId), name, delimiter, false);
95  
96          if (returnObj != null) {
97              return (String[])returnObj;
98          }
99          else {
100             return null;
101         }
102     }
103 
104     public static String[] getStringArray(
105             PortletPreferences preferences, long companyId, String name,
106             String delimiter, String[] defaultValue)
107         throws Exception {
108 
109         Object returnObj = PortalClassInvoker.invoke(
110             _CLASS, _METHOD_GET_STRING_ARRAY, preferences,
111             new LongWrapper(companyId), name, delimiter, defaultValue, false);
112 
113         if (returnObj != null) {
114             return (String[])returnObj;
115         }
116         else {
117             return null;
118         }
119     }
120 
121     public static String[] getStringArray(String name, String delimiter)
122         throws Exception {
123 
124         Object returnObj = PortalClassInvoker.invoke(
125             _CLASS, _METHOD_GET_STRING_ARRAY, name, delimiter, false);
126 
127         if (returnObj != null) {
128             return (String[])returnObj;
129         }
130         else {
131             return null;
132         }
133     }
134 
135     public static String[] getStringArray(
136             String name, String delimiter, String[] defaultValue)
137         throws Exception {
138 
139         Object returnObj = PortalClassInvoker.invoke(
140             _CLASS, _METHOD_GET_STRING_ARRAY, name, delimiter, defaultValue,
141             false);
142 
143         if (returnObj != null) {
144             return (String[])returnObj;
145         }
146         else {
147             return null;
148         }
149     }
150 
151     private static final String _CLASS =
152         "com.liferay.portal.util.PrefsPropsUtil";
153 
154     private static final String _METHOD_GET_STRING = "getString";
155 
156     private static final String _METHOD_GET_STRING_ARRAY = "getStringArray";
157 
158 }