|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iglu.util.CommandLineParser
A command line parser for applications. It does not do anything with
the commands that it parses, but it sorts them out, and provides an easy way
for an application to query whether some option was present on the command
line.
Two important terms to understand
Field Summary | |
private java.util.LinkedList |
extras
Command line options present that could not be associated with option switches |
private java.util.HashMap |
params
The list of parameters and their values. |
Constructor Summary | |
CommandLineParser(java.lang.String[] argv,
char optionMarker,
boolean loadFile)
Creates new CommandLineParser |
|
CommandLineParser(java.lang.String[] argv,
char optionMarker,
boolean loadFile,
java.lang.String[] switches)
Creates a new commandlineparser, never associating the items in switches with any parameters. |
Method Summary | |
java.util.Iterator |
extrasIterator()
An iterator over the strings not associated with any options |
java.lang.String[] |
getExtras()
Returns an array of the strings passed to the command line without option tags. |
java.lang.String |
getOptionValue(java.lang.String option)
Returns the parameter associated with the option, or null if no associated parameter exists. |
protected java.lang.String[] |
loadStringsFromFile(java.lang.String fileName)
loads a file into an array of strings, and breaks them up into options |
static void |
main(java.lang.String[] argv)
Simple test. |
boolean |
optionExists(java.lang.String option)
Returns true if the option was put on the command line. |
java.util.Set |
optionSet()
All the options on the command line. |
protected void |
parseStrings(java.lang.String[] args,
char optionMarker,
java.util.LinkedList switches)
Parses the strings passes to it, interpreting them as commandline options |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private java.util.HashMap params
private java.util.LinkedList extras
Constructor Detail |
public CommandLineParser(java.lang.String[] argv, char optionMarker, boolean loadFile)
argv
- The parameters to parse.optionMarker
- What indicates an option.loadFile
- If set to true, use @filename
option to specify a file where options are stored.public CommandLineParser(java.lang.String[] argv, char optionMarker, boolean loadFile, java.lang.String[] switches)
argv
- The string to parseoptionMarker
- What denotes an optionloadFile
- Should I load a file if @ is present?switches
- Options never to associate with a parameterMethod Detail |
protected java.lang.String[] loadStringsFromFile(java.lang.String fileName)
fileName
- protected void parseStrings(java.lang.String[] args, char optionMarker, java.util.LinkedList switches)
args
- optionMarker
- switches
- public java.lang.String[] getExtras()
public boolean optionExists(java.lang.String option)
option
- public java.lang.String getOptionValue(java.lang.String option)
option
- public java.util.Set optionSet()
public java.util.Iterator extrasIterator()
public static void main(java.lang.String[] argv)
argv
-
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |