|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.das2.util.ArgumentList
public class ArgumentList
Utility class for processing the String[] arguments passed into the main routine, handing positional and switch parameters. Also automatically generates the usage documentation.
Constructor Summary | |
---|---|
ArgumentList(java.lang.String programName)
creates the processor for the program. |
Method Summary | |
---|---|
void |
addBooleanSwitchArgument(java.lang.String name,
java.lang.String abbrev,
java.lang.String key,
java.lang.String description)
specify a named switch argument that is named, and we only care whether it was used or not. |
void |
addOptionalPositionArgument(int position,
java.lang.String key,
java.lang.String defaultValue,
java.lang.String description)
Specify the ith positional argument, which may be left unspecified by the user. |
void |
addOptionalSwitchArgument(java.lang.String name,
java.lang.String abbrev,
java.lang.String key,
java.lang.String defaultValue,
java.lang.String description)
specify a named switch argument that may be specified by the user. |
void |
addPositionArgument(int position,
java.lang.String key,
java.lang.String description)
Specify the ith positional argument. |
void |
addSwitchArgument(java.lang.String name,
java.lang.String abbrev,
java.lang.String key,
java.lang.String description)
specify a named switch argument that must be specified by the user. |
boolean |
getBooleanValue(java.lang.String key)
|
java.util.Map |
getMap()
return a Map of all the specified values. |
java.util.Map |
getOptions()
returns a Map of optional arguments that were specified, so you can see exactly what was specified. |
java.util.prefs.Preferences |
getPreferences()
returns the options as a java.util.prefs.Preferences object, for batch processes. |
java.lang.String |
getValue(java.lang.String key)
get the value for this parameter |
void |
printPrefsSettings()
see Vg1pws app for example use. |
void |
printUsage()
print the usage statement out to stderr. |
void |
process(java.lang.String[] args)
given the specification, process the argument list. |
void |
requireOneOf(java.lang.String[] keyNames)
requires the user specify one of these values, otherwise the usage statement is printed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ArgumentList(java.lang.String programName)
Method Detail |
---|
public java.lang.String getValue(java.lang.String key)
java.lang.IllegalArgumentException
- if the parameter name was never described.public java.util.prefs.Preferences getPreferences()
public boolean getBooleanValue(java.lang.String key)
public void addPositionArgument(int position, java.lang.String key, java.lang.String description)
position
- the position number, 0 is the first argument position after the class name.key
- the internal reference name to get the value specified.description
- a short (40 character) description of the argument.public void requireOneOf(java.lang.String[] keyNames)
keyNames
- an array of internal key names that identify parameters.public void addOptionalPositionArgument(int position, java.lang.String key, java.lang.String defaultValue, java.lang.String description)
position
- the position number, 0 is the first argument position after the class name.key
- the internal reference name to get the value specified.defaultValue
- the value that is returned if a value is not provided by the user.description
- a short (40 character) description of the argument.public void addSwitchArgument(java.lang.String name, java.lang.String abbrev, java.lang.String key, java.lang.String description)
name
- the long parameter name, which the user may enter. e.g. "level"abbrev
- short (one letter) parameter version. e.g. "l" for -l=3key
- the internal reference name to get the value specified, not necessarily but often the same as name.description
- a short (40 character) description of the argument.public void addOptionalSwitchArgument(java.lang.String name, java.lang.String abbrev, java.lang.String key, java.lang.String defaultValue, java.lang.String description)
name
- the long parameter name, which the user may enter. e.g. "level"abbrev
- short (one letter) parameter version. e.g. "l" for -l=3defaultValue
- value to return if the user doesn't specify.key
- the internal reference name to get the value specified, not necessarily but often the same as name.description
- a short (40 character) description of the argument.public void addBooleanSwitchArgument(java.lang.String name, java.lang.String abbrev, java.lang.String key, java.lang.String description)
name
- the long parameter name, which the user may enter. e.g. "level"abbrev
- short (one letter) parameter version. e.g. "l" for -l=3key
- the internal reference name to get the value specified, not necessarily but often the same as name.description
- a short (40 character) description of the argument.public void printUsage()
public java.util.Map getMap()
public java.util.Map getOptions()
public void process(java.lang.String[] args)
args
- as in public static void main( String[] args ).public void printPrefsSettings()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |