Package snaq.util.jclap
Class StringOption
- Direct Known Subclasses:
FileOption
public class StringOption extends Option<String>
Implementation of an
Option with value of type String.- Author:
- Giles Winstanley
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceStringOption.FilterAcceptance filter forStringOptioninstances. -
Field Summary
-
Constructor Summary
Constructors Constructor Description StringOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)Creates a newStringOptioninstance.StringOption(String shortName, String longName, String description, int minCount, int maxCount)Creates a newStringOptioninstance. -
Method Summary
Modifier and Type Method Description Optional<StringOption.Filter>getFilter()Returns theStringOption.Filterfor this instance.Class<String>getType()Returns the class type of value this option can take.protected StringparseValue(String arg, Locale locale)Parses the argument string for an option value, optionally using the specified locale for reference (e.g.voidsetFilter(StringOption.Filter filter)Sets theStringOption.Filterfor this instance.Methods inherited from class snaq.util.jclap.Option
addValue, equals, getDescription, getLongName, getMaxCount, getMinCount, getShortName, getValues, hashCode, isAllowMany, isHidden, isMandatory, requiresValue, setHidden, setMinMaxCounts, toString
-
Constructor Details
-
StringOption
public StringOption(String shortName, String longName, String description, int minCount, int maxCount)Creates a newStringOptioninstance.- Parameters:
shortName- short name of the option (e.g. -n)longName- long name of the option (e.g. --name)description- helpful description of the option (printed for usage message)minCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this option
-
StringOption
public StringOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany)Creates a newStringOptioninstance.- Parameters:
shortName- short name of the option (e.g. -n)longName- long name of the option (e.g. --name)description- helpful description of the option (printed for usage message)mandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)
-
-
Method Details
-
parseValue
Parses the argument string for an option value, optionally using the specified locale for reference (e.g. for date parsing).- Specified by:
parseValuein classOption<String>- Parameters:
arg- string argument from which a value is to be parsedlocale- locale as specified when initializing theCLAParserinstance- Returns:
- Value of the parsed argument string
- Throws:
OptionException- if a problem occurs while parsing the argument string
-
setFilter
Sets theStringOption.Filterfor this instance.- Parameters:
filter-Filterinstance to use for accepting/rejecting values
-
getFilter
Returns theStringOption.Filterfor this instance.- Returns:
- optional Filter instance
-
getType
Returns the class type of value this option can take.
-