|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Cxt
- The type of the context object passed to
execute(String, Object)
.public static interface CommandLineParser.OptionSpec<Cxt>
The interface which the enum passed to
CommandLineParser.buildParser(Class)
must implement. Enum
constants implementing this interface implement the
execute(String, Object)
method, which is called when the
option is found in the command line. Also, they carry
CommandLineParser.OptionSpec.Option
attributes to specify the name of the argument
(such as "help" or "verbose") and its abbreviation (such as 'h' or 'v'),
as well as other data.
Nested Class Summary | |
---|---|
static class |
CommandLineParser.OptionSpec.ArgSpec
The specification for the argument of an option. |
static interface |
CommandLineParser.OptionSpec.Option
The annotation giving syntactic specifications for a command-line option. |
static class |
CommandLineParser.OptionSpec.OptionException
Thrown by the execute(String, Object) method of
CommandLineParser.OptionSpec implementors to indicate an error in the command
line. |
Method Summary | |
---|---|
void |
execute(String arg,
Cxt context)
What to do with the option when encountered. |
Method Detail |
---|
void execute(String arg, Cxt context) throws CommandLineParser.OptionSpec.OptionException
arg
- The argument given to the argument, or null
if
the argument was given no arguments. (An option annotated with
arg = ArgSpec.REQUIRED
will never be passed
null
for this argument.)context
- The context in which to perform the action. The
exact meaning of this depends on the particular implementor; a
typical context object would simply have a bunch of flags
corresponding to the options that may be set. However, there is
no general requirement on the context object (or the Cxt
type parameter to OptionSpec); in fact, an implementation
could well have null
for the context and process the
options using CommandLineParser.getOpts()
.
CommandLineParser.OptionSpec.OptionException
- If the argument is somehow invalid. The
meaning of "invalid" is dependent entirely on the
implementation; a typical case would be that an integer is
expected but the given argument doesn't parse as one. These
exceptions are caught by
CommandLineParser.parse(Object, String[])
and rethrown
as CommandLineParser.InvalidCommandLineException
objects, after being formatted with the name of the option and
the value of its argument. (Consequently, the message passed to
the OptionException constructor needn't include either.)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |