uk.ac.starlink.ttools.server
Class ServletEnvironment

java.lang.Object
  extended by uk.ac.starlink.ttools.server.ServletEnvironment
All Implemented Interfaces:
Environment, TableEnvironment

public class ServletEnvironment
extends Object
implements TableEnvironment

Execution environment which can be used from a servlet.

Since:
6 Oct 2008
Author:
Mark Taylor

Constructor Summary
ServletEnvironment(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, StarTableFactory tableFactory, StarTableOutput tableOutput, JDBCAuthenticator jdbcAuth)
          Constructor.
 
Method Summary
 void acquireValue(Parameter param)
          Obtains a legal value for a given parameter from the environment and sets the parameter's value accordingly.
 void clearValue(Parameter param)
          Clears a value for a given parameter.
 PrintStream getErrorStream()
          Returns an output stream into which error or logging output from a task can be written.
 JDBCAuthenticator getJdbcAuthenticator()
          Returns a JDBC authenticator suitable for use in this environment.
 String[] getNames()
          Returns an array of parameter names which have been specified.
 PrintStream getOutputStream()
          Returns an output stream into which text output from a task can be written.
 StarTableFactory getTableFactory()
          Returns a table factory suitable for use in this environment.
 StarTableOutput getTableOutput()
          Returns a table output marshaller suitable for use in this environment.
 boolean isDebug()
          Indicates whether we are running in debug mode.
 boolean isHelp()
          Returns true if the parameters passed into this environment reprsent a request for help.
 boolean isStrictVotable()
          Determines whether votables are to be parsed in strict mode.
 void setDebug(boolean debug)
          Sets whether we are running in debug mode.
 void setStrictVotable(boolean strictVot)
          Sets whether votables should be parsed in strict mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletEnvironment

public ServletEnvironment(javax.servlet.ServletRequest request,
                          javax.servlet.ServletResponse response,
                          StarTableFactory tableFactory,
                          StarTableOutput tableOutput,
                          JDBCAuthenticator jdbcAuth)
                   throws IOException
Constructor.

Parameters:
request - servlet request
response - servlet response
tableFactory - table factory
tableOutput - table output
jdbcAuth - JDBC authenticator
Throws:
IOException
Method Detail

acquireValue

public void acquireValue(Parameter param)
                  throws TaskException
Description copied from interface: Environment
Obtains a legal value for a given parameter from the environment and sets the parameter's value accordingly.

This environment should obtain a value for the parameter par in whatever way it sees fit, and must then call par's Parameter.setValueFromString(uk.ac.starlink.task.Environment, java.lang.String) method so that the parameter knows what its new value is. If the setValueFromString call throws a ParameterValueException the environment may try to get another value (for instance by re-prompting the user) or may give up and re-throw the exception.

Specified by:
acquireValue in interface Environment
Parameters:
param - the Parameter whose value is to be obtained and set
Throws:
TaskException

clearValue

public void clearValue(Parameter param)
Description copied from interface: Environment
Clears a value for a given parameter.

Specified by:
clearValue in interface Environment
Parameters:
param - the Parameter whose value is to be cleared

getNames

public String[] getNames()
Description copied from interface: Environment
Returns an array of parameter names which have been specified. The result is not necessarily an exhaustive list of all parameters whose values can be retrieved from this environment, since an interactive environment may be able to prompt the user for values, but it can give a list of values provided explicitly or without interactive prompts.

Specified by:
getNames in interface Environment
Returns:
array of names of known supplied parameters

getOutputStream

public PrintStream getOutputStream()
Description copied from interface: Environment
Returns an output stream into which text output from a task can be written. This would correspond to standard output for a terminal-based application.

Specified by:
getOutputStream in interface Environment
Returns:
a stream for text output

getErrorStream

public PrintStream getErrorStream()
Description copied from interface: Environment
Returns an output stream into which error or logging output from a task can be written. This would correspodnd to standard error for a terminal-based application.

Specified by:
getErrorStream in interface Environment
Returns:
a stream for error output

getTableFactory

public StarTableFactory getTableFactory()
Description copied from interface: TableEnvironment
Returns a table factory suitable for use in this environment.

Specified by:
getTableFactory in interface TableEnvironment
Returns:
table factory

getTableOutput

public StarTableOutput getTableOutput()
Description copied from interface: TableEnvironment
Returns a table output marshaller suitable for use in this environment.

Specified by:
getTableOutput in interface TableEnvironment
Returns:
table output

getJdbcAuthenticator

public JDBCAuthenticator getJdbcAuthenticator()
Description copied from interface: TableEnvironment
Returns a JDBC authenticator suitable for use in this environment.

Specified by:
getJdbcAuthenticator in interface TableEnvironment
Returns:
JDBC authenticator

isDebug

public boolean isDebug()
Description copied from interface: TableEnvironment
Indicates whether we are running in debug mode.

Specified by:
isDebug in interface TableEnvironment
Returns:
true iff debugging output is required

setDebug

public void setDebug(boolean debug)
Description copied from interface: TableEnvironment
Sets whether we are running in debug mode.

Specified by:
setDebug in interface TableEnvironment
Parameters:
debug - set true if you want debugging messages

isStrictVotable

public boolean isStrictVotable()
Description copied from interface: TableEnvironment
Determines whether votables are to be parsed in strict mode.

Specified by:
isStrictVotable in interface TableEnvironment
Returns:
true if VOTables will be interpreted strictly in accordance with the standard

setStrictVotable

public void setStrictVotable(boolean strictVot)
Description copied from interface: TableEnvironment
Sets whether votables should be parsed in strict mode.

Specified by:
setStrictVotable in interface TableEnvironment
Parameters:
strictVot - true if VOTables should be interpreted strictly in accordance with the standard

isHelp

public boolean isHelp()
Returns true if the parameters passed into this environment reprsent a request for help.

Returns:
true for help request


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.