W
- parsed type of each wordpublic class WordsParameter<W> extends Parameter<W[]>
Constructor and Description |
---|
WordsParameter(String name,
Class<W[]> arrayClazz,
WordParser<W> parser)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static WordsParameter<Boolean> |
createBooleanWordsParameter(String name)
Returns an instance for which words are parsed as Booleans.
|
static WordsParameter<Double> |
createDoubleWordsParameter(String name)
Returns an instance for which words are parsed as Doubles.
|
static WordsParameter<Integer> |
createIntegerWordsParameter(String name)
Returns an instance for which words are parsed as Integers.
|
static WordsParameter<String> |
createStringWordsParameter(String name)
Returns an instance for which words are simply parsed as strings.
|
int |
getRequiredWordCount()
Returns the number of words required from this parameter.
|
WordParser<W> |
getWordParser()
Returns the parser which is being used to validate and to parse each
word in the supplied value string.
|
void |
setRequiredWordCount(int nWords)
Sets the number of words required from this parameter.
|
void |
setWordUsage(String wordUsage)
Configures the usage of this parameter from usages for given words.
|
W[] |
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.
|
W[] |
wordsValue(Environment env)
Returns the typed value of this parameter.
|
clearValue, getDescription, getName, getPosition, getPreferExplicit, getPrompt, getStringDefault, getUsage, getValueClass, isNullPermitted, objectToString, objectValue, setDescription, setDescription, setName, setNullPermitted, setPosition, setPreferExplicit, setPrompt, setStringDefault, setUsage, setValue, setValueFromObject, setValueFromString, stringValue, toArray, toString
public WordsParameter(String name, Class<W[]> arrayClazz, WordParser<W> parser)
name
- parameter namearrayClazz
- array output class of this parameterparser
- converts each input word string to a typed valuepublic void setRequiredWordCount(int nWords)
nWords
- required number of wordspublic int getRequiredWordCount()
public WordParser<W> getWordParser()
public void setWordUsage(String wordUsage)
wordUsage
- per-word usagepublic W[] wordsValue(Environment env) throws TaskException
This is just an alias for Parameter.objectValue(uk.ac.starlink.task.Environment)
.
env
- execution environmentTaskException
public W[] 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<W[]>
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 static WordsParameter<String> createStringWordsParameter(String name)
name
- parameter namepublic static WordsParameter<Integer> createIntegerWordsParameter(String name)
name
- parameter namepublic static WordsParameter<Double> createDoubleWordsParameter(String name)
name
- parameter namepublic static WordsParameter<Boolean> createBooleanWordsParameter(String name)
name
- parameter nameCopyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.