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[] getStringArray(
41              long companyId, String name, String delimiter)
42          throws Exception {
43  
44          Object returnObj = PortalClassInvoker.invoke(
45              _CLASS, _METHOD_GET_STRING_ARRAY, new LongWrapper(companyId), name,
46              delimiter, false);
47  
48          if (returnObj != null) {
49              return (String[])returnObj;
50          }
51          else {
52              return null;
53          }
54      }
55  
56      public static String[] getStringArray(
57              long companyId, String name, String delimiter,
58              String[] defaultValue)
59          throws Exception {
60  
61          Object returnObj = PortalClassInvoker.invoke(
62              _CLASS, _METHOD_GET_STRING_ARRAY, new LongWrapper(companyId), name,
63              delimiter, defaultValue, false);
64  
65          if (returnObj != null) {
66              return (String[])returnObj;
67          }
68          else {
69              return null;
70          }
71      }
72  
73      public static String[] getStringArray(
74              PortletPreferences preferences, long companyId, String name,
75              String delimiter)
76          throws Exception {
77  
78          Object returnObj = PortalClassInvoker.invoke(
79              _CLASS, _METHOD_GET_STRING_ARRAY, preferences,
80              new LongWrapper(companyId), name, delimiter, false);
81  
82          if (returnObj != null) {
83              return (String[])returnObj;
84          }
85          else {
86              return null;
87          }
88      }
89  
90      public static String[] getStringArray(
91              PortletPreferences preferences, long companyId, String name,
92              String delimiter, String[] defaultValue)
93          throws Exception {
94  
95          Object returnObj = PortalClassInvoker.invoke(
96              _CLASS, _METHOD_GET_STRING_ARRAY, preferences,
97              new LongWrapper(companyId), name, delimiter, defaultValue, false);
98  
99          if (returnObj != null) {
100             return (String[])returnObj;
101         }
102         else {
103             return null;
104         }
105     }
106 
107     public static String[] getStringArray(String name, String delimiter)
108         throws Exception {
109 
110         Object returnObj = PortalClassInvoker.invoke(
111             _CLASS, _METHOD_GET_STRING_ARRAY, name, delimiter, false);
112 
113         if (returnObj != null) {
114             return (String[])returnObj;
115         }
116         else {
117             return null;
118         }
119     }
120 
121     public static String[] getStringArray(
122             String name, String delimiter, String[] defaultValue)
123         throws Exception {
124 
125         Object returnObj = PortalClassInvoker.invoke(
126             _CLASS, _METHOD_GET_STRING_ARRAY, name, delimiter, defaultValue,
127             false);
128 
129         if (returnObj != null) {
130             return (String[])returnObj;
131         }
132         else {
133             return null;
134         }
135     }
136 
137     private static final String _CLASS =
138         "com.liferay.portal.util.PrefsPropsUtil";
139 
140     private static final String _METHOD_GET_STRING = "getString";
141 
142     private static final String _METHOD_GET_STRING_ARRAY = "getStringArray";
143 
144 }