|
||||||||||
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
An option that implements the Flagged interface. A flagged option is preceded by a short flag or a long flag; i.e. "-n 5" or "--number 5". FlaggedOptions also provide an additional features over unflagged options, namely the ability to be declared more than once in a command line (e.g., "-n 5 -n 10"). This is not possible with unflagged options, as they are never declared.
Flagged
,
Option
Constructor Summary | |
FlaggedOption(String id)
Creates a new FlaggedOption with the specified unique ID. |
|
FlaggedOption(String id,
StringParser stringParser,
String defaultValue,
boolean required,
char shortFlag,
String longFlag)
A shortcut constructor that creates a new FlaggedOption and configures its most commonly used settings. |
|
FlaggedOption(String id,
StringParser stringParser,
String defaultValue,
boolean required,
char shortFlag,
String longFlag,
String help)
A shortcut constructor that creates a new FlaggedOption and configures its most commonly used settings, including help. |
Method Summary | |
boolean |
allowMultipleDeclarations()
Returns a boolean indicating whether multiple declarations are allowed for this FlaggedOption. |
String |
getLongFlag()
Returns the long flag for this FlaggedOption. |
char |
getShortFlag()
Returns the short flag for this FlaggedOption. |
Character |
getShortFlagCharacter()
Returns the short flag for this FlaggedOption. |
String |
getSyntax()
Returns syntax instructions for this FlaggedOption. |
FlaggedOption |
setAllowMultipleDeclarations(boolean allowMultipleDeclarations)
Sets this FlaggedOption to allow or disallow multiple declarations. |
FlaggedOption |
setDefault(String defaultValue)
Sets a default value for this parameter. |
FlaggedOption |
setDefault(String[] defaultValues)
Sets one or more default values for this parameter. |
FlaggedOption |
setList(boolean isList)
Sets whether this FlaggedOption is a list. |
FlaggedOption |
setListSeparator(char listSeparator)
Sets the list separator character for this FlaggedOption. |
FlaggedOption |
setLongFlag(String longFlag)
Sets the long flag for this FlaggedOption. |
FlaggedOption |
setRequired(boolean required)
Sets whether this FlaggedOption is required. |
FlaggedOption |
setShortFlag(char shortFlag)
Sets the short flag for this FlaggedOption. |
FlaggedOption |
setStringParser(StringParser stringParser)
Sets the StringParser to which this FlaggedOption's parse() method should delegate. |
FlaggedOption |
setUsageName(String usageName)
Sets the name that will be displayed when getSyntax() is called |
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 FlaggedOption(String id)
id
- the unique ID for this FlaggedOption.public FlaggedOption(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 FlaggedOption(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).Method Detail |
public FlaggedOption setShortFlag(char shortFlag)
shortFlag
- the short flag for this FlaggedOption.
public char getShortFlag()
getShortFlag
in interface Flagged
public Character getShortFlagCharacter()
getShortFlagCharacter
in interface Flagged
public FlaggedOption setLongFlag(String longFlag)
longFlag
- the long flag for this FlaggedOption.
public FlaggedOption setUsageName(String usageName)
usageName
- the name to use, or null if the id should be used (default)
public String getLongFlag()
getLongFlag
in interface Flagged
public FlaggedOption setAllowMultipleDeclarations(boolean allowMultipleDeclarations)
Sets this FlaggedOption to allow or disallow multiple declarations. If multiple declarations are allowed, the flag may be specified multiple times on the command line (e.g., "-n 5 -n 10"). All of the results are aggregated in the resulting JSAPResult.
Default behavior is to disallow multiple declarations.
allowMultipleDeclarations
- if true, multiple declarations are
allowed.
public boolean allowMultipleDeclarations()
setAllowMultipleDeclarations(boolean)
public String getSyntax()
getSyntax
in class Parameter
public FlaggedOption setList(boolean isList)
isList
- if true, this Option is a list.
public FlaggedOption setListSeparator(char listSeparator)
listSeparator
- the list separator for this Option.
public FlaggedOption setRequired(boolean required)
required
- if true, this Option will be required.
public FlaggedOption setDefault(String[] defaultValues)
defaultValues
- the default values for this parameter.setDefault(String)
public FlaggedOption setDefault(String defaultValue)
defaultValue
- the default value for this parameter.setDefault(String)
public FlaggedOption setStringParser(StringParser stringParser)
stringParser
- the StringParser to which this Option's parse()
method should delegate.
StringParser
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |