org.springframework.core.env
Class AbstractPropertyResolver

java.lang.Object
  extended by org.springframework.core.env.AbstractPropertyResolver
All Implemented Interfaces:
ConfigurablePropertyResolver, PropertyResolver
Direct Known Subclasses:
PropertySourcesPropertyResolver

public abstract class AbstractPropertyResolver
extends Object
implements ConfigurablePropertyResolver

Abstract base class for resolving properties against any underlying source.

Since:
3.1
Author:
Chris Beams

Field Summary
protected  ConversionService conversionService
           
protected  Log logger
           
 
Constructor Summary
AbstractPropertyResolver()
           
 
Method Summary
 ConversionService getConversionService()
           
 String getRequiredProperty(String key)
          Return the property value associated with the given key, converted to the given targetType (never null).
<T> T
getRequiredProperty(String key, Class<T> valueType)
          Return the property value associated with the given key, converted to the given targetType (never null).
 String resolvePlaceholders(String text)
          Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by PropertyResolver.getProperty(java.lang.String).
 String resolveRequiredPlaceholders(String text)
          Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by PropertyResolver.getProperty(java.lang.String).
 void setConversionService(ConversionService conversionService)
          Set the ConversionService to be used when performing type conversions on properties.
 void setPlaceholderPrefix(String placeholderPrefix)
           
 void setPlaceholderSuffix(String placeholderSuffix)
           
 void setValueSeparator(String valueSeparator)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.core.env.PropertyResolver
containsProperty, getProperty, getProperty
 

Field Detail

logger

protected final Log logger

conversionService

protected ConversionService conversionService
Constructor Detail

AbstractPropertyResolver

public AbstractPropertyResolver()
Method Detail

getConversionService

public ConversionService getConversionService()
Specified by:
getConversionService in interface ConfigurablePropertyResolver
Returns:
the ConversionService used when performing type conversions on properties.
See Also:
PropertyResolver.getProperty(String, Class)

setConversionService

public void setConversionService(ConversionService conversionService)
Description copied from interface: ConfigurablePropertyResolver
Set the ConversionService to be used when performing type conversions on properties.

Specified by:
setConversionService in interface ConfigurablePropertyResolver
See Also:
PropertyResolver.getProperty(String, Class)

getRequiredProperty

public String getRequiredProperty(String key)
                           throws IllegalStateException
Description copied from interface: PropertyResolver
Return the property value associated with the given key, converted to the given targetType (never null).

Specified by:
getRequiredProperty in interface PropertyResolver
Throws:
IllegalStateException - if the key cannot be resolved
See Also:
PropertyResolver.getRequiredProperty(String, Class)

getRequiredProperty

public <T> T getRequiredProperty(String key,
                                 Class<T> valueType)
                      throws IllegalStateException
Description copied from interface: PropertyResolver
Return the property value associated with the given key, converted to the given targetType (never null).

Specified by:
getRequiredProperty in interface PropertyResolver
Throws:
IllegalStateException - if the given key cannot be resolved

setPlaceholderPrefix

public void setPlaceholderPrefix(String placeholderPrefix)
Specified by:
setPlaceholderPrefix in interface ConfigurablePropertyResolver

setPlaceholderSuffix

public void setPlaceholderSuffix(String placeholderSuffix)
Specified by:
setPlaceholderSuffix in interface ConfigurablePropertyResolver

setValueSeparator

public void setValueSeparator(String valueSeparator)
Specified by:
setValueSeparator in interface ConfigurablePropertyResolver

resolvePlaceholders

public String resolvePlaceholders(String text)
Description copied from interface: PropertyResolver
Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by PropertyResolver.getProperty(java.lang.String). Unresolvable placeholders with no default value are ignored and passed through unchanged.

Specified by:
resolvePlaceholders in interface PropertyResolver
Parameters:
text - the String to resolve
Returns:
the resolved String (never null)
See Also:
PropertyResolver.resolveRequiredPlaceholders(java.lang.String), SystemPropertyUtils.resolvePlaceholders(String)

resolveRequiredPlaceholders

public String resolveRequiredPlaceholders(String text)
                                   throws IllegalArgumentException
Description copied from interface: PropertyResolver
Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by PropertyResolver.getProperty(java.lang.String). Unresolvable placeholders with no default value will cause an IllegalArgumentException to be thrown.

Specified by:
resolveRequiredPlaceholders in interface PropertyResolver
Returns:
the resolved String (never null)
Throws:
IllegalArgumentException - if given text is null
See Also:
SystemPropertyUtils.resolvePlaceholders(String, boolean)