|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--mark.core.args.ArgHelper
An ArgHelper assists an application in handling command-line arguments.
Typically, an application will initialize an ArgHelper with the arguments
it receives as parameters to main. It then informs the ArgHelper which
arguments it expects, so that the ArgHelper can print a usage string
should something go wrong. Thereafter, the application will call the
ArgHelper to extract arguments.
Sample Usage:
public static void main (String[] a) {
ArgHelper args = new ArgHelper (a, "GenFeatures");
args.augmentUsage ("-v", false);
args.augmentUsage ("-f
| Constructor Summary | |
ArgHelper(java.lang.String[] args,
java.lang.String programName)
Initializes the ArgHelper. |
|
| Method Summary | |
void |
augmentUsage(java.lang.String option,
boolean required)
Appends an option to the usage string. |
void |
error(java.lang.String message)
Throws an exception. |
void |
extractAll(java.util.Collection c,
boolean required)
Extracts and all remaining arguments and places them in the given collection. |
java.lang.String |
extractFirst(boolean required)
Extracts and returns the first argument in the ArgHelper. |
boolean |
extractMatched(java.lang.String arg)
Extracts the argument that matches the given String. |
java.lang.String[] |
extractMatchedPlusMany(java.lang.String arg,
boolean required)
Extracts the argument that matches the given String and the following argument, converts the second extracted argument into a parameter list, and returns the parameter list. |
java.lang.String |
extractMatchedPlusOne(java.lang.String arg,
boolean required)
Extracts the argument that matches the given String and the following argument and returns the second extracted argument. |
int |
size()
Returns the number of arguments remaining in the ArgHelper. |
java.lang.String |
toString()
|
void |
verifyEmpty()
If an argument exists, throws an exception. |
void |
verifyNoMatch(java.lang.String arg)
Throws an exception if the given argument is in the ArgHelper. |
void |
verifyNotEmpty()
If no argument exists, throws an exception. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public ArgHelper(java.lang.String[] args,
java.lang.String programName)
args - the arguments.programName - the name of the program. If the ArgHelper ever
throws an exception, it will embed this name inside the exception
message.| Method Detail |
public java.lang.String toString()
toString in class java.lang.Object
public void error(java.lang.String message)
throws java.lang.Exception
message - the exception message.
java.lang.Exception - always.
public void augmentUsage(java.lang.String option,
boolean required)
option - the option to append (e.g. "-t").required - whether the option is required.public int size()
public void verifyNoMatch(java.lang.String arg)
throws java.lang.Exception
arg - the argument to match (e.g. "-f").
java.lang.Exception - if the argument is in the ArgHandler.
public java.lang.String extractFirst(boolean required)
throws java.lang.Exception
required - whether an argument is required.
java.lang.Exception - if required and no argument exists.
public void extractAll(java.util.Collection c,
boolean required)
throws java.lang.Exception
c - the collection.required - whether an argument is required.
java.lang.Exception - if required and no argument exists.public boolean extractMatched(java.lang.String arg)
arg - the argument to match (e.g. "-f").
public java.lang.String extractMatchedPlusOne(java.lang.String arg,
boolean required)
throws java.lang.Exception
arg - the argument to match (e.g. "-f").required - whether the match is required.
java.lang.Exception - if required and no match occurs or if a match occurs on
the last argument.
public java.lang.String[] extractMatchedPlusMany(java.lang.String arg,
boolean required)
throws java.lang.Exception
arg - the argument to match (e.g. "-f").required - whether the match is required.
java.lang.Exception - if required and no match occurs or if a match occurs
on the last argument.
public void verifyEmpty()
throws java.lang.Exception
java.lang.Exception - if an argument exists.
public void verifyNotEmpty()
throws java.lang.Exception
java.lang.Exception - if no argument exists.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||