Package uk.ac.starlink.ttools.task
Class AddEnvironment
java.lang.Object
uk.ac.starlink.ttools.task.AddEnvironment
- All Implemented Interfaces:
uk.ac.starlink.task.Environment
Environment implementation which wraps a base environment instance and
adds some extra entries as specified by a given map.
Note this does not work perfectly, because of bad design of the
Environment class. The acquireValue method can end up
passing an instance of the wrapped environment to a parameter,
which means that subequent environment accesses made under the control
of that parameter will not pick up entries added to this environment.
A redesign of the Environment class is the only good way out of this.
Until then you have to hack round it by explicitly calling acquireValue
from this class on dependent variables before it gets done under control
of the variable they depend on.
- Since:
- 2013
- Author:
- Mark Taylor
-
Constructor Summary
ConstructorsConstructorDescriptionAddEnvironment(uk.ac.starlink.task.Environment baseEnv, Map<String, String> addMap) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidacquireValue(uk.ac.starlink.task.Parameter<?> par) voidclearValue(uk.ac.starlink.task.Parameter<?> par) static AddEnvironmentcreateAddEnvironment(uk.ac.starlink.task.Environment baseEnv, Map<String, String> addMap) Returns an AddEnvironment based on a supplied base environment and a map of key-value pairs.String[]getNames()
-
Constructor Details
-
AddEnvironment
Constructor.- Parameters:
baseEnv- base environmentaddMap- addional key-value pairs to add to this environment
-
-
Method Details
-
acquireValue
public void acquireValue(uk.ac.starlink.task.Parameter<?> par) throws uk.ac.starlink.task.TaskException - Specified by:
acquireValuein interfaceuk.ac.starlink.task.Environment- Throws:
uk.ac.starlink.task.TaskException
-
clearValue
public void clearValue(uk.ac.starlink.task.Parameter<?> par) - Specified by:
clearValuein interfaceuk.ac.starlink.task.Environment
-
getNames
- Specified by:
getNamesin interfaceuk.ac.starlink.task.Environment
-
getOutputStream
- Specified by:
getOutputStreamin interfaceuk.ac.starlink.task.Environment
-
getErrorStream
- Specified by:
getErrorStreamin interfaceuk.ac.starlink.task.Environment
-
createAddEnvironment
public static AddEnvironment createAddEnvironment(uk.ac.starlink.task.Environment baseEnv, Map<String, String> addMap) Returns an AddEnvironment based on a supplied base environment and a map of key-value pairs. If the supplied base environment is a TableEnvironment instance, the returned value will be as well.- Parameters:
baseEnv- base environmentaddMap- addional key-value pairs to add to this environment- Returns:
- Environment or TableEnvironment instance with additional entries
-