public class JOptCommandLinePropertySource extends CommandLinePropertySource<joptsimple.OptionSet>
OptionSet
による CommandLinePropertySource
実装。main
メソッドに提供された引数の String[]
に対して OptionParser
を構成および実行し、結果の OptionSet
オブジェクトを使用して JOptCommandLinePropertySource
を作成します。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); // ... }完全な一般的な使用例については、
CommandLinePropertySource
を参照してください。JOpt Simple バージョン 4.3 以降が必要です。5.0 まで JOpt に対してテスト済み。
CommandLinePropertySource
, OptionParser
, OptionSet
PropertySource.StubPropertySource
COMMAND_LINE_PROPERTY_SOURCE_NAME, DEFAULT_NON_OPTION_ARGS_PROPERTY_NAME
logger, name, source
コンストラクターと説明 |
---|
JOptCommandLinePropertySource(joptsimple.OptionSet options) デフォルトの名前を持ち、指定された OptionSet に基づく新しい JOptCommandLinePropertySource を作成します。 |
JOptCommandLinePropertySource(StringSE name, joptsimple.OptionSet options) 指定された名前を持ち、指定された OptionSet に基づく新しい JOptCommandLinePropertySource を作成します。 |
修飾子と型 | メソッドと説明 |
---|---|
protected boolean | containsOption(StringSE name) コマンドラインから解析されたオプション引数のセットに、指定された名前のオプションが含まれているかどうかを返します。 |
protected ListSE<StringSE> | getNonOptionArgs() コマンドラインから解析された非オプション引数のコレクションを返します。 |
ListSE<StringSE> | getOptionValues(StringSE name) 指定された名前を持つコマンドラインオプションに関連付けられた値のコレクションを返します。 |
StringSE[] | getPropertyNames() ソースオブジェクトに含まれるすべてのプロパティの名前を返します( null は決してしないでください)。 |
containsProperty, getProperty, setNonOptionArgsPropertyName
equals, getName, getSource, hashCode, named, toString
cloneSE, finalizeSE, getClassSE, notifySE, notifyAllSE, waitSE, waitSE, waitSE
public JOptCommandLinePropertySource(joptsimple.OptionSet options)
OptionSet
に基づく新しい JOptCommandLinePropertySource
を作成します。public JOptCommandLinePropertySource(StringSE name, joptsimple.OptionSet options)
OptionSet
に基づく新しい JOptCommandLinePropertySource
を作成します。protected boolean containsOption(StringSE name)
CommandLinePropertySource
CommandLinePropertySource<joptsimple.OptionSet>
の containsOption
public StringSE[] getPropertyNames()
EnumerablePropertySource
null
は決してしないでください)。EnumerablePropertySource<joptsimple.OptionSet>
の getPropertyNames
@Nullable public ListSE<StringSE> getOptionValues(StringSE name)
CommandLinePropertySource
[]
)["bar"]
)["bar", "baz"]
)null
を返します CommandLinePropertySource<joptsimple.OptionSet>
の getOptionValues
protected ListSE<StringSE> getNonOptionArgs()
CommandLinePropertySource
null
。CommandLinePropertySource<joptsimple.OptionSet>
の getNonOptionArgs