public class TapQuery extends Object
Modifier and Type | Field and Description |
---|---|
static DataFormat |
DFLT_UPLOAD_SER
Default VOTable serialization format for uploading VOTables
to a TAP service.
|
Constructor and Description |
---|
TapQuery(TapService service,
String adql,
Map<String,String> extraParams)
Constructs a query with no uploaded tables.
|
TapQuery(TapService service,
String adql,
Map<String,String> extraParams,
Map<String,StarTable> uploadMap,
long uploadLimit,
VOTableWriter vowriter)
Constructs a query with uploaded tables.
|
TapQuery(URL serviceUrl,
String adql,
Map<String,String> extraParams)
Convenience constructor that uses a URL rather than a TapService object.
|
Modifier and Type | Method and Description |
---|---|
HttpURLConnection |
createSyncConnection(ContentCoding coding)
Opens a URL connection for the result of synchronously executing
this query.
|
StarTable |
executeSync(StoragePolicy storage,
ContentCoding coding)
Executes this query synchronously and returns the resulting table.
|
boolean |
executeSync(TableSink sink,
ContentCoding coding)
Executes this query synchronously and streams the resulting table
to a table sink.
|
static URLConnection |
followRedirects(URLConnection conn)
Takes a URLConnection and repeatedly follows 303 redirects
until a non-303 status is achieved.
|
String |
getAdql()
Returns the text of the ADQL query for this object.
|
static StarTable |
getResult(UwsJob uwsJob,
ContentCoding coding,
StoragePolicy storage)
Reads and returns the table that resulted from a successful TAP query,
represented by a given UWS job.
|
Map<String,HttpStreamParam> |
getStreamParams()
Returns the map of streamed parameters to be passed to the TAP service.
|
Map<String,String> |
getStringParams()
Returns the map of string parameters to be passed to the TAP service.
|
TapService |
getTapService()
Returns the TAP service object to which this query will be submitted.
|
static InputStream |
getVOTableStream(URLConnection conn,
ContentCoding coding)
Gets an input stream from a URL connection that should contain
a VOTable.
|
static StarTable |
readResultVOTable(URLConnection conn,
ContentCoding coding,
StoragePolicy storage)
Reads a VOTable which may represent a successful result or an error.
|
static <T> T |
scalarQuery(TapService service,
String adql,
Class<T> clazz)
Utility method to obtain a single-cell table as the result of a
synchronous TAP query.
|
static boolean |
streamResultVOTable(URLConnection conn,
ContentCoding coding,
TableSink sink)
Streams a VOTable document which may represent a successful result
or an error.
|
UwsJob |
submitAsync()
Submits this query asynchronously and returns the corresponding UWS job.
|
static StarTable |
waitForResult(UwsJob uwsJob,
ContentCoding coding,
StoragePolicy storage,
long pollMillis)
Blocks until the TAP query represented by a given UWS job has completed,
then returns a table based on the result.
|
static URL |
waitForResultUrl(UwsJob uwsJob,
long pollMillis)
Blocks until the TAP query represented by a given UWS job has completed,
then returns the URL from which the successful result can be obtained.
|
public static final DataFormat DFLT_UPLOAD_SER
DataFormat.TABLEDATA
.
BINARY would be more efficient and ought to be OK,
but at time of writing at least CADC, and under some circumstances
other services, work properly with TABLEDATA but not BINARY
uploaded tables, so for now conform to the lowest common denominator.public TapQuery(TapService service, String adql, Map<String,String> extraParams)
service
- TAP service descriptionadql
- text of ADQL queryextraParams
- key->value map for optional parameters;
if any of these match the names of standard
parameters (upper case) the standard values will
be overwritten, so use with care (may be null)public TapQuery(TapService service, String adql, Map<String,String> extraParams, Map<String,StarTable> uploadMap, long uploadLimit, VOTableWriter vowriter) throws IOException
service
- TAP service descriptionadql
- text of ADQL queryextraParams
- key->value map for optional parameters;
if any of these match the names of standard
parameters (upper case) the standard values will
be overwritten, so use with care (may be null)uploadMap
- name->table map of tables to be uploaded to
the service for the query (may be null)uploadLimit
- maximum number of bytes that may be uploaded;
if negative, no limit is applied,
ignored if uploadMap
null or emptyvowriter
- serializer for producing content of uploaded tables;
ignored if uploadMap
null or empty,
if null a default value is usedIOException
- if upload tables exceed the upload limitpublic TapQuery(URL serviceUrl, String adql, Map<String,String> extraParams)
TapServices.createDefaultTapService(java.net.URL)
and then invokes one of the other constructors.
This form is mildly deprecated, it is preferred to create your own TapService as above and submit that to one of the other constructors instead. It's present because other classes rely on it, but there is no intention to add URL-based constructors corresponding to the other TapService-based forms.
serviceUrl
- base URL of TAP serviceadql
- text of ADQL queryextraParams
- key->value map for optional parameters;
if any of these match the names of standard
parameters (upper case) the standard values will
be overwritten, so use with care (may be null)public String getAdql()
public TapService getTapService()
public Map<String,String> getStringParams()
public Map<String,HttpStreamParam> getStreamParams()
public StarTable executeSync(StoragePolicy storage, ContentCoding coding) throws IOException
storage
- storage policy for caching table datacoding
- configures HTTP compressionIOException
public boolean executeSync(TableSink sink, ContentCoding coding) throws IOException, SAXException
sink
- table destinationcoding
- configures HTTP compressionIOException
SAXException
public HttpURLConnection createSyncConnection(ContentCoding coding) throws IOException
coding
- HTTP content-coding policy
result should be interpreted with same codingIOException
public UwsJob submitAsync() throws IOException
IOException
public static URL waitForResultUrl(UwsJob uwsJob, long pollMillis) throws IOException, InterruptedException
uwsJob
- started UWS job representing an async TAP querypollMillis
- polling interval in millisecondsIOException
InterruptedException
public static StarTable waitForResult(UwsJob uwsJob, ContentCoding coding, StoragePolicy storage, long pollMillis) throws IOException, InterruptedException
uwsJob
- started UWS job representing an async TAP querycoding
- configures HTTP compressionstorage
- storage policy for caching table datapollMillis
- polling interval in millisecondsIOException
InterruptedException
public static StarTable getResult(UwsJob uwsJob, ContentCoding coding, StoragePolicy storage) throws IOException
uwsJob
- successfully completed UWS job representing
an async TAP querycoding
- configures HTTP compressionstorage
- storage policy for caching table dataIOException
public static <T> T scalarQuery(TapService service, String adql, Class<T> clazz) throws IOException
service
- TAP service descriptionadql
- query stringclazz
- class of required valueIOException
- if required result cannot be gotpublic static StarTable readResultVOTable(URLConnection conn, ContentCoding coding, StoragePolicy storage) throws IOException
conn
- connection to table resourcecoding
- HTTP content coding policy used to prepare connectionstorage
- storage policyIOException
public static boolean streamResultVOTable(URLConnection conn, ContentCoding coding, TableSink sink) throws IOException, SAXException
Note: any XML that comes after the TABLE element of the result table is ignored for the purposes of reporting the table metadata. The only thing after the end of the TABLE that affects the result of this method is the overflow flag, which affects the return value. So if you need to pick up items which might be in trailing elements, for instance Service Descriptors in later RESOURCE elements, you will have to use a different method.
conn
- connection to table resourcecoding
- HTTP content coding policy used to prepare connectionsink
- destination for table result of succesful queryIOException
SAXException
public static InputStream getVOTableStream(URLConnection conn, ContentCoding coding) throws IOException
conn
- connection to result of TAP service callcoding
- HTTP content coding policy used to prepare connectionIOException
public static URLConnection followRedirects(URLConnection conn) throws IOException
conn
- initial URL connectionhconn
)IOException
Copyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.