|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object maslab.util.GetOpt
public class GetOpt
A basic GetOpt implementation. Add your options, parse the command line arguments, then get the modified value of your arguments.
Field Summary | |
---|---|
int |
helpMessageWidth
|
Constructor Summary | |
---|---|
GetOpt()
Create an empty GetOpt object. |
Method Summary | |
---|---|
void |
addBoolean(char sname,
java.lang.String lname,
boolean defaultValue,
java.lang.String helpMessage)
Add a boolean-type option. |
void |
addDouble(char sname,
java.lang.String lname,
double defaultValue,
java.lang.String helpMessage)
Add an double-type option. |
void |
addInt(char sname,
java.lang.String lname,
int defaultValue,
java.lang.String helpMessage)
Add an integer-type option. |
void |
addString(char sname,
java.lang.String lname,
java.lang.String defaultValue,
java.lang.String helpMessage)
Add a string-type option. |
void |
doHelp()
Output a "pretty" usage display based on the helpMessages of each option. |
void |
doHelp(java.io.Writer outs)
Output a "pretty" usage display based on the helpMessages of each option; sends the output to the specified Writer. |
void |
dump()
As a debugging aid, dump the values of all options to stdout. |
void |
dumpInternal(java.io.Writer outs)
As a debugging aid, dump the values of all options to the specified Writer.. |
boolean |
getBoolean(java.lang.String lname)
Determine the value of an option. |
double |
getDouble(java.lang.String lname)
Determine the value of an option. |
java.util.ArrayList<java.lang.String> |
getExtraArgs()
Return arguments that were not consumed by flag processing. |
int |
getInt(java.lang.String lname)
Determine the value of an option. |
java.lang.String |
getReason()
Get the reason for an error. |
java.lang.String |
getString(java.lang.String lname)
Determine the value of an option. |
static void |
main(java.lang.String[] args)
Simple sample code to show how to use the library. |
boolean |
parse(java.lang.String[] args)
Process command line arguments, updating the options we know about. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int helpMessageWidth
Constructor Detail |
---|
public GetOpt()
Method Detail |
---|
public java.lang.String getReason()
public void addString(char sname, java.lang.String lname, java.lang.String defaultValue, java.lang.String helpMessage)
sname
- A one letter short name or 0 if none.lname
- A multi-letter option namedefaultValue
- The default value of the optionhelpMessage
- A brief description of the optionpublic java.lang.String getString(java.lang.String lname)
lname
- The long name specified by the matching addOption
method.public void addInt(char sname, java.lang.String lname, int defaultValue, java.lang.String helpMessage)
sname
- A one letter short name or 0 if none.lname
- A multi-letter option namedefaultValue
- The default value of the optionhelpMessage
- A brief description of the optionpublic void addDouble(char sname, java.lang.String lname, double defaultValue, java.lang.String helpMessage)
sname
- A one letter short name or 0 if none.lname
- A multi-letter option namedefaultValue
- The default value of the optionhelpMessage
- A brief description of the optionpublic int getInt(java.lang.String lname)
lname
- The long name specified by the matching addOption
method.public double getDouble(java.lang.String lname)
lname
- The long name specified by the matching addOption
method.public void addBoolean(char sname, java.lang.String lname, boolean defaultValue, java.lang.String helpMessage)
sname
- A one letter short name or 0 if none.lname
- A multi-letter option namedefaultValue
- The default value of the optionhelpMessage
- A brief description of the optionpublic boolean getBoolean(java.lang.String lname)
lname
- The long name specified by the matching addOption
method.public boolean parse(java.lang.String[] args)
args
- The args passed into the main() function.
public java.util.ArrayList<java.lang.String> getExtraArgs()
public void dump()
public void dumpInternal(java.io.Writer outs) throws java.io.IOException
java.io.IOException
public void doHelp()
public void doHelp(java.io.Writer outs) throws java.io.IOException
java.io.IOException
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |