类 PropertyPlaceholderHelper
- java.lang.Object
- org.springframework.util.PropertyPlaceholderHelper
public class PropertyPlaceholderHelper extends Object
Utility class for working with Strings that have placeholder values in them. A placeholder takes the form${name}
. UsingPropertyPlaceholderHelper
these placeholders can be substituted for user-supplied values.Values for substitution can be supplied using a
Properties
instance or using aPropertyPlaceholderHelper.PlaceholderResolver
.- 从以下版本开始:
- 3.0
- 作者:
- Juergen Hoeller, Rob Harrop
嵌套类概要
嵌套类 修饰符和类型 类 说明 static interface
PropertyPlaceholderHelper.PlaceholderResolver
Strategy interface used to resolve replacement values for placeholders contained in Strings.
构造器概要
构造器 构造器 说明 PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix)
Creates a newPropertyPlaceholderHelper
that uses the supplied prefix and suffix.PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix, String valueSeparator, boolean ignoreUnresolvablePlaceholders)
Creates a newPropertyPlaceholderHelper
that uses the supplied prefix and suffix.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected String
parseStringValue(String value, PropertyPlaceholderHelper.PlaceholderResolver placeholderResolver, Set<String> visitedPlaceholders)
String
replacePlaceholders(String value, Properties properties)
Replaces all placeholders of format${name}
with the corresponding property from the suppliedProperties
.String
replacePlaceholders(String value, PropertyPlaceholderHelper.PlaceholderResolver placeholderResolver)
Replaces all placeholders of format${name}
with the value returned from the suppliedPropertyPlaceholderHelper.PlaceholderResolver
.
构造器详细资料
PropertyPlaceholderHelper
public PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix)
Creates a newPropertyPlaceholderHelper
that uses the supplied prefix and suffix. Unresolvable placeholders are ignored.- 参数:
placeholderPrefix
- the prefix that denotes the start of a placeholderplaceholderSuffix
- the suffix that denotes the end of a placeholder
PropertyPlaceholderHelper
public PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix, String valueSeparator, boolean ignoreUnresolvablePlaceholders)
Creates a newPropertyPlaceholderHelper
that uses the supplied prefix and suffix.- 参数:
placeholderPrefix
- the prefix that denotes the start of a placeholderplaceholderSuffix
- the suffix that denotes the end of a placeholdervalueSeparator
- the separating character between the placeholder variable and the associated default value, if anyignoreUnresolvablePlaceholders
- indicates whether unresolvable placeholders should be ignored (true
) or cause an exception (false
)
方法详细资料
replacePlaceholders
public String replacePlaceholders(String value, Properties properties)
Replaces all placeholders of format${name}
with the corresponding property from the suppliedProperties
.- 参数:
value
- the value containing the placeholders to be replacedproperties
- theProperties
to use for replacement- 返回:
- the supplied value with placeholders replaced inline
replacePlaceholders
public String replacePlaceholders(String value, PropertyPlaceholderHelper.PlaceholderResolver placeholderResolver)
Replaces all placeholders of format${name}
with the value returned from the suppliedPropertyPlaceholderHelper.PlaceholderResolver
.- 参数:
value
- the value containing the placeholders to be replacedplaceholderResolver
- thePlaceholderResolver
to use for replacement- 返回:
- the supplied value with placeholders replaced inline
parseStringValue
protected String parseStringValue(String value, PropertyPlaceholderHelper.PlaceholderResolver placeholderResolver, Set<String> visitedPlaceholders)