001
014
015 package com.liferay.portal.kernel.settings;
016
017 import com.liferay.portal.kernel.util.StringPool;
018
019 import java.util.Map;
020
021
024 public class ParameterMapSettings extends BaseSettings {
025
026 public static final String PREFERENCES_PREFIX = "preferences--";
027
028 public static final String SETTINGS_PREFIX = "settings--";
029
030 public ParameterMapSettings(
031 Map<String, String[]> parameterMap, Settings parentSettings) {
032
033 super(parentSettings);
034
035 _parameterMap = parameterMap;
036 }
037
038 @Override
039 protected String doGetValue(String key) {
040 String[] values = doGetValues(key);
041
042 if (values == null) {
043 return null;
044 }
045
046 return values[0];
047 }
048
049 @Override
050 protected String[] doGetValues(String key) {
051 String[] values = _parameterMap.get(key);
052
053 if (values == null) {
054 values = _parameterMap.get(
055 PREFERENCES_PREFIX + key + StringPool.DOUBLE_DASH);
056 }
057
058 if (values == null) {
059 values = _parameterMap.get(
060 SETTINGS_PREFIX + key + StringPool.DOUBLE_DASH);
061 }
062
063 return values;
064 }
065
066 private final Map<String, String[]> _parameterMap;
067
068 }