public final class QualifiedSwitch extends FlaggedOption
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 and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
String |
getSyntax()
Returns syntax instructions for this QualifiedSwitch.
|
allowMultipleDeclarations, getLongFlag, getShortFlag, getShortFlagCharacter, setAllowMultipleDeclarations, setDefault, setDefault, setList, setListSeparator, setLongFlag, setRequired, setShortFlag, setStringParser, setUsageName
getListSeparator, getStringParser, internalSetList, internalSetListSeparator, internalSetRequired, internalSetStringParser, isList, parse, register, required, unregister
_setDefault, _setDefault, _setUsageName, addDefault, enforceParameterLock, getDefault, getHelp, getID, getUsage, getUsageName, locked, setHelp, setLocked
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.public String getSyntax()
getSyntax
in class FlaggedOption
Copyright © 2016. All rights reserved.