Package uk.ac.starlink.ttools.plot2.task
Class ParameterFinder<P extends uk.ac.starlink.task.Parameter<?>>
java.lang.Object
uk.ac.starlink.ttools.plot2.task.ParameterFinder<P>
Used for obtaining a parameter qualified by an optional suffix.
In some cases, it is desirable to allow parameters which are
logically associated with a layer suffix to be specified without
the suffix, for instance if you have three layers using the
same table x
, it's nice to write "in=x
"
as a shorthand for "in1=x in2=x in3=x
".
But if in2=x
is present in the environment, that will
be used in preference.
- Since:
- 2 Sep 2014
- Author:
- Mark Taylor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract P
createParameter
(String suffix) Concrete subclasses must implement this method to create a parameter of the right type with an arbitrary suffix.findParameter
(uk.ac.starlink.task.Environment env, String fullSuffix) Returns an existing parameter to use for obtaining a value associated with the given layer suffix from the given environment.findParameterByName
(String target, String fullSuffix) Attempts to locate a parameter known by this finder with the given name.getParameter
(uk.ac.starlink.task.Environment env, String fullSuffix) CallsfindParameter(uk.ac.starlink.task.Environment, java.lang.String)
, but if the result is null, a parameter with the full suffix is returned.
-
Constructor Details
-
ParameterFinder
public ParameterFinder()
-
-
Method Details
-
createParameter
Concrete subclasses must implement this method to create a parameter of the right type with an arbitrary suffix.- Parameters:
suffix
- arbitrary suffix- Returns:
- parameter of with the given suffix
-
getParameter
CallsfindParameter(uk.ac.starlink.task.Environment, java.lang.String)
, but if the result is null, a parameter with the full suffix is returned. In that case, the environment doesn't already have a value for the parameter, but it may take steps to obtain one (like asking the user).- Parameters:
env
- execution environment, possibly populated with valuesfullSuffix
- suffix associated with the layer for which the value is required- Returns:
- parameter for obtaining a value associated with the layer suffix, not null
-
findParameter
Returns an existing parameter to use for obtaining a value associated with the given layer suffix from the given environment. If the environment contains a value for the parameter with the given suffix, or of any shortened form of that suffix (including the empty string), that parameter is returned. Otherwise, null is returned.- Parameters:
env
- execution environment, possibly populated with valuesfullSuffix
- suffix associated with the layer for which the value is required- Returns:
- parameter for obtaining a value associated with the layer suffix, or null
-
findParameterByName
Attempts to locate a parameter known by this finder with the given name. If it can't be found, return null.- Parameters:
target
- required parameter name (not case-sensitive)fullSuffix
- suffix associated with the layer for which the value is required- Returns:
- parameter with name
target
, or null
-