public class Switch extends Parameter implements Flagged
BooleanStringParser
internally, so their results can be
obtained from a JSAPResult using
the getBoolean() methods.
An example of a command line using a Switch is "dosomething -v", where "-v" might mean "verbose."
Flagged,
BooleanStringParser| Constructor and Description |
|---|
Switch(String id)
Creates a new Switch with the specified unique ID.
|
Switch(String id,
char shortFlag,
String longFlag)
A shortcut constructor that creates a new Switch and configures all of
its settings.
|
Switch(String id,
char shortFlag,
String longFlag,
String help)
A shortcut constructor that creates a new Switch and configures all of
its settings, including help.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getLongFlag()
Returns the long flag for this Switch.
|
char |
getShortFlag()
Returns the short flag for this Switch.
|
Character |
getShortFlagCharacter()
Returns the short flag for this Switch.
|
String |
getSyntax()
Returns usage instructions for this Switch.
|
protected List |
parse(String arg)
Creates a new BooleanStringParser to which it delegates the parsing of
the specified argument.
|
Switch |
setDefault(String defaultValue)
Sets a default value for this parameter.
|
Switch |
setDefault(String[] defaultValues)
Sets one or more default values for this parameter.
|
Switch |
setLongFlag(String longFlag)
Sets the long flag for this Switch.
|
Switch |
setShortFlag(char shortFlag)
Sets the short flag for this Switch.
|
_setDefault, _setDefault, _setUsageName, addDefault, enforceParameterLock, getDefault, getHelp, getID, getUsage, getUsageName, locked, setHelp, setLockedpublic Switch(String id)
id - the unique ID for this Switch.public Switch(String id, char shortFlag, String longFlag, String help)
id - the unique ID for this Switch.shortFlag - the short flag for this Switch (may be set to
JSAP.NO_SHORTFLAG for none).longFlag - the long flag for this Switch (may be set to
JSAP.NO_LONGFLAG for none).help - the help text for this Switch (may be set to JSAP.NO_HELPfor none).public Switch(String id, char shortFlag, String longFlag)
id - the unique ID for this Switch.shortFlag - the short flag for this Switch (may be set to
JSAP.NO_SHORTFLAG for none).longFlag - the long flag for this Switch (may be set to
JSAP.NO_LONGFLAG for none).public Switch setShortFlag(char shortFlag)
shortFlag - the short flag for this Switch.public char getShortFlag()
getShortFlag in interface Flaggedpublic Character getShortFlagCharacter()
getShortFlagCharacter in interface Flaggedpublic Switch setLongFlag(String longFlag)
longFlag - the long flag for this Switch.public String getLongFlag()
getLongFlag in interface Flaggedprotected List parse(String arg) throws ParseException
parse in class Parameterarg - the argument to parse.ParseException - if the specified parameter cannot be parsed.public String getSyntax()
public Switch setDefault(String defaultValue)
defaultValue - the default value for this parameter.setDefault(String)public Switch setDefault(String[] defaultValues)
defaultValues - the default values for this parameter.setDefault(String)Copyright © 2016. All rights reserved.