Top Description Methods
org.springframework.core.env

public Interface PropertyResolver

Known Direct Subinterfaces
org.springframework.core.env.ConfigurablePropertyResolver, org.springframework.core.env.Environment
Imports
org.springframework.lang.Nullable

Interface for resolving properties against any underlying source.
Authors
Chris Beams, Juergen Hoeller
Since
3.1
See Also
Environment, PropertySourcesPropertyResolver

Method Summary

Modifier and TypeMethod and Description
public boolean
containsProperty(String key)

Return whether the given property key is available for resolution, i.e. if the value for the given key is not null.

public String
getProperty(String
the property name to resolve
key
)

Return the property value associated with the given key, or null if the key cannot be resolved.

public String
getProperty(String
the property name to resolve
key
,
String
the default value to return if no value is found
defaultValue
)

Return the property value associated with the given key, or defaultValue if the key cannot be resolved.

public <T> T
getProperty(String
the property name to resolve
key
,
Class<T>
the expected type of the property value
targetType
)

Return the property value associated with the given key, or null if the key cannot be resolved.

public <T> T
getProperty(String
the property name to resolve
key
,
Class<T>
the expected type of the property value
targetType
,
T
the default value to return if no value is found
defaultValue
)

Return the property value associated with the given key, or defaultValue if the key cannot be resolved.

public String
getRequiredProperty(String key)

Return the property value associated with the given key (never null).

public <T> T
getRequiredProperty(String key, Class<T> targetType)

Return the property value associated with the given key, converted to the given targetType (never null).

public String

Returns:

the resolved String (never null)
resolvePlaceholders
(String
the String to resolve
text
)

Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by getProperty.

public String

Returns:

the resolved String (never null)
resolveRequiredPlaceholders
(String text)

Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by getProperty.

Method Detail

containsPropertyback to summary
public boolean containsProperty(String key)

Return whether the given property key is available for resolution, i.e. if the value for the given key is not null.

getPropertyback to summary
public String getProperty(String key)

Return the property value associated with the given key, or null if the key cannot be resolved.

Parameters
key:String

the property name to resolve

Annotations
@Nullable
See Also
getProperty(String, String), getProperty(String, Class), getRequiredProperty(String)
getPropertyback to summary
public String getProperty(String key, String defaultValue)

Return the property value associated with the given key, or defaultValue if the key cannot be resolved.

Parameters
key:String

the property name to resolve

defaultValue:String

the default value to return if no value is found

See Also
getRequiredProperty(String), getProperty(String, Class)
getPropertyback to summary
public <T> T getProperty(String key, Class<T> targetType)

Return the property value associated with the given key, or null if the key cannot be resolved.

Parameters
key:String

the property name to resolve

targetType:Class<T>

the expected type of the property value

Annotations
@Nullable
See Also
getRequiredProperty(String, Class)
getPropertyback to summary
public <T> T getProperty(String key, Class<T> targetType, T defaultValue)

Return the property value associated with the given key, or defaultValue if the key cannot be resolved.

Parameters
key:String

the property name to resolve

targetType:Class<T>

the expected type of the property value

defaultValue:T

the default value to return if no value is found

See Also
getRequiredProperty(String, Class)
getRequiredPropertyback to summary
public String getRequiredProperty(String key) throws IllegalStateException

Return the property value associated with the given key (never null).

Exceptions
IllegalStateException:
if the key cannot be resolved
See Also
getRequiredProperty(String, Class)
getRequiredPropertyback to summary
public <T> T getRequiredProperty(String key, Class<T> targetType) throws IllegalStateException

Return the property value associated with the given key, converted to the given targetType (never null).

Exceptions
IllegalStateException:
if the given key cannot be resolved
resolvePlaceholdersback to summary
public String resolvePlaceholders(String text)

Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by getProperty. Unresolvable placeholders with no default value are ignored and passed through unchanged.

Parameters
text:String

the String to resolve

Returns:String

the resolved String (never null)

Exceptions
IllegalArgumentException:
if given text is null
See Also
resolveRequiredPlaceholders
resolveRequiredPlaceholdersback to summary
public String resolveRequiredPlaceholders(String text) throws IllegalArgumentException

Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by getProperty. Unresolvable placeholders with no default value will cause an IllegalArgumentException to be thrown.

Returns:String

the resolved String (never null)

Exceptions
IllegalArgumentException:
if given text is null or if any placeholders are unresolvable