类 JOptCommandLinePropertySource
java.lang.Object
cn.taketoday.core.env.PropertySource<T>
cn.taketoday.core.env.EnumerablePropertySource<T>
cn.taketoday.core.env.CommandLinePropertySource<joptsimple.OptionSet>
cn.taketoday.core.env.JOptCommandLinePropertySource
CommandLinePropertySource implementation backed by a JOpt OptionSet.
Typical usage
Configure and execute anOptionParser 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.
- 从以下版本开始:
- 4.0
- 作者:
- Chris Beams, Juergen Hoeller, Dave Syer
- 另请参阅:
-
CommandLinePropertySourceOptionParserOptionSet
-
嵌套类概要
从类继承的嵌套类/接口 cn.taketoday.core.env.PropertySource
PropertySource.StubPropertySource -
字段概要
从类继承的字段 cn.taketoday.core.env.CommandLinePropertySource
COMMAND_LINE_PROPERTY_SOURCE_NAME, DEFAULT_NON_OPTION_ARGS_PROPERTY_NAME从类继承的字段 cn.taketoday.core.env.PropertySource
name, source -
构造器概要
构造器构造器说明JOptCommandLinePropertySource(String name, joptsimple.OptionSet options) Create a newJOptCommandLinePropertySourcehaving the given name and backed by the givenOptionSet.JOptCommandLinePropertySource(joptsimple.OptionSet options) Create a newJOptCommandLinePropertySourcehaving the default name and backed by the givenOptionSet. -
方法概要
修饰符和类型方法说明protected booleancontainsOption(String name) Return whether the set of option arguments parsed from the command line contains an option with the given name.Return the collection of non-option arguments parsed from the command line.getOptionValues(String name) Return the collection of values associated with the command line option having the given name.String[]Return the names of all properties contained by the source object (nevernull).从类继承的方法 cn.taketoday.core.env.CommandLinePropertySource
containsProperty, getProperty, setNonOptionArgsPropertyName
-
构造器详细资料
-
JOptCommandLinePropertySource
public JOptCommandLinePropertySource(joptsimple.OptionSet options) Create a newJOptCommandLinePropertySourcehaving the default name and backed by the givenOptionSet. -
JOptCommandLinePropertySource
Create a newJOptCommandLinePropertySourcehaving the given name and backed by the givenOptionSet.
-
-
方法详细资料
-
containsOption
从类复制的说明:CommandLinePropertySourceReturn whether the set of option arguments parsed from the command line contains an option with the given name.- 指定者:
containsOption在类中CommandLinePropertySource<joptsimple.OptionSet>
-
getPropertyNames
从类复制的说明:EnumerablePropertySourceReturn the names of all properties contained by the source object (nevernull).- 指定者:
getPropertyNames在类中EnumerablePropertySource<joptsimple.OptionSet>
-
getOptionValues
从类复制的说明:CommandLinePropertySourceReturn 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>
- if the option is present and has no argument (e.g.: "--foo"), return an empty
collection (
-
getNonOptionArgs
从类复制的说明:CommandLinePropertySourceReturn the collection of non-option arguments parsed from the command line. Nevernull.- 指定者:
getNonOptionArgs在类中CommandLinePropertySource<joptsimple.OptionSet>
-