edu.harvard.cfa.vo.tapclient.tap
Class SyncJob

java.lang.Object
  extended by edu.harvard.cfa.vo.tapclient.tap.Job
      extended by edu.harvard.cfa.vo.tapclient.tap.SyncJob

public class SyncJob
extends Job

An object used for executing an synchronous data query.

            SyncJob syncJob = new SyncJob(service);

            // Set the parameters
            syncJob.setParameter("QUERY", "SELECT TOP 10 * FROM TAP_SCHEMA.columns");
            syncJob.setParameter("LANG", "ADQL");
            syncJob.setParameter("FORMAT", "votable");
            syncJob.setParameter("MAXREC", "1000");

            // Run the job
            InputStream resultStream = null;
            try {
                resultStream = syncJob.run();
                // ...
            } finally {
                try { 
                    resultStream.close();
                } catch (Exception ignore) {
                }
            }
 


Field Summary
 
Fields inherited from class edu.harvard.cfa.vo.tapclient.tap.Job
inlineContent, parameters
 
Constructor Summary
SyncJob(TapService service)
          Creates a SyncJob to execute a synchronous data query against the TAP service.
SyncJob(TapService service, java.lang.String query, java.lang.String lang, java.lang.String format)
          Creates a SyncJob object to execute a synchronous data query against the TAP service.
 
Method Summary
 java.io.InputStream run()
          Sends a request to the TAP service to run this SyncJob objects's data query.
 void setParameter(java.lang.String name, java.lang.String value)
          Sets the named parameter's value.
 
Methods inherited from class edu.harvard.cfa.vo.tapclient.tap.Job
addInlineUpload, addUpload, setFormat, setInlineUpload, setLang, setMaxRec, setParameter, setQuery, setRunId, setUpload
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SyncJob

public SyncJob(TapService service)
Creates a SyncJob to execute a synchronous data query against the TAP service. The TAP LANG and FORMAT parameters are set to 'ADQL' and 'votable' by default. These values may be overridden by a call to #setParameter

Parameters:
service - the TAP service service
Throws:
java.lang.IllegalArgumentException - if service is null
See Also:
SyncJob(TapService,String,String,String)

SyncJob

public SyncJob(TapService service,
               java.lang.String query,
               java.lang.String lang,
               java.lang.String format)
Creates a SyncJob object to execute a synchronous data query against the TAP service.

Parameters:
service - the TAP service service
query - the query
lang - the requested query language
format - the requested output results format
Throws:
java.lang.IllegalArgumentException - if service is null
Method Detail

setParameter

public void setParameter(java.lang.String name,
                         java.lang.String value)
Sets the named parameter's value. The parameter will be posted with the synchronous data query to the TAP service when #run is called.

Specified by:
setParameter in class Job
Parameters:
name - parameter name to add
value - parameter value to add
Throws:
java.lang.IllegalStateException - if #run has already been called on this SyncJob object.

run

public java.io.InputStream run()
                        throws HttpException,
                               java.io.IOException
Sends a request to the TAP service to run this SyncJob objects's data query. Note that the response could be either a result set in the requested format or an error document.

Returns:
InputStream the TAP service response to posting the synchronous data query.
Throws:
HttpException - if the service responses with an unexpected HTTP status.
java.io.IOException - if an error occurs creating the InputStream
java.lang.IllegalStateException - if #run has already been called on this SyncJob object.