org.springframework.core.env

## 类 AbstractPropertyResolver

- java.lang.Object
- - org.springframework.core.env.AbstractPropertyResolver

- 所有已实现的接口:
    ConfigurablePropertyResolver, PropertyResolver
  直接已知子类:
    PropertySourcesPropertyResolver

      public abstract class AbstractPropertyResolver
      extends Object
      implements ConfigurablePropertyResolver

  Abstract base class for resolving properties against any underlying source.
  从以下版本开始:
    3.1
  作者:
    Chris Beams, Juergen Hoeller

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `protected Log` | `logger`

  - ### 构造器概要

    构造器
    构造器和说明
    `AbstractPropertyResolver()`

  - ### 方法概要

    所有方法 实例方法 抽象方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `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`.
    `protected <T> T` | `convertValueIfNecessary(Object value, Class<T> targetType)` Convert the given value to the specified target type, if necessary.
    `ConfigurableConversionService` | `getConversionService()` Return the `ConfigurableConversionService` used when performing type conversions on properties.
    `String` | `getProperty(String key)` Return the property value associated with the given key, or `null` if the key cannot be resolved.
    `<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.
    `String` | `getProperty(String key, String defaultValue)` Return the property value associated with the given key, or `defaultValue` if the key cannot be resolved.
    `protected abstract String` | `getPropertyAsRawString(String key)` Retrieve the specified property as a raw String, i.e. without resolution of nested placeholders.
    `String` | `getRequiredProperty(String key)` Return the property value associated with the given key (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`).
    `protected String` | `resolveNestedPlaceholders(String value)` Resolve placeholders within the given string, deferring to the value of `setIgnoreUnresolvableNestedPlaceholders(boolean)` to determine whether any unresolvable placeholders should raise an exception or be ignored.
    `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(ConfigurableConversionService conversionService)` Set the `ConfigurableConversionService` to be used when performing type conversions on properties.
    `void` | `setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders)` Set whether to throw an exception when encountering an unresolvable placeholder nested within the value of a given property.
    `void` | `setPlaceholderPrefix(String placeholderPrefix)` Set the prefix that placeholders replaced by this resolver must begin with.
    `void` | `setPlaceholderSuffix(String placeholderSuffix)` Set the suffix that placeholders replaced by this resolver must end with.
    `void` | `setRequiredProperties(String... requiredProperties)` Specify which properties must be present, to be verified by `ConfigurablePropertyResolver.validateRequiredProperties()`.
    `void` | `setValueSeparator(String valueSeparator)` Specify the separating character between the placeholders replaced by this resolver and their associated default value, or `null` if no such special character should be processed as a value separator.
    `void` | `validateRequiredProperties()` Validate that each of the properties specified by `ConfigurablePropertyResolver.setRequiredProperties(java.lang.String...)` is present and resolves to a non-`null` value.

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### 从接口继承的方法 org.springframework.core.env.PropertyResolver

      `getProperty`

- - ### 字段详细资料

    - #### logger

          protected final Log logger

  - ### 构造器详细资料

    - #### AbstractPropertyResolver

          public AbstractPropertyResolver()

  - ### 方法详细资料

    - #### getConversionService

          public ConfigurableConversionService getConversionService()

      从接口复制的说明: `ConfigurablePropertyResolver`
      Return the `ConfigurableConversionService` used when performing type conversions on properties.

      The configurable nature of the returned conversion service allows for the convenient addition and removal of individual `Converter` instances:

           ConfigurableConversionService cs = env.getConversionService();
           cs.addConverter(new FooConverter());

      指定者:
        `getConversionService` 在接口中 `ConfigurablePropertyResolver`
      另请参阅:
        `PropertyResolver.getProperty(String, Class)`, `ConverterRegistry.addConverter(org.springframework.core.convert.converter.Converter<?, ?>)`

    - #### setConversionService

          public void setConversionService(ConfigurableConversionService conversionService)

      从接口复制的说明: `ConfigurablePropertyResolver`
      Set the `ConfigurableConversionService` to be used when performing type conversions on properties.

      Note: as an alternative to fully replacing the `ConversionService`, consider adding or removing individual `Converter` instances by drilling into `ConfigurablePropertyResolver.getConversionService()` and calling methods such as `#addConverter`.

      指定者:
        `setConversionService` 在接口中 `ConfigurablePropertyResolver`
      另请参阅:
        `PropertyResolver.getProperty(String, Class)`, `ConfigurablePropertyResolver.getConversionService()`, `ConverterRegistry.addConverter(org.springframework.core.convert.converter.Converter<?, ?>)`

    - #### setPlaceholderPrefix

          public void setPlaceholderPrefix(String placeholderPrefix)

      Set the prefix that placeholders replaced by this resolver must begin with.

      The default is "${".

      指定者:
        `setPlaceholderPrefix` 在接口中 `ConfigurablePropertyResolver`
      另请参阅:
        `SystemPropertyUtils.PLACEHOLDER_PREFIX`

    - #### setPlaceholderSuffix

          public void setPlaceholderSuffix(String placeholderSuffix)

      Set the suffix that placeholders replaced by this resolver must end with.

      The default is "}".

      指定者:
        `setPlaceholderSuffix` 在接口中 `ConfigurablePropertyResolver`
      另请参阅:
        `SystemPropertyUtils.PLACEHOLDER_SUFFIX`

    - #### setValueSeparator

          public void setValueSeparator(@Nullable
                                        String valueSeparator)

      Specify the separating character between the placeholders replaced by this resolver and their associated default value, or `null` if no such special character should be processed as a value separator.

      The default is ":".

      指定者:
        `setValueSeparator` 在接口中 `ConfigurablePropertyResolver`
      另请参阅:
        `SystemPropertyUtils.VALUE_SEPARATOR`

    - #### 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. A `false` value indicates strict resolution, i.e. that an exception will be thrown. A `true` value indicates that unresolvable nested placeholders should be passed through in their unresolved ${...} form.

      The default is `false`.

      指定者:
        `setIgnoreUnresolvableNestedPlaceholders` 在接口中 `ConfigurablePropertyResolver`
      从以下版本开始:
        3.2

    - #### setRequiredProperties

          public void setRequiredProperties(String... requiredProperties)

      从接口复制的说明: `ConfigurablePropertyResolver`
      Specify which properties must be present, to be verified by `ConfigurablePropertyResolver.validateRequiredProperties()`.
      指定者:
        `setRequiredProperties` 在接口中 `ConfigurablePropertyResolver`

    - #### validateRequiredProperties

          public void validateRequiredProperties()

      从接口复制的说明: `ConfigurablePropertyResolver`
      Validate that each of the properties specified by `ConfigurablePropertyResolver.setRequiredProperties(java.lang.String...)` is present and resolves to a non-`null` value.
      指定者:
        `validateRequiredProperties` 在接口中 `ConfigurablePropertyResolver`

    - #### containsProperty

          public boolean containsProperty(String key)

      从接口复制的说明: `PropertyResolver`
      Return whether the given property key is available for resolution, i.e. if the value for the given key is not `null`.
      指定者:
        `containsProperty` 在接口中 `PropertyResolver`

    - #### getProperty

          @Nullable
          public String getProperty(String key)

      从接口复制的说明: `PropertyResolver`
      Return the property value associated with the given key, or `null` if the key cannot be resolved.
      指定者:
        `getProperty` 在接口中 `PropertyResolver`
      参数:
        `key` - the property name to resolve
      另请参阅:
        `PropertyResolver.getProperty(String, String)`, `PropertyResolver.getProperty(String, Class)`, `PropertyResolver.getRequiredProperty(String)`

    - #### getProperty

          public String getProperty(String key,
                                    String defaultValue)

      从接口复制的说明: `PropertyResolver`
      Return the property value associated with the given key, or `defaultValue` if the key cannot be resolved.
      指定者:
        `getProperty` 在接口中 `PropertyResolver`
      参数:
        `key` - the property name to resolve
        `defaultValue` - the default value to return if no value is found
      另请参阅:
        `PropertyResolver.getRequiredProperty(String)`, `PropertyResolver.getProperty(String, Class)`

    - #### getProperty

          public <T> T getProperty(String key,
                                   Class<T> targetType,
                                   T defaultValue)

      从接口复制的说明: `PropertyResolver`
      Return the property value associated with the given key, or `defaultValue` if the key cannot be resolved.
      指定者:
        `getProperty` 在接口中 `PropertyResolver`
      参数:
        `key` - the property name to resolve
        `targetType` - the expected type of the property value
        `defaultValue` - the default value to return if no value is found
      另请参阅:
        `PropertyResolver.getRequiredProperty(String, Class)`

    - #### getRequiredProperty

          public String getRequiredProperty(String key)
                                     throws IllegalStateException

      从接口复制的说明: `PropertyResolver`
      Return the property value associated with the given key (never `null`).
      指定者:
        `getRequiredProperty` 在接口中 `PropertyResolver`
      抛出:
        `IllegalStateException` - if the key cannot be resolved
      另请参阅:
        `PropertyResolver.getRequiredProperty(String, Class)`

    - #### getRequiredProperty

          public <T> T getRequiredProperty(String key,
                                           Class<T> valueType)
                                    throws IllegalStateException

      从接口复制的说明: `PropertyResolver`
      Return the property value associated with the given key, converted to the given targetType (never `null`).
      指定者:
        `getRequiredProperty` 在接口中 `PropertyResolver`
      抛出:
        `IllegalStateException` - if the given key cannot be resolved

    - #### resolvePlaceholders

          public String resolvePlaceholders(String text)

      从接口复制的说明: `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.
      指定者:
        `resolvePlaceholders` 在接口中 `PropertyResolver`
      参数:
        `text` - the String to resolve
      返回:
        the resolved String (never `null`)
      另请参阅:
        `PropertyResolver.resolveRequiredPlaceholders(java.lang.String)`, `SystemPropertyUtils.resolvePlaceholders(String)`

    - #### resolveRequiredPlaceholders

          public String resolveRequiredPlaceholders(String text)
                                             throws IllegalArgumentException

      从接口复制的说明: `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.
      指定者:
        `resolveRequiredPlaceholders` 在接口中 `PropertyResolver`
      返回:
        the resolved String (never `null`)
      抛出:
        `IllegalArgumentException` - if given text is `null` or if any placeholders are unresolvable
      另请参阅:
        `SystemPropertyUtils.resolvePlaceholders(String, boolean)`

    - #### resolveNestedPlaceholders

          protected String resolveNestedPlaceholders(String value)

      Resolve placeholders within the given string, deferring to the value of `setIgnoreUnresolvableNestedPlaceholders(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)` and `resolveRequiredPlaceholders(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.

      从以下版本开始:
        3.2
      另请参阅:
        `setIgnoreUnresolvableNestedPlaceholders(boolean)`

    - #### convertValueIfNecessary

          @Nullable
          protected <T> T convertValueIfNecessary(Object value,
                                                             @Nullable
                                                             Class<T> targetType)

      Convert the given value to the specified target type, if necessary.
      参数:
        `value` - the original property value
        `targetType` - the specified target type for property retrieval
      返回:
        the converted value, or the original value if no conversion is necessary
      从以下版本开始:
        4.3.5

    - #### getPropertyAsRawString

          @Nullable
          protected abstract String getPropertyAsRawString(String key)

      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 `null` if none found