public class OptionHandlerRegistry
extends java.lang.Object
getRegistry() call.| Modifier and Type | Class and Description |
|---|---|
private class |
OptionHandlerRegistry.DefaultConstructorHandlerFactory |
static interface |
OptionHandlerRegistry.OptionHandlerFactory
Provide custom logic for creating
OptionHandler implementation. |
| Modifier and Type | Field and Description |
|---|---|
private java.util.Map<java.lang.Class,OptionHandlerRegistry.OptionHandlerFactory> |
handlers
All
OptionHandlers known to the CmdLineParser. |
private static OptionHandlerRegistry |
instance
The shared reference.
|
| Modifier | Constructor and Description |
|---|---|
private |
OptionHandlerRegistry()
Constructs an option handler manager with the
default handlers initialized.
|
| Modifier and Type | Method and Description |
|---|---|
protected OptionHandler |
createOptionHandler(CmdLineParser parser,
OptionDef o,
Setter setter)
|
private static java.lang.reflect.Constructor<? extends OptionHandler> |
getConstructor(java.lang.Class<? extends OptionHandler> handlerClass)
Finds the constructor for an option handler.
|
static OptionHandlerRegistry |
getRegistry()
Gets the option handler registry singleton instance.
|
private void |
initHandlers()
Registers the default handlers.
|
void |
registerHandler(java.lang.Class valueType,
java.lang.Class<? extends OptionHandler> handlerClass)
Registers a user-defined
OptionHandler class with args4j. |
void |
registerHandler(java.lang.Class valueType,
OptionHandlerRegistry.OptionHandlerFactory factory)
Registers a user-defined
OptionHandler class with args4j. |
private static OptionHandlerRegistry instance
getRegistry()private final java.util.Map<java.lang.Class,OptionHandlerRegistry.OptionHandlerFactory> handlers
OptionHandlers known to the CmdLineParser.
Constructors of OptionHandler-derived class keyed by their supported types.private OptionHandlerRegistry()
public static OptionHandlerRegistry getRegistry()
private void initHandlers()
private static java.lang.reflect.Constructor<? extends OptionHandler> getConstructor(java.lang.Class<? extends OptionHandler> handlerClass)
public void registerHandler(java.lang.Class valueType,
java.lang.Class<? extends OptionHandler> handlerClass)
OptionHandler class with args4j.
This method allows users to extend the behavior of args4j by writing
their own OptionHandler implementation.
valueType - The specified handler is used when the field/method annotated by Option
is of this type.handlerClass - This class must have the constructor that has the same signature as
OptionHandler.OptionHandler(CmdLineParser, OptionDef, Setter)java.lang.NullPointerException - if valueType or handlerClass is null.java.lang.IllegalArgumentException - if handlerClass is not a subtype of OptionHandler.public void registerHandler(java.lang.Class valueType,
OptionHandlerRegistry.OptionHandlerFactory factory)
OptionHandler class with args4j.
This method allows users to extend the behavior of args4j by writing
their own OptionHandler implementation.
valueType - The specified handler is used when the field/method annotated by Option
is of this type.factory - Factory to instantiate handler upon request.java.lang.NullPointerException - if valueType or factory is null.protected OptionHandler createOptionHandler(CmdLineParser parser, OptionDef o, Setter setter)