public class EnumOption extends Option
is a command line option with String
valued arguments
from a small set of given strings.
Constructor and Description |
---|
EnumOption(java.lang.String opt,
java.lang.String name,
java.lang.String usage,
int cmin,
int cmax,
java.lang.String allowed) |
EnumOption(java.lang.String opt,
java.lang.String name,
java.lang.String usage,
int cmin,
int cmax,
java.lang.String allowed,
java.lang.String[] deFault)
creates an option which accepts string values from small
enumerated set of values.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
addRestrictions(java.lang.String s)
override in subclass to describe restrictions applied to
values, like numerical range.
|
java.lang.Object |
check(java.lang.Object v)
checks if the given
Object is a valid value for this option
or can be converted to one. |
public EnumOption(java.lang.String opt, java.lang.String name, java.lang.String usage, int cmin, int cmax, java.lang.String allowed, java.lang.String[] deFault) throws CommandlineException
creates an option which accepts string values from small
enumerated set of values. Parameter allowed
must
contain the enumerated values as follows: The first character in
allowed
is used as a separator. Then
allowed
is split at every position of where the
separator appears, and the resulting substrings make up the
enumerated values. For example "|one|two|three"
defines the enumeration {"one", "two", "three"}
.
Notes:
CommandlineException
- if the defaults don't match the requirementspublic EnumOption(java.lang.String opt, java.lang.String name, java.lang.String usage, int cmin, int cmax, java.lang.String allowed)
public java.lang.Object check(java.lang.Object v) throws CommandlineException
Option
checks if the given Object
is a valid value for this option
or can be converted to one. This method converts the value, if possible and
necessary and returns the resulting Object
.
Hint: Subclasses must override this method to make sure the right objects are stored.
CommandlineException
- if the value does not meet the requirements for this option (e.g.
wrong type, value too large) and cannot be (easily) converted.