E - the return type of the optionpublic abstract class Option<E> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static ResourceBundle |
bundle
Resources for internationalization.
|
protected static String |
ILLEGAL_SN_CHARS
String denoting illegal characters for short name.
|
protected static Locale |
locale
Locale for help/error display. |
protected static int |
MAX_COUNT_LIMIT
Limit to maximum number of occurrences required for this option (set to an arbitrary 100).
|
protected static int |
MIN_COUNT_LIMIT
Limit to minimum number of occurrences required for this option.
|
protected List<E> |
values
List of values for this option.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Option(String shortName,
String longName,
String description,
boolean requiresValue,
boolean mandatory,
boolean allowMany)
Creates a new
Option instance. |
protected |
Option(String shortName,
String longName,
String description,
boolean requiresValue,
int minCount,
int maxCount)
Creates a new
Option instance. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addValue(E value)
Adds the specified value to the list of those parsed.
|
boolean |
equals(Object obj) |
String |
getDescription()
Returns the description text of this Option.
|
String |
getLongName()
Returns the long name of this option.
|
int |
getMaxCount()
Returns the maximum value count for this option.
|
int |
getMinCount()
Returns the minimum value count for this option.
|
String |
getShortName()
Returns the short name of this option.
|
abstract Class<E> |
getType()
Returns the class type of value this option can take.
|
protected String |
getUsageTypeString()
Returns the option type, for display in the usage message.
|
List<E> |
getValues()
Returns the mapped value of the specified argument if it exists.
|
int |
hashCode() |
boolean |
isAllowMany()
Returns whether this option allows multiple values to be set.
|
boolean |
isHidden()
Returns whether this option is hidden from the usage message.
|
boolean |
isMandatory()
Returns whether this option is mandatory.
|
protected abstract E |
parseValue(String arg)
Parses the argument string for an option value.
|
boolean |
requiresValue()
Returns whether this option requires a value.
|
Option<E> |
setHidden()
Sets the flag to hide this option from the usage message.
|
void |
setMinMaxCounts(int minCount,
int maxCount)
Sets the minimum/maximum value counts for this option.
|
String |
toString() |
protected static final String ILLEGAL_SN_CHARS
protected static final int MIN_COUNT_LIMIT
protected static final int MAX_COUNT_LIMIT
protected static final Locale locale
Locale for help/error display.protected static final ResourceBundle bundle
protected Option(String shortName, String longName, String description, boolean requiresValue, int minCount, int maxCount)
Option instance.shortName - short name of the option (must be non-null; e.g. -?)longName - long name of the option (e.g. --help)description - helpful description of the option (printed for usage message)requiresValue - whether this option requires a subsequently-specified valueminCount - minimum number of occurrences required for this optionmaxCount - maximum number of occurrences required for this optionprotected Option(String shortName, String longName, String description, boolean requiresValue, boolean mandatory, boolean allowMany)
Option instance.shortName - short name of the option (must be non-null; e.g. -?)longName - long name of the option (e.g. --help)description - helpful description of the option (printed for usage message)requiresValue - whether this option requires a subsequently-specified valuemandatory - whether this option must be specifiedallowMany - whether this option can take more than one value (i.e. be specified more than once)public abstract Class<E> getType()
protected String getUsageTypeString()
public List<E> getValues()
protected void addValue(E value) throws OptionException
value - the value to add to this optionOptionException - if a single-value option already has a valueprotected abstract E parseValue(String arg) throws OptionException
Integer instance representing 123).arg - string argument from which a value is to be parsedOptionException - if a problem occurs while parsing the argument stringpublic String getShortName()
public String getLongName()
public String getDescription()
public boolean requiresValue()
public int getMinCount()
public int getMaxCount()
public boolean isMandatory()
public boolean isAllowMany()
public void setMinMaxCounts(int minCount,
int maxCount)
minCount - minimum count for the optionmaxCount - maximum count for the optionpublic Option<E> setHidden()
public boolean isHidden()
Copyright © 2015. All rights reserved.