public class ArgumentParser extends Object
The command line argument proxy interface must follow these conventions:
- Methods do not define arguments
- Method names must start with get
- Allowed return types are Integer, Boolean, String, File and Charset.
Note: Do not use this class, internal use only!
Modifier and Type | Class and Description |
---|---|
static interface |
ArgumentParser.OptionalParameter |
static interface |
ArgumentParser.ParameterDescription |
Modifier and Type | Method and Description |
---|---|
static <T> String |
createUsage(Class<T>... argProxyInterfaces)
Creates a usage string which can be printed in case the user did specify the arguments
incorrectly.
|
static <T> String |
createUsage(Class<T> argProxyInterface)
Creates a usage string which can be printed in case the user did specify the arguments
incorrectly.
|
static <T> String[] |
filter(String[] args,
Class<T> argProxyInterface)
Filters arguments leaving only those pertaining to argProxyInterface.
|
static <T> T |
parse(String[] args,
Class<T> argProxyInterface)
Parses the passed arguments and creates an instance of the proxy interface.
|
static <T> boolean |
validateArguments(String[] args,
Class<T>... argProxyInterfaces)
Tests if the argument are correct or incorrect.
|
static <T> boolean |
validateArguments(String[] args,
Class<T> argProxyInterface)
Tests if the argument are correct or incorrect.
|
static <T> String |
validateArgumentsLoudly(String[] args,
Class<T>... argProxyInterfaces)
Tests if the arguments are correct or incorrect.
|
static <T> String |
validateArgumentsLoudly(String[] args,
Class<T> argProxyInterface)
Tests if the arguments are correct or incorrect.
|
public static <T> String createUsage(Class<T> argProxyInterface)
validateArguments(String[], Class)
returns false.argProxyInterface
- interface with parameter descriptionspublic static <T> String createUsage(Class<T>... argProxyInterfaces)
validateArguments(String[],
Class[])
returns false.argProxyInterfaces
- interfaces with parameter descriptionspublic static <T> boolean validateArguments(String[] args, Class<T> argProxyInterface)
parse(String[], Class)
method and reported accordingly.args
- command line argumentsargProxyInterface
- interface with parameters descriptionpublic static <T> boolean validateArguments(String[] args, Class<T>... argProxyInterfaces)
parse(String[], Class)
method and reported accordingly.args
- command line argumentsargProxyInterfaces
- interfaces with parameters descriptionpublic static <T> String validateArgumentsLoudly(String[] args, Class<T> argProxyInterface)
args
- command line argumentsargProxyInterface
- interface with parameters descriptionpublic static <T> String validateArgumentsLoudly(String[] args, Class<T>... argProxyInterfaces)
args
- command line argumentsargProxyInterfaces
- interfaces with parameters descriptionpublic static <T> T parse(String[] args, Class<T> argProxyInterface)
In case an argument value cannot be parsed a TerminateToolException
is
thrown which contains an error message which explains the problems.
args
- argumentsargProxyInterface
- interface with parameters descriptionTerminateToolException
- if an argument value cannot be parsed.IllegalArgumentException
- if validateArguments returns false, if the proxy interface is not compatible.public static <T> String[] filter(String[] args, Class<T> argProxyInterface)
T
- Targs
- argumentsargProxyInterface
- interface with parameters descriptionCopyright © 2015 The Apache Software Foundation. All rights reserved.