C
- type for single element of parameter output arraypublic class MultiChoiceParameter<C> extends AbstractChoiceParameter<C[],C> implements MultiParameter
Constructor and Description |
---|
MultiChoiceParameter(String name,
char valueSep,
C[] options)
Constructor with implicit element type.
|
MultiChoiceParameter(String name,
Class<C> optClazz,
char valueSep,
C[] options)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
String |
getUsage()
Returns the usage string for this parameter.
|
char |
getValueSeparator()
Returns a character which is to be used as the separator between
values found in adjacent occurrences of the parameter in the
execution environment.
|
String |
objectToString(Environment env,
C[] objVal)
Takes a typed value of this parameter and formats it as a string
which may be used for presentation to the user.
|
void |
setDefaultOptions(C[] options)
Sets the default value for this parameter to an array containing
previously added options.
|
void |
setUsage(String usage)
Sets a usage string for this parameter.
|
C[] |
stringToObject(Environment env,
String sval)
Takes a non-blank string, as supplied by the execution environment,
and turns it into a typed value for this parameter.
|
addOption, addOption, choiceToString, clearOptions, getName, getOption, getOptionNames, getOptions, getOptionValueList, stringifyOption, stringToChoice
clearValue, getDescription, getName, getPosition, getPreferExplicit, getPrompt, getStringDefault, getValueClass, isNullPermitted, objectValue, setDescription, setDescription, setName, setNullPermitted, setPosition, setPreferExplicit, setPrompt, setStringDefault, setValue, setValueFromObject, setValueFromString, stringValue, toArray, toString
public MultiChoiceParameter(String name, Class<C> optClazz, char valueSep, C[] options)
name
- parameter nameoptClazz
- type for element value of this parametervalueSep
- separator character for multiple values in a stringoptions
- initial array of legal element values
for this parameterpublic char getValueSeparator()
MultiParameter
getValueSeparator
in interface MultiParameter
public C[] stringToObject(Environment env, String sval) throws TaskException
Parameter
It is an error to supply a null or empty string value.
If this method fails (throws a ParameterValueException)
and if allowClassnameValue
is set, then a subsequent
attempt will be made to interpret the stringVal
as the classname of a suitable class with a no-arg constructor.
stringToObject
in class Parameter<C[]>
env
- execution environment; in most cases this is not required
but for some purposes environment-specific characteristics
may influence the resultsval
- non-null, non-empty string valueTaskException
public String objectToString(Environment env, C[] objVal)
Parameter
stringToObject
should be possible,
but that is not in general required/guaranteed.
The default implementation uses the value's toString method, but subclasses can override this for smarter behaviour.
objectToString
in class Parameter<C[]>
env
- execution environmentobjVal
- typed parameter valuepublic void setUsage(String usage)
Parameter
Parameter
class uses the string "<value>"
as the default usage string.public String getUsage()
Parameter
getUsage
in class Parameter<C[]>
Parameter.setUsage(java.lang.String)
public void setDefaultOptions(C[] options)
options
- default parameter valueCopyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.