|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.nevelex.app.args.ArgumentProcessor
SINGLETON object used to processes the consumption of every command-line argument passed in to an application.
This is the equivalent of the Invoker class
of the Command Pattern.
| Method Summary | |
static ArgumentCommand |
getArgumentCommand(java.lang.String argumentName)
Returns the associated ArgumentCommand object for the supplied argumentName. |
static void |
processArguments(java.lang.String[] args)
Processes the argument list. |
static void |
processArguments(java.lang.String[] args,
int startingIndex,
int indexLimit)
Processes the argument list. |
static void |
registerArgumentCommand(java.lang.String argument,
ArgumentCommand argumentCommand)
Registers an ArgumentCommand concrete class to handle the supplied command-line argument. |
static void |
registerArgumentCommand(java.lang.String argumentLong,
java.lang.String argumentShort,
ArgumentCommand argumentCommand)
Registers an ArgumentCommand concrete class to handle the supplied long and short version of a command-line argument. |
static void |
setArgumentConsumer(ArgumentConsumer argumentConsumer)
Sets the ArgumentConsumer object used to verify that all required arguments have been given on the command-line. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static final void setArgumentConsumer(ArgumentConsumer argumentConsumer)
argumentConsumer - the ArgumentConsumer concrete instance.
public static final void registerArgumentCommand(java.lang.String argument,
ArgumentCommand argumentCommand)
argument - the command-line argument string. (e.g. "--help" or "-h")argumentCommand - the ArgumentCommand concrete instance.
public static final void registerArgumentCommand(java.lang.String argumentLong,
java.lang.String argumentShort,
ArgumentCommand argumentCommand)
argumentLong - the long version of the command-line argument string. (e.g. "--help" or "--filename")argumentShort - the short version of the command-line argument string. (e.g. "-h" or "-f")argumentCommand - the ArgumentCommand concrete instance.public static final ArgumentCommand getArgumentCommand(java.lang.String argumentName)
argumentName - the command-line argument name.
public static final void processArguments(java.lang.String[] args,
int startingIndex,
int indexLimit)
throws java.lang.IllegalStateException,
InvalidArgumentException,
MissingArgumentException,
UnknownArgumentException
Here are a few examples:
java JavaApp [options... & arguments...]ArgumentProcessor.processArguments(args, 0, args.length);ArgumentProcessor.processArguments(String[]) method.
java JavaApp [options...] <reqParam1> <reqParam2>ArgumentProcessor.processArguments(args, 0, args.length - 2);
java JavaApp <reqParam1> [options...] <reqParam2> <reqParam3>ArgumentProcessor.processArguments(args, 1, args.length - 2);
args - the command-line arguments to process.startingIndex - the starting index (inclusinve) into the command-line argument list to begin prcessing.indexLimit - the ending index (exclusive) at which to terminate command-line argument processing.
java.lang.IllegalStateException - thrown if the application is not in the desired state prior to starting or after completing argument processing.
InvalidArgumentException - thrown if the argument does not have all of its required options.
MissingArgumentException - thrown if the argument list did not contain all the required arguments.
UnknownArgumentException - thrown if the argument is not known to the application.processArguments(String[])
public static final void processArguments(java.lang.String[] args)
throws java.lang.IllegalStateException,
InvalidArgumentException,
MissingArgumentException,
UnknownArgumentException
java JavaClass inFile outFilejava JavaClass --in inFile --out outFile
args - the command-line arguments to process.
java.lang.IllegalStateException - thrown if the application is not in the desired state prior to starting argument processing.
InvalidArgumentException - thrown if the argument does not have all of its required options.
MissingArgumentException - thrown if the argument list did not contain all the required arguments.
UnknownArgumentException - thrown if the argument is not known to this application.processArguments(String[], int, int)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||