public static interface Service.GDataRequest
A GDataRequest instance will be returned by the streaming client APIs of the Service class. The basic usage pattern is:
GDataRequest request = ... // createXXXRequest API call try { OutputStream requestStream = request.getRequestStream(); // stream request data, if any request.execute() // execute the request InputStream responseStream = request.getResponseStream(); // process the response data, if any } catch (IOException ioe) { // handle errors writing to / reading from server } catch (ServiceException se) { // handle service invocation errors } finally { request.end(); }
Modifier and Type | Interface and Description |
---|---|
static class |
Service.GDataRequest.RequestType
The RequestType enumeration defines the set of expected GData request
types.
|
Modifier and Type | Method and Description |
---|---|
void |
end()
Ends all processing associated with this request and releases any
transient resources (such as open data streams) required for execution.
|
void |
execute()
Executes the GData service request.
|
ParseSource |
getParseSource()
Returns a parse source that can be used to read response data from the
GData service.
|
ContentType |
getRequestContentType()
Returns the
ContentType of the data that will be written to the
service by this request or null if no data is written to the
server by the request. |
java.io.OutputStream |
getRequestStream()
Returns a stream that can be used to write request data to the GData
service.
|
java.net.URL |
getRequestUrl()
Returns the
URL that is the target of the GData request |
ContentType |
getResponseContentType()
Returns the content type of the GData response.
|
DateTime |
getResponseDateHeader(java.lang.String headerName)
Returns the value of a header containing a header or
null if no
response header of this type exists or it could not be parsed as a valid
date. |
java.lang.String |
getResponseHeader(java.lang.String headerName)
Returns the value of the specified response header name or
null
if no response header of this type exists. |
java.io.InputStream |
getResponseStream()
Returns an input stream that can be used to read response data from the
GData service.
|
void |
setConnectTimeout(int timeout)
Sets the number of milliseconds to wait for a connection to the remote
GData service before timing out.
|
void |
setEtag(java.lang.String etag)
Sets the entity tag value that will be used to conditionalize the request
if not
null . |
void |
setHeader(java.lang.String name,
java.lang.String value)
Sets a request header (and logs it, if logging is enabled)
|
void |
setIfModifiedSince(DateTime conditionDate)
Sets the If-Modified-Since date precondition to be applied to the
request.
|
void |
setPrivateHeader(java.lang.String name,
java.lang.String value)
Sets request header (and log just the name but not the value, if logging
is enabled)
|
void |
setReadTimeout(int timeout)
Sets the number of milliseconds to wait for a response from the remote
GData service before timing out.
|
void setConnectTimeout(int timeout)
timeout
- the read timeout. A value of zero indicates an infinite
timeout.java.lang.IllegalArgumentException
- if the timeout value is negative.URLConnection.setConnectTimeout(int)
void setReadTimeout(int timeout)
timeout
- the read timeout. A value of zero indicates an infinite
timeout.java.lang.IllegalArgumentException
- if the timeout value is negative.URLConnection.setReadTimeout(int)
void setEtag(java.lang.String etag)
null
. For a query requests, the tag will cause the target
resource to be returned if the resource entity tag does not match
the specified value (i.e. if the resource has not changed). For update or
delete request types, the entity tag value is used to indicate that the
requested operation should occur only if the specified etag value does
match the specified value (i.e. if the resource has changed). A
request entity tag value may not be associated with other request types.etag
- void setIfModifiedSince(DateTime conditionDate)
NotModifiedException
will be thrown. The default
value is null
, indicating no precondition.conditionDate
- the date that should be used to limit the operation
on the target resource. The operation will only be performed if
the resource has been modified later than the specified date.void setHeader(java.lang.String name, java.lang.String value)
name
- the header namevalue
- the header valuevoid setPrivateHeader(java.lang.String name, java.lang.String value)
name
- the header namevalue
- the header valuejava.net.URL getRequestUrl()
URL
that is the target of the GData requestjava.io.OutputStream getRequestStream() throws java.io.IOException
java.io.IOException
- error obtaining the request output stream.ContentType getRequestContentType()
ContentType
of the data that will be written to the
service by this request or null
if no data is written to the
server by the request.void execute() throws java.io.IOException, ServiceException
java.io.IOException
- error writing to or reading from GData service.ResourceNotFoundException
- invalid request
target resource.ServiceException
- system error executing request.ContentType getResponseContentType() throws java.io.IOException, ServiceException
null
if no
response content.java.lang.IllegalStateException
- attempt to read content type without first
calling execute()
.java.io.IOException
- error obtaining the response content type.ServiceException
- error obtaining the response content type.java.io.InputStream getResponseStream() throws java.io.IOException
getParseSource()
instead.
The caller is responsible for ensuring that the input stream is properly closed after the response has been read.
java.lang.IllegalStateException
- attempt to read response without first
calling execute()
.java.io.IOException
- error obtaining the response input stream.java.lang.String getResponseHeader(java.lang.String headerName)
null
if no response header of this type exists.headerName
- name of headerDateTime getResponseDateHeader(java.lang.String headerName)
null
if no
response header of this type exists or it could not be parsed as a valid
date.headerName
- name of headerParseSource getParseSource() throws java.io.IOException, ServiceException
The caller is responsible for ensuring that input streams and readers contained in the parse source are properly closed after the response has been read.
java.lang.IllegalStateException
- attempt to read response without first
calling execute()
.java.io.IOException
- error obtaining the response data.ServiceException
- error obtaining the response data.void end()