Package uk.ac.starlink.task
Class ObjectFactoryParameter<T>
- java.lang.Object
-
- uk.ac.starlink.task.Parameter<T>
-
- uk.ac.starlink.task.ObjectFactoryParameter<T>
-
public class ObjectFactoryParameter<T> extends Parameter<T>
Parameter whose (user-supplied) string values correspond to nicknames from anObjectFactory
. TheParameter.objectValue(uk.ac.starlink.task.Environment)
method returns the corresponding object generated by the factory for that nickname.- Since:
- 22 Nov 2006
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Constructor Description ObjectFactoryParameter(java.lang.String name, uk.ac.starlink.util.ObjectFactory<T> factory)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description uk.ac.starlink.util.ObjectFactory<T>
getObjectFactory()
Returns the object factory used by this parameter.java.lang.String
getUsage()
Returns the usage string for this parameter.T
stringToObject(Environment env, java.lang.String sval)
Takes a non-blank string, as supplied by the execution environment, and turns it into a typed value for this parameter.-
Methods inherited from class uk.ac.starlink.task.Parameter
clearValue, getDescription, getName, getPosition, getPreferExplicit, getPrompt, getStringDefault, getValueClass, isNullPermitted, objectToString, objectValue, setDescription, setDescription, setName, setNullPermitted, setPosition, setPreferExplicit, setPrompt, setStringDefault, setUsage, setValue, setValueFromObject, setValueFromString, stringValue, toArray, toString
-
-
-
-
Constructor Detail
-
ObjectFactoryParameter
public ObjectFactoryParameter(java.lang.String name, uk.ac.starlink.util.ObjectFactory<T> factory)
Constructor.- Parameters:
name
- parameter namefactory
- object factory
-
-
Method Detail
-
getObjectFactory
public uk.ac.starlink.util.ObjectFactory<T> getObjectFactory()
Returns the object factory used by this parameter.- Returns:
- object factory
-
stringToObject
public T stringToObject(Environment env, java.lang.String sval) throws ParameterValueException
Description copied from class:Parameter
Takes a non-blank string, as supplied by the execution environment, and turns it into a typed value for this parameter. This method also performs validation, so if the string value is unacceptable in any way, a ParameterValueException should be thrown.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 thestringVal
as the classname of a suitable class with a no-arg constructor.- Specified by:
stringToObject
in classParameter<T>
- Parameters:
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 value- Returns:
- typed value
- Throws:
ParameterValueException
-
getUsage
public java.lang.String getUsage()
Description copied from class:Parameter
Returns the usage string for this parameter.- Overrides:
getUsage
in classParameter<T>
- Returns:
- usage string
- See Also:
Parameter.setUsage(java.lang.String)
-
-