|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.task.Parameter
uk.ac.starlink.ttools.plottask.NamedObjectParameter
public abstract class NamedObjectParameter
Parameter subclass for selecting named options.
This resembles ChoiceParameter
in that several
named choices are available.
However, it is also possible to select options which are not in the
known option list. For this to work, a pair of methods
toString(java.lang.Object)
and fromString(java.lang.String)
must be implemented as inverses of each other so that a string can be
turned into an object.
The supplied options do not need to have names which follow this scheme.
Constructor Summary | |
---|---|
NamedObjectParameter(String name)
Constructs a new parameter with no named options. |
Method Summary | |
---|---|
void |
addOption(String name,
Object option)
Adds an option with an associated name. |
abstract Object |
fromString(String name)
Translates a string value for this parameter into the object value which it represents. |
String[] |
getNames()
Returns the names of all the named options known for this parameter. |
String |
getOptionList()
Returns a formatted XML string giving an unordered list of the options for this parameter. |
Object[] |
getOptions()
Returns the option objects for all the named options known for this parameter. |
String |
getUsage()
|
Object |
objectValue(uk.ac.starlink.task.Environment env)
Returns the value of this parameter as an object. |
void |
setDefaultOption(Object option)
Sets the default value of this parameter as an option value object. |
void |
setUsage(String usage)
|
void |
setValueFromString(uk.ac.starlink.task.Environment env,
String sval)
|
String |
toString(Object option)
Translates a possible option value of this parameter into a string which represents it as a string value. |
Methods inherited from class uk.ac.starlink.task.Parameter |
---|
checkGotValue, clearValue, getDefault, getDescription, getName, getPosition, getPreferExplicit, getPrompt, isNullPermitted, setDefault, setDescription, setDescription, setGotValue, setName, setNullPermitted, setPosition, setPreferExplicit, setPrompt, setStringValue, stringValue, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NamedObjectParameter(String name)
name
- parameter nameMethod Detail |
---|
public void addOption(String name, Object option)
toString(option)
.
name
- option aliasoption
- option value objectpublic void setValueFromString(uk.ac.starlink.task.Environment env, String sval) throws uk.ac.starlink.task.TaskException
setValueFromString
in class uk.ac.starlink.task.Parameter
uk.ac.starlink.task.TaskException
public Object objectValue(uk.ac.starlink.task.Environment env) throws uk.ac.starlink.task.TaskException
addOption(java.lang.String, java.lang.Object)
fromString(java.lang.String)
setDefaultOption(java.lang.Object)
null
, if isNullPermitted()
env
- execution environment
uk.ac.starlink.task.TaskException
public void setDefaultOption(Object option)
option
must be either one of the values added using
addOption(java.lang.String, java.lang.Object)
or toString(java.lang.Object)
must be
able to translate it. Or it could be null.
option
- new default value as an objectpublic String toString(Object option)
option
- object value
public abstract Object fromString(String name)
The implementation must be such that
fromString(toString(o)).equals(o)
.
name
- option name
public String getOptionList()
public String[] getNames()
public Object[] getOptions()
public void setUsage(String usage)
setUsage
in class uk.ac.starlink.task.Parameter
public String getUsage()
getUsage
in class uk.ac.starlink.task.Parameter
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |