类 AbstractPropertyResolver
- 直接已知子类:
TypedPropertyResolver
- 从以下版本开始:
- 4.0
- 作者:
- Chris Beams, Juergen Hoeller, Harry Yang
-
字段概要
字段修饰符和类型字段说明private ConfigurableConversionServiceprivate Characterprivate booleanprivate PropertyPlaceholderHandlerprivate Stringprivate Stringprivate LinkedHashSet<String>private PropertyPlaceholderHandlerprivate String -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidaddRequiredProperties(String... requiredProperties) Specify which properties must be present, to be verified byConfigurablePropertyResolver.validateRequiredProperties().booleancontainsProperty(String key) Return whether the given property key is available for resolution, i.e. if the value for the given key is notnull.protected <T> TconvertValueIfNecessary(Object value, Class<T> targetType) Convert the given value to the specified target type, if necessary.private PropertyPlaceholderHandlercreatePlaceholderHelper(boolean ignoreUnresolvablePlaceholders) Return theConfigurableConversionServiceused when performing type conversions on properties.getProperty(String key) Return the property value associated with the given key, ornullif the key cannot be resolved.<T> TgetProperty(String key, Class<T> targetType, T defaultValue) Return the property value associated with the given key, ordefaultValueif the key cannot be resolved.getProperty(String key, String defaultValue) Return the property value associated with the given key, ordefaultValueif the key cannot be resolved.protected abstract StringRetrieve the specified property as a raw String, i.e. without resolution of nested placeholders.Return the property value associated with the given key (nevernull).<T> TgetRequiredProperty(String key, Class<T> valueType) Return the property value associated with the given key, converted to the given targetType (nevernull).protected StringresolveNestedPlaceholders(String value) Resolve placeholders within the given string, deferring to the value ofsetIgnoreUnresolvableNestedPlaceholders(boolean)to determine whether any unresolvable placeholders should raise an exception or be ignored.resolvePlaceholder(String placeholderName) Resolve the supplied placeholder name to the replacement value.resolvePlaceholders(String text) Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved byPropertyResolver.getProperty(java.lang.String).Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved byPropertyResolver.getProperty(java.lang.String).voidsetConversionService(ConfigurableConversionService conversionService) Set theConfigurableConversionServiceto be used when performing type conversions on properties.voidsetEscapeCharacter(Character escapeCharacter) Specify the escape character to use to ignore placeholder prefix or value separator, ornullif no escaping should take place.voidsetIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders) Set whether to throw an exception when encountering an unresolvable placeholder nested within the value of a given property.voidsetPlaceholderPrefix(String placeholderPrefix) Set the prefix that placeholders replaced by this resolver must begin with.voidsetPlaceholderSuffix(String placeholderSuffix) Set the suffix that placeholders replaced by this resolver must end with.voidsetRequiredProperties(String... requiredProperties) Specify which properties must be present, to be verified byConfigurablePropertyResolver.validateRequiredProperties().voidsetValueSeparator(String valueSeparator) Specify the separating character between the placeholders replaced by this resolver and their associated default value, ornullif no such special character should be processed as a value separator.voidValidate that each of the properties specified byConfigurablePropertyResolver.setRequiredProperties(java.lang.String...)is present and resolves to a non-nullvalue.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.core.env.PropertyResolver
getFlag, getFlag, getProperty
-
字段详细资料
-
conversionService
-
nonStrictHelper
-
strictHelper
-
ignoreUnresolvableNestedPlaceholders
private boolean ignoreUnresolvableNestedPlaceholders -
placeholderPrefix
-
placeholderSuffix
-
valueSeparator
-
escapeCharacter
-
requiredProperties
-
-
构造器详细资料
-
AbstractPropertyResolver
public AbstractPropertyResolver()
-
-
方法详细资料
-
getConversionService
从接口复制的说明:ConfigurablePropertyResolverReturn theConfigurableConversionServiceused when performing type conversions on properties.The configurable nature of the returned conversion service allows for the convenient addition and removal of individual
Converterinstances:ConfigurableConversionService cs = env.getConversionService(); cs.addConverter(new FooConverter()); -
setConversionService
从接口复制的说明:ConfigurablePropertyResolverSet theConfigurableConversionServiceto be used when performing type conversions on properties.Note: as an alternative to fully replacing the
ConversionService, consider adding or removing individualConverterinstances by drilling intoConfigurablePropertyResolver.getConversionService()and calling methods such as#addConverter. -
setPlaceholderPrefix
Set the prefix that placeholders replaced by this resolver must begin with.The default is "${".
-
setPlaceholderSuffix
Set the suffix that placeholders replaced by this resolver must end with.The default is "}".
-
setValueSeparator
Specify the separating character between the placeholders replaced by this resolver and their associated default value, ornullif no such special character should be processed as a value separator.The default is ":".
-
setEscapeCharacter
Specify the escape character to use to ignore placeholder prefix or value separator, ornullif no escaping should take place.The default is "\".
-
setIgnoreUnresolvableNestedPlaceholders
public void setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders) Set whether to throw an exception when encountering an unresolvable placeholder nested within the value of a given property. Afalsevalue indicates strict resolution, i.e. that an exception will be thrown. Atruevalue indicates that unresolvable nested placeholders should be passed through in their unresolved ${...} form.The default is
false. -
setRequiredProperties
从接口复制的说明:ConfigurablePropertyResolverSpecify which properties must be present, to be verified byConfigurablePropertyResolver.validateRequiredProperties(). -
addRequiredProperties
从接口复制的说明:ConfigurablePropertyResolverSpecify which properties must be present, to be verified byConfigurablePropertyResolver.validateRequiredProperties(). -
validateRequiredProperties
public void validateRequiredProperties()从接口复制的说明:ConfigurablePropertyResolverValidate that each of the properties specified byConfigurablePropertyResolver.setRequiredProperties(java.lang.String...)is present and resolves to a non-nullvalue. -
containsProperty
从接口复制的说明:PropertyResolverReturn whether the given property key is available for resolution, i.e. if the value for the given key is notnull.- 指定者:
containsProperty在接口中PropertyResolver
-
getProperty
从接口复制的说明:PropertyResolverReturn the property value associated with the given key, ornullif the key cannot be resolved.- 指定者:
getProperty在接口中PropertyResolver- 参数:
key- the property name to resolve- 另请参阅:
-
getProperty
从接口复制的说明:PropertyResolverReturn the property value associated with the given key, ordefaultValueif the key cannot be resolved.- 指定者:
getProperty在接口中PropertyResolver- 参数:
key- the property name to resolvedefaultValue- the default value to return if no value is found- 另请参阅:
-
getProperty
从接口复制的说明:PropertyResolverReturn the property value associated with the given key, ordefaultValueif the key cannot be resolved.- 指定者:
getProperty在接口中PropertyResolver- 参数:
key- the property name to resolvetargetType- the expected type of the property valuedefaultValue- the default value to return if no value is found- 另请参阅:
-
getRequiredProperty
从接口复制的说明:PropertyResolverReturn the property value associated with the given key (nevernull).- 指定者:
getRequiredProperty在接口中PropertyResolver- 抛出:
IllegalStateException- if the key cannot be resolved- 另请参阅:
-
getRequiredProperty
从接口复制的说明:PropertyResolverReturn the property value associated with the given key, converted to the given targetType (nevernull).- 指定者:
getRequiredProperty在接口中PropertyResolver- 抛出:
IllegalStateException- if the given key cannot be resolved
-
resolvePlaceholders
从接口复制的说明:PropertyResolverResolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved byPropertyResolver.getProperty(java.lang.String). Unresolvable placeholders with no default value are ignored and passed through unchanged.- 指定者:
resolvePlaceholders在接口中PropertyResolver- 参数:
text- the String to resolve- 返回:
- the resolved String (never
null) - 另请参阅:
-
resolveRequiredPlaceholders
从接口复制的说明:PropertyResolverResolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved byPropertyResolver.getProperty(java.lang.String). Unresolvable placeholders with no default value will cause an IllegalArgumentException to be thrown.- 指定者:
resolveRequiredPlaceholders在接口中PropertyResolver- 返回:
- the resolved String (never
null) - 抛出:
IllegalArgumentException- if given text isnullor if any placeholders are unresolvable
-
resolveNestedPlaceholders
Resolve placeholders within the given string, deferring to the value ofsetIgnoreUnresolvableNestedPlaceholders(boolean)to determine whether any unresolvable placeholders should raise an exception or be ignored.Invoked from
getProperty(java.lang.String)and its variants, implicitly resolving nested placeholders. In contrast,resolvePlaceholders(java.lang.String)andresolveRequiredPlaceholders(java.lang.String)do not delegate to this method but rather perform their own handling of unresolvable placeholders, as specified by each of those methods. -
createPlaceholderHelper
-
resolvePlaceholder
从接口复制的说明:PlaceholderResolverResolve the supplied placeholder name to the replacement value.- 指定者:
resolvePlaceholder在接口中PlaceholderResolver- 参数:
placeholderName- the name of the placeholder to resolve- 返回:
- the replacement value, or
nullif no replacement is to be made
-
convertValueIfNecessary
Convert the given value to the specified target type, if necessary.- 参数:
value- the original property valuetargetType- the specified target type for property retrieval- 返回:
- the converted value, or the original value if no conversion is necessary
-
getPropertyAsRawString
Retrieve the specified property as a raw String, i.e. without resolution of nested placeholders.- 参数:
key- the property name to resolve- 返回:
- the property value or
nullif none found
-