Class OptionHandler<T>
java.lang.Object
org.kohsuke.args4j.spi.OptionHandler<T>
- Type Parameters:
T- Thecomponenttype of the field that thisOptionHandlerworks with. When I say "component", I mean a field that can hold multiple values (such asCollectionor array). This should refer to its component time.Setterimplementations abstract away multi-value-ness by allowingOptionHandlerto invoke itsSetter.addValue(Object)multiple times.
- Direct Known Subclasses:
BooleanOptionHandler, DelimitedOptionHandler, EnumOptionHandler, ExplicitBooleanOptionHandler, MacAddressOptionHandler, MapOptionHandler, OneArgumentOptionHandler, PatternOptionHandler, RestOfArgumentsHandler, StopOptionHandler, StringArrayOptionHandler, StringOptionHandler, SubCommandHandler, URIOptionHandler, URLOptionHandler
Code that parses operands of an option into Java.
This class can be extended by application to support additional Java datatypes in option operands.
Implementation of this class needs to be registered to args4j by using
OptionHandlerRegistry.registerHandler(Class,Class).
For registration to work, subclasses will need to implement the constructor
with the signature
OptionHandler(CmdLineParser, OptionDef, Setter).
- Author:
- Kohsuke Kawaguchi
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedOptionHandler(CmdLineParser parser, OptionDef option, Setter<? super T> setter) -
Method Summary
Modifier and TypeMethodDescriptionabstract StringGets the default meta variable name used to print the usage screen.final StringGet string representing usage for this option, of the form "name metaval", e.g.final StringgetNameAndMeta(ResourceBundle rb, ParserProperties properties) Get string representing usage for this option, of the form "name metaval" or "name=metaval, e.g.abstract intparseArguments(Parameters params) Called if the option that this owner recognizes is found.protected StringThe opposite of the parse operation.Prints the default value by introspecting the current setter asGetter.
-
Field Details
-
option
The annotation. -
setter
-
owner
The owner to which this handler belongs to.
-
-
Constructor Details
-
OptionHandler
-
-
Method Details
-
parseArguments
Called if the option that this owner recognizes is found.- Parameters:
params- The rest of the arguments. This method can use this object to access the arguments of the option if necessary. The object is valid only during the method call.- Returns:
- The number of arguments consumed. (For example, returns
0if this option doesn't take any parameters.) - Throws:
CmdLineException
-
getDefaultMetaVariable
Gets the default meta variable name used to print the usage screen. The value returned by this method can be a reference in theResourceBundle, if one was passed toCmdLineParser.- Returns:
nullto hide a meta variable.
-
getMetaVariable
-
getNameAndMeta
Get string representing usage for this option, of the form "name metaval", e.g. "-foo VALUE" or "--foo VALUE"- Parameters:
rb- ResourceBundle to get localized version of meta string
-
getNameAndMeta
Get string representing usage for this option, of the form "name metaval" or "name=metaval, e.g. "--foo VALUE" or "--foo=VALUE"- Parameters:
rb- ResourceBundle to get localized version of meta stringproperties- Affects the formatting behaviours.
-
print
-
printDefaultValue
-