org.springframework.beans.factory.config

## 类 YamlProcessor

- java.lang.Object
- - org.springframework.beans.factory.config.YamlProcessor

- 直接已知子类:
    YamlMapFactoryBean, YamlPropertiesFactoryBean

      public abstract class YamlProcessor
      extends Object

  Base class for YAML factories.

  Requires SnakeYAML 1.18 or higher, as of Spring Framework 5.0.6.

  从以下版本开始:
    4.1
  作者:
    Dave Syer, Juergen Hoeller

- - ### 嵌套类概要

    嵌套类
    限定符和类型 | 类和说明
    --- | ---
    `static interface` | `YamlProcessor.DocumentMatcher` Strategy interface used to test if properties match.
    `static interface` | `YamlProcessor.MatchCallback` Callback interface used to process the YAML parsing results.
    `static class` | `YamlProcessor.MatchStatus` Status returned from `YamlProcessor.DocumentMatcher.matches(java.util.Properties)`
    `static class` | `YamlProcessor.ResolutionMethod` Method to use for resolving resources.
    `protected static class` | `YamlProcessor.StrictMapAppenderConstructor` 已过时。 as of Spring Framework 5.0.6 (not used anymore here), superseded by SnakeYAML's own duplicate key handling

  - ### 构造器概要

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

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `protected org.yaml.snakeyaml.Yaml` | `createYaml()` Create the `Yaml` instance to use.
    `protected Map<String,Object>` | `getFlattenedMap(Map<String,Object> source)` Return a flattened version of the given map, recursively following any nested Map or Collection values.
    `protected void` | `process(YamlProcessor.MatchCallback callback)` Provide an opportunity for subclasses to process the Yaml parsed from the supplied resources.
    `void` | `setDocumentMatchers(YamlProcessor.DocumentMatcher... matchers)` A map of document matchers allowing callers to selectively use only some of the documents in a YAML resource.
    `void` | `setMatchDefault(boolean matchDefault)` Flag indicating that a document for which all the `document matchers` abstain will nevertheless match.
    `void` | `setResolutionMethod(YamlProcessor.ResolutionMethod resolutionMethod)` Method to use for resolving resources.
    `void` | `setResources(org.springframework.core.io.Resource... resources)` Set locations of YAML `resources` to be loaded.

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

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

- - ### 构造器详细资料

    - #### YamlProcessor

          public YamlProcessor()

  - ### 方法详细资料

    - #### setDocumentMatchers

          public void setDocumentMatchers(YamlProcessor.DocumentMatcher... matchers)

      A map of document matchers allowing callers to selectively use only some of the documents in a YAML resource. In YAML documents are separated by `---`lines, and each document is converted to properties before the match is made. E.g.

           environment: dev
           url: https://dev.bar.com
           name: Developer Setup
           ---
           environment: prod
           url:https://foo.bar.com
           name: My Cool App

      when mapped with

           setDocumentMatchers(properties ->
               ("prod".equals(properties.getProperty("environment")) ? MatchStatus.FOUND : MatchStatus.NOT_FOUND));

      would end up as

           environment=prod
           url=https://foo.bar.com
           name=My Cool App

      ``

    - #### setMatchDefault

          public void setMatchDefault(boolean matchDefault)

      Flag indicating that a document for which all the `document matchers` abstain will nevertheless match. Default is `true`.

    - #### setResolutionMethod

          public void setResolutionMethod(YamlProcessor.ResolutionMethod resolutionMethod)

      Method to use for resolving resources. Each resource will be converted to a Map, so this property is used to decide which map entries to keep in the final output from this factory. Default is `YamlProcessor.ResolutionMethod.OVERRIDE`.

    - #### setResources

          public void setResources(org.springframework.core.io.Resource... resources)

      Set locations of YAML `resources` to be loaded.
      另请参阅:
        `YamlProcessor.ResolutionMethod`

    - #### process

          protected void process(YamlProcessor.MatchCallback callback)

      Provide an opportunity for subclasses to process the Yaml parsed from the supplied resources. Each resource is parsed in turn and the documents inside checked against the `matchers`. If a document matches it is passed into the callback, along with its representation as Properties. Depending on the `setResolutionMethod(ResolutionMethod)` not all of the documents will be parsed.
      参数:
        `callback` - a callback to delegate to once matching documents are found
      另请参阅:
        `createYaml()`

    - #### createYaml

          protected org.yaml.snakeyaml.Yaml createYaml()

      Create the `Yaml` instance to use.

      The default implementation sets the "allowDuplicateKeys" flag to `false`, enabling built-in duplicate key handling in SnakeYAML 1.18+.

      另请参阅:
        `LoaderOptions.setAllowDuplicateKeys(boolean)`

    - #### getFlattenedMap

          protected final Map<String,Object> getFlattenedMap(Map<String,Object> source)

      Return a flattened version of the given map, recursively following any nested Map or Collection values. Entries from the resulting map retain the same order as the source. When called with the Map from a `YamlProcessor.MatchCallback` the result will contain the same values as the `YamlProcessor.MatchCallback` Properties.
      参数:
        `source` - the source map
      返回:
        a flattened map
      从以下版本开始:
        4.1.3