001
014
015 package com.liferay.portal.kernel.settings;
016
017 import com.liferay.portal.kernel.util.StringUtil;
018
019 import java.util.Properties;
020
021
025 public class PropertiesSettings extends BaseSettings {
026
027 public PropertiesSettings(
028 LocationVariableResolver locationVariableResolver,
029 Properties properties) {
030
031 this(locationVariableResolver, properties, null);
032 }
033
034 public PropertiesSettings(
035 LocationVariableResolver locationVariableResolver,
036 Properties properties, Settings parentSettings) {
037
038 super(parentSettings);
039
040 _locationVariableResolver = locationVariableResolver;
041 _properties = properties;
042 }
043
044 @Override
045 protected String doGetValue(String key) {
046 return readProperty(key);
047 }
048
049 @Override
050 protected String[] doGetValues(String key) {
051 return StringUtil.split(doGetValue(key));
052 }
053
054 protected String getProperty(String key) {
055 return readProperty(key);
056 }
057
058 protected String readProperty(String key) {
059 String value = _properties.getProperty(key);
060
061 if (_locationVariableResolver.isLocationVariable(value)) {
062 return _locationVariableResolver.resolve(value);
063 }
064
065 return value;
066 }
067
068 private final LocationVariableResolver _locationVariableResolver;
069 private final Properties _properties;
070
071 }