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
public class AddEnvironment extends java.lang.Object implements 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
Constructors Constructor Description AddEnvironment(uk.ac.starlink.task.Environment baseEnv, java.util.Map<java.lang.String,java.lang.String> addMap)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acquireValue(uk.ac.starlink.task.Parameter par)
void
clearValue(uk.ac.starlink.task.Parameter par)
static AddEnvironment
createAddEnvironment(uk.ac.starlink.task.Environment baseEnv, java.util.Map<java.lang.String,java.lang.String> addMap)
Returns an AddEnvironment based on a supplied base environment and a map of key-value pairs.java.io.PrintStream
getErrorStream()
java.lang.String[]
getNames()
java.io.PrintStream
getOutputStream()
-
-
-
Method Detail
-
acquireValue
public void acquireValue(uk.ac.starlink.task.Parameter par) throws uk.ac.starlink.task.TaskException
- Specified by:
acquireValue
in interfaceuk.ac.starlink.task.Environment
- Throws:
uk.ac.starlink.task.TaskException
-
clearValue
public void clearValue(uk.ac.starlink.task.Parameter par)
- Specified by:
clearValue
in interfaceuk.ac.starlink.task.Environment
-
getNames
public java.lang.String[] getNames()
- Specified by:
getNames
in interfaceuk.ac.starlink.task.Environment
-
getOutputStream
public java.io.PrintStream getOutputStream()
- Specified by:
getOutputStream
in interfaceuk.ac.starlink.task.Environment
-
getErrorStream
public java.io.PrintStream getErrorStream()
- Specified by:
getErrorStream
in interfaceuk.ac.starlink.task.Environment
-
createAddEnvironment
public static AddEnvironment createAddEnvironment(uk.ac.starlink.task.Environment baseEnv, java.util.Map<java.lang.String,java.lang.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
-
-