T
- The component
type of the field that this OptionHandler
works with.
When I say "component", I mean a field that can hold multiple values
(such as Collection
or array). This should refer to its component time.
Setter
implementations abstract away multi-value-ness by allowing OptionHandler
to invoke its Setter.addValue(Object)
multiple times.public abstract class OptionHandler<T> extends Object
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)
.
Modifier and Type | Field and Description |
---|---|
OptionDef |
option
The annotation.
|
CmdLineParser |
owner
The owner to which this handler belongs to.
|
Setter<? super T> |
setter
Object to be used for setting value.
|
Modifier | Constructor and Description |
---|---|
protected |
OptionHandler(CmdLineParser parser,
OptionDef option,
Setter<? super T> setter) |
Modifier and Type | Method and Description |
---|---|
abstract String |
getDefaultMetaVariable()
Gets the default meta variable name used to print the usage screen.
|
String |
getMetaVariable(ResourceBundle rb) |
String |
getNameAndMeta(ResourceBundle rb)
Get string representing usage for this option, of the form "name metaval",
e.g.
|
String |
getNameAndMeta(ResourceBundle rb,
ParserProperties properties)
Get string representing usage for this option, of the form "name metaval" or "name=metaval,
e.g.
|
abstract int |
parseArguments(Parameters params)
Called if the option that this owner recognizes is found.
|
protected String |
print(T v)
The opposite of the parse operation.
|
String |
printDefaultValue()
Prints the default value by introspecting the current setter as
Getter . |
public final OptionDef option
public final CmdLineParser owner
protected OptionHandler(CmdLineParser parser, OptionDef option, Setter<? super T> setter)
public abstract int parseArguments(Parameters params) throws CmdLineException
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.0
if this option doesn't take any parameters.)CmdLineException
public abstract String getDefaultMetaVariable()
ResourceBundle
, if one was passed to
CmdLineParser
.null
to hide a meta variable.public String getMetaVariable(ResourceBundle rb)
public final String getNameAndMeta(ResourceBundle rb)
rb
- ResourceBundle to get localized version of meta stringpublic final String getNameAndMeta(ResourceBundle rb, ParserProperties properties)
rb
- ResourceBundle to get localized version of meta stringproperties
- Affects the formatting behaviours.protected String print(T v)
Copyright © 2003-2016 Kohsuke Kawaguchi. All Rights Reserved.