001
014
015 package com.liferay.portal.kernel.util;
016
017 import com.liferay.portal.kernel.configuration.Filter;
018 import com.liferay.portal.kernel.log.Log;
019 import com.liferay.portal.kernel.log.LogFactoryUtil;
020
021 import java.util.Properties;
022
023
026 public class PropsUtil {
027
028 public static String get(String key) {
029 String value = null;
030
031 try {
032 Object returnObj = PortalClassInvoker.invoke(
033 false, _getMethodKey1, key);
034
035 if (returnObj != null) {
036 value = (String)returnObj;
037 }
038 }
039 catch (Exception e) {
040 _log.error(e, e);
041 }
042
043 return value;
044 }
045
046 public static String get(String key, Filter filter) {
047 String value = null;
048
049 try {
050 Object returnObj = PortalClassInvoker.invoke(
051 false, _getMethodKey2, key, filter);
052
053 if (returnObj != null) {
054 value = (String)returnObj;
055 }
056 }
057 catch (Exception e) {
058 _log.error(e, e);
059 }
060
061 return value;
062 }
063
064 public static String[] getArray(String key) {
065 String[] value = null;
066
067 try {
068 Object returnObj = PortalClassInvoker.invoke(
069 false, _getArrayMethodKey1, key);
070
071 if (returnObj != null) {
072 value = (String[])returnObj;
073 }
074 }
075 catch (Exception e) {
076 _log.error(e, e);
077 }
078
079 return value;
080 }
081
082 public static String[] getArray(String key, Filter filter) {
083 String[] value = null;
084
085 try {
086 Object returnObj = PortalClassInvoker.invoke(
087 false, _getArrayMethodKey2, key, filter);
088
089 if (returnObj != null) {
090 value = (String[])returnObj;
091 }
092 }
093 catch (Exception e) {
094 _log.error(e, e);
095 }
096
097 return value;
098 }
099
100 public static Properties getProperties() {
101 Properties properties = null;
102
103 try {
104 Object returnObj = PortalClassInvoker.invoke(
105 false, _getPropertiesMethodKey1);
106
107 if (returnObj != null) {
108 properties = (Properties)returnObj;
109 }
110 }
111 catch (Exception e) {
112 _log.error(e, e);
113 }
114
115 return properties;
116 }
117
118 public static Properties getProperties(
119 String prefix, boolean removePrefix) {
120
121 Properties properties = null;
122
123 try {
124 Object returnObj = PortalClassInvoker.invoke(
125 false, _getPropertiesMethodKey2, prefix, removePrefix);
126
127 if (returnObj != null) {
128 properties = (Properties)returnObj;
129 }
130 }
131 catch (Exception e) {
132 _log.error(e, e);
133 }
134
135 return properties;
136 }
137
138 private static final String _CLASS_NAME =
139 "com.liferay.portal.util.PropsUtil";
140
141 private static Log _log = LogFactoryUtil.getLog(PropsUtil.class);
142
143 private static MethodKey _getArrayMethodKey1 = new MethodKey(
144 _CLASS_NAME, "getArray", String.class);
145 private static MethodKey _getArrayMethodKey2 = new MethodKey(
146 _CLASS_NAME, "getArray", String.class, Filter.class);
147 private static MethodKey _getMethodKey1 = new MethodKey(
148 _CLASS_NAME, "get", String.class);
149 private static MethodKey _getMethodKey2 = new MethodKey(
150 _CLASS_NAME, "get", String.class, Filter.class);
151 private static MethodKey _getPropertiesMethodKey1 = new MethodKey(
152 _CLASS_NAME, "getProperties");
153 private static MethodKey _getPropertiesMethodKey2 = new MethodKey(
154 _CLASS_NAME, "getProperties", String.class, boolean.class);
155
156 }