Package uk.ac.starlink.ttools.task
Class MapEnvironment
- java.lang.Object
-
- uk.ac.starlink.ttools.task.MapEnvironment
-
- All Implemented Interfaces:
uk.ac.starlink.task.Environment,TableEnvironment
public class MapEnvironment extends java.lang.Object implements TableEnvironment
Environment which allows use of ttools tasks from an in-memory context. Input StarTables can be set as values of parameters and output ones can be extracted.- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Constructor Description MapEnvironment()Constructs a new environment with no values.MapEnvironment(java.util.Map<java.lang.String,java.lang.Object> map)Constructs a new environment with a map of parameter name->value pairs.MapEnvironment(MapEnvironment env)Clone constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacquireValue(uk.ac.starlink.task.Parameter<?> param)voidclearValue(uk.ac.starlink.task.Parameter<?> param)java.lang.String[]getErrorLines()Returns the error output written by the task so far, in an array one line per element.java.io.PrintStreamgetErrorStream()java.lang.StringgetErrorText()Returns a string which contains all the error output written by the task so far.uk.ac.starlink.table.jdbc.JDBCAuthenticatorgetJdbcAuthenticator()Returns a JDBC authenticator suitable for use in this environment.java.util.Map<java.lang.String,java.lang.Object>getMap()Returns the map object that contains the data for this environment.java.lang.String[]getNames()java.lang.String[]getOutputLines()Returns the output written by the task so far, in an array one line per element.java.io.PrintStreamgetOutputStream()uk.ac.starlink.table.StarTablegetOutputTable(java.lang.String paramName)If the task which has been executed in this environment has created an output table which has not been otherwise disposed of, you can get it from here.java.lang.StringgetOutputText()Returns a string which contains all the output written by the task so far.uk.ac.starlink.table.StarTableFactorygetTableFactory()Returns a table factory suitable for use in this environment.uk.ac.starlink.table.StarTableOutputgetTableOutput()Returns a table output marshaller suitable for use in this environment.java.lang.String[]getUnused()Returns an array containing any words of the input argument list which were never queried by the application to find their value.booleanisDebug()Indicates whether we are running in debug mode.booleanisStrictVotable()Determines whether votables are to be parsed in strict mode.voidsetDebug(boolean debug)Sets whether we are running in debug mode.MapEnvironmentsetResourceBase(java.lang.Class<?> clazz)Sets the class which defines the context for resource discovery.voidsetStrictVotable(boolean strict)Sets whether votables should be parsed in strict mode.MapEnvironmentsetValue(java.lang.String paramName, java.lang.Object value)Sets the value of a parameter.
-
-
-
Constructor Detail
-
MapEnvironment
public MapEnvironment()
Constructs a new environment with no values.
-
MapEnvironment
public MapEnvironment(java.util.Map<java.lang.String,java.lang.Object> map)
Constructs a new environment with a map of parameter name->value pairs.- Parameters:
map- parameter map
-
MapEnvironment
public MapEnvironment(MapEnvironment env)
Clone constructor.- Parameters:
env- environment to copy
-
-
Method Detail
-
getOutputStream
public java.io.PrintStream getOutputStream()
- Specified by:
getOutputStreamin interfaceuk.ac.starlink.task.Environment
-
getErrorStream
public java.io.PrintStream getErrorStream()
- Specified by:
getErrorStreamin interfaceuk.ac.starlink.task.Environment
-
clearValue
public void clearValue(uk.ac.starlink.task.Parameter<?> param)
- Specified by:
clearValuein interfaceuk.ac.starlink.task.Environment
-
getNames
public java.lang.String[] getNames()
- Specified by:
getNamesin interfaceuk.ac.starlink.task.Environment
-
getMap
public java.util.Map<java.lang.String,java.lang.Object> getMap()
Returns the map object that contains the data for this environment. Modify it at your own risk.- Returns:
- content map
-
getOutputText
public java.lang.String getOutputText()
Returns a string which contains all the output written by the task so far.- Returns:
- output text
-
getOutputLines
public java.lang.String[] getOutputLines()
Returns the output written by the task so far, in an array one line per element.- Returns:
- output text
-
getErrorText
public java.lang.String getErrorText()
Returns a string which contains all the error output written by the task so far.- Returns:
- error text
-
getErrorLines
public java.lang.String[] getErrorLines()
Returns the error output written by the task so far, in an array one line per element.- Returns:
- error text
-
setValue
public MapEnvironment setValue(java.lang.String paramName, java.lang.Object value)
Sets the value of a parameter. A string value is OK; in some cases other parameter types are catered for. For convenience, this method returns this object (cf. StringBuffer).- Parameters:
paramName- namevalue- string or other value- Returns:
- this
-
setResourceBase
public MapEnvironment setResourceBase(java.lang.Class<?> clazz)
Sets the class which defines the context for resource discovery.- Parameters:
clazz- resource base class- Returns:
- this
- See Also:
Class.getResource(java.lang.String)
-
getOutputTable
public uk.ac.starlink.table.StarTable getOutputTable(java.lang.String paramName)
If the task which has been executed in this environment has created an output table which has not been otherwise disposed of, you can get it from here.- Parameters:
paramName- name of a TableConsumerParameter- Returns:
- output table stored under
name
-
acquireValue
public void acquireValue(uk.ac.starlink.task.Parameter<?> param) throws uk.ac.starlink.task.TaskException- Specified by:
acquireValuein interfaceuk.ac.starlink.task.Environment- Throws:
uk.ac.starlink.task.TaskException
-
getTableFactory
public uk.ac.starlink.table.StarTableFactory getTableFactory()
Description copied from interface:TableEnvironmentReturns a table factory suitable for use in this environment.- Specified by:
getTableFactoryin interfaceTableEnvironment- Returns:
- table factory
-
getTableOutput
public uk.ac.starlink.table.StarTableOutput getTableOutput()
Description copied from interface:TableEnvironmentReturns a table output marshaller suitable for use in this environment.- Specified by:
getTableOutputin interfaceTableEnvironment- Returns:
- table output
-
getJdbcAuthenticator
public uk.ac.starlink.table.jdbc.JDBCAuthenticator getJdbcAuthenticator()
Description copied from interface:TableEnvironmentReturns a JDBC authenticator suitable for use in this environment.- Specified by:
getJdbcAuthenticatorin interfaceTableEnvironment- Returns:
- JDBC authenticator
-
isDebug
public boolean isDebug()
Description copied from interface:TableEnvironmentIndicates whether we are running in debug mode.- Specified by:
isDebugin interfaceTableEnvironment- Returns:
- true iff debugging output is required
-
setDebug
public void setDebug(boolean debug)
Description copied from interface:TableEnvironmentSets whether we are running in debug mode.- Specified by:
setDebugin interfaceTableEnvironment- Parameters:
debug- set true if you want debugging messages
-
isStrictVotable
public boolean isStrictVotable()
Description copied from interface:TableEnvironmentDetermines whether votables are to be parsed in strict mode.- Specified by:
isStrictVotablein interfaceTableEnvironment- Returns:
- true if VOTables will be interpreted strictly in accordance with the standard
-
setStrictVotable
public void setStrictVotable(boolean strict)
Description copied from interface:TableEnvironmentSets whether votables should be parsed in strict mode.- Specified by:
setStrictVotablein interfaceTableEnvironment- Parameters:
strict- true if VOTables should be interpreted strictly in accordance with the standard
-
getUnused
public java.lang.String[] getUnused()
Returns an array containing any words of the input argument list which were never queried by the application to find their value. Such unused words probably merit a warning, since they may for instance be misspelled versions of real parameters.- Returns:
- array of unused words
-
-