org.springframework.core.env

## 类 JOptCommandLinePropertySource

- java.lang.Object
- - org.springframework.core.env.PropertySource<T>
  - - org.springframework.core.env.EnumerablePropertySource<T>
    - - org.springframework.core.env.CommandLinePropertySource<joptsimple.OptionSet>
      - - org.springframework.core.env.JOptCommandLinePropertySource

-     public class JOptCommandLinePropertySource
      extends CommandLinePropertySource<joptsimple.OptionSet>

  `CommandLinePropertySource` implementation backed by a JOpt `OptionSet`.

  ## Typical usage

  Configure and execute an `OptionParser` against the `String[]` of arguments supplied to the `main` method, and create a `JOptCommandLinePropertySource` using the resulting `OptionSet` object:

       public static void main(String[] args) {
           OptionParser parser = new OptionParser();
           parser.accepts("option1");
           parser.accepts("option2").withRequiredArg();
           OptionSet options = parser.parse(args);
           PropertySource ps = new JOptCommandLinePropertySource(options);
           // ...
       }

  See `CommandLinePropertySource` for complete general usage examples.

  Requires JOpt Simple version 4.3 or higher. Tested against JOpt up until 5.0.

  从以下版本开始:
    3.1
  作者:
    Chris Beams, Juergen Hoeller, Dave Syer
  另请参阅:
    `CommandLinePropertySource`, `OptionParser`, `OptionSet`

- - ### 嵌套类概要

    - ### 从类继承的嵌套类/接口 org.springframework.core.env.PropertySource

      `PropertySource.StubPropertySource`

  - ### 字段概要

    - ### 从类继承的字段 org.springframework.core.env.CommandLinePropertySource

      `COMMAND_LINE_PROPERTY_SOURCE_NAME, DEFAULT_NON_OPTION_ARGS_PROPERTY_NAME`

    - ### 从类继承的字段 org.springframework.core.env.PropertySource

      `logger, name, source`

  - ### 构造器概要

    构造器
    构造器和说明
    `JOptCommandLinePropertySource(joptsimple.OptionSet options)` Create a new `JOptCommandLinePropertySource` having the default name and backed by the given `OptionSet`.
    `JOptCommandLinePropertySource(String name, joptsimple.OptionSet options)` Create a new `JOptCommandLinePropertySource` having the given name and backed by the given `OptionSet`.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `protected boolean` | `containsOption(String name)` Return whether the set of option arguments parsed from the command line contains an option with the given name.
    `protected List<String>` | `getNonOptionArgs()` Return the collection of non-option arguments parsed from the command line.
    `List<String>` | `getOptionValues(String name)` Return the collection of values associated with the command line option having the given name.
    `String[]` | `getPropertyNames()` Return the names of all properties contained by the source object (never `null`).

    - ### 从类继承的方法 org.springframework.core.env.CommandLinePropertySource

      `containsProperty, getProperty, setNonOptionArgsPropertyName`

    - ### 从类继承的方法 org.springframework.core.env.PropertySource

      `equals, getName, getSource, hashCode, named, toString`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

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

    - #### JOptCommandLinePropertySource

          public JOptCommandLinePropertySource(joptsimple.OptionSet options)

      Create a new `JOptCommandLinePropertySource` having the default name and backed by the given `OptionSet`.
      另请参阅:
        `CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME`, `CommandLinePropertySource.CommandLinePropertySource(Object)`

    - #### JOptCommandLinePropertySource

          public JOptCommandLinePropertySource(String name,
                                               joptsimple.OptionSet options)

      Create a new `JOptCommandLinePropertySource` having the given name and backed by the given `OptionSet`.

  - ### 方法详细资料

    - #### containsOption

          protected boolean containsOption(String name)

      从类复制的说明: `CommandLinePropertySource`
      Return whether the set of option arguments parsed from the command line contains an option with the given name.
      指定者:
        `containsOption` 在类中 `CommandLinePropertySource<joptsimple.OptionSet>`

    - #### getPropertyNames

          public String[] getPropertyNames()

      从类复制的说明: `EnumerablePropertySource`
      Return the names of all properties contained by the source object (never `null`).
      指定者:
        `getPropertyNames` 在类中 `EnumerablePropertySource<joptsimple.OptionSet>`

    - #### getOptionValues

          @Nullable
          public List<String> getOptionValues(String name)

      从类复制的说明: `CommandLinePropertySource`
      Return the collection of values associated with the command line option having the given name.
      - if the option is present and has no argument (e.g.: "--foo"), return an empty collection (`[]`)
      - if the option is present and has a single value (e.g. "--foo=bar"), return a collection having one element (`["bar"]`)
      - if the option is present and the underlying command line parsing library supports multiple arguments (e.g. "--foo=bar --foo=baz"), return a collection having elements for each value (`["bar", "baz"]`)
      - if the option is not present, return `null`
      指定者:
        `getOptionValues` 在类中 `CommandLinePropertySource<joptsimple.OptionSet>`

    - #### getNonOptionArgs

          protected List<String> getNonOptionArgs()

      从类复制的说明: `CommandLinePropertySource`
      Return the collection of non-option arguments parsed from the command line. Never `null`.
      指定者:
        `getNonOptionArgs` 在类中 `CommandLinePropertySource<joptsimple.OptionSet>`