|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.martiansoftware.jsap.Parameter
com.martiansoftware.jsap.Option
com.martiansoftware.jsap.FlaggedOption
com.martiansoftware.jsap.QualifiedSwitch
A QualifiedSwitch is a parameter that has something in common with a Switch, i.e., its presence or absence is significant, but different from a "pure" Switch it can have an additional value (or values) prefixed by a ':' sign that qualifies the Switch - making it behave like a FlaggedOption if a value is specified.
QualifiedSwitch in fact extends FlaggedOption, providing all of its functionality including the ability to use any StringParser to parse its optional value(s). Values are retrieved from the JSAPResult in the same manner they would be retrieved for an equivalent FlaggedOption.
Additionally, the QualifiedSwitch's presence on the command line can be determined via JSAPResult.getBoolean(id). This presents a small challenge in the unlikely event that you're also using a BooleanStringParser with the QualifiedSwitch; if you are, JSAPResult.getBoolean(id) will not return the optional values, but will still signify the QualifiedSwitch's presence. Boolean optional values can be retrieved via JSAPResult.getBooleanArray(id). The first boolean in the array will be the first optionally specified boolean value qualifying the switch.
The following are some examples of a QualifiedSwitch's use:
setList(true)
and setListSeparator(',')
) has three qualifying values.Please note that QualifiedSwitch is currently experimental, although it has no known problems.
QualifiedSwitch and its supporting code in other JSAP classes was generously contributed to JSAP by Klaus P. Berg of Siemens AG, Munich, Germany.
Constructor Summary | |
QualifiedSwitch(String id)
A shortcut constructor that creates a new QualifiedSwitch |
|
QualifiedSwitch(String id,
StringParser stringParser,
String defaultValue,
boolean required,
char shortFlag,
String longFlag)
A shortcut constructor that creates a new QualifiedSwitch and configures its most commonly used settings. |
|
QualifiedSwitch(String id,
StringParser stringParser,
String defaultValue,
boolean required,
char shortFlag,
String longFlag,
String help)
A shortcut constructor that creates a new QualifiedSwitch and configures its most commonly used settings, including help. |
Method Summary | |
String |
getSyntax()
Returns syntax instructions for this QualifiedSwitch. |
Methods inherited from class com.martiansoftware.jsap.FlaggedOption |
allowMultipleDeclarations, getLongFlag, getShortFlag, getShortFlagCharacter, setAllowMultipleDeclarations, setDefault, setDefault, setList, setListSeparator, setLongFlag, setRequired, setShortFlag, setStringParser, setUsageName |
Methods inherited from class com.martiansoftware.jsap.Option |
getListSeparator, getStringParser, isList, required |
Methods inherited from class com.martiansoftware.jsap.Parameter |
addDefault, getDefault, getHelp, getID, getUsage, getUsageName, setHelp |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public QualifiedSwitch(String id, StringParser stringParser, String defaultValue, boolean required, char shortFlag, String longFlag, String help)
id
- the unique ID for this FlaggedOption.stringParser
- the StringParser this FlaggedOption should use.defaultValue
- the default value for this FlaggedOption (may be
null).required
- if true, this FlaggedOption is required.shortFlag
- the short flag for this option (may be set to
JSAP.NO_SHORTFLAG for none).longFlag
- the long flag for this option (may be set to
JSAP.NO_LONGFLAG for none).help
- the help text for this option (may be set to JSAP.NO_HELP
for none).public QualifiedSwitch(String id, StringParser stringParser, String defaultValue, boolean required, char shortFlag, String longFlag)
id
- the unique ID for this FlaggedOption.stringParser
- the StringParser this FlaggedOption should use.defaultValue
- the default value for this FlaggedOption (may be
null).required
- if true, this FlaggedOption is required.shortFlag
- the short flag for this option (may be set to
JSAP.NO_SHORTFLAG for none).longFlag
- the long flag for this option (may be set to
JSAP.NO_LONGFLAG for none).public QualifiedSwitch(String id)
id
- the unique ID for this QualifiedSwitch.Method Detail |
public String getSyntax()
getSyntax
in class FlaggedOption
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |