|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public static interface Service.GDataRequest
The GDataRequest interface represents a streaming connection to a GData service that can be used either to send request data to the service using an OutputStream (or XmlWriter for XML content) or to receive response data from the service as an InputStream (or ParseSource for XML data). The calling client then has full control of the request data generation and response data parsing. This can be used to integrate GData services with an external Atom or RSS parsing library, such as Rome.
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 }
Service.createEntryRequest(URL)
,
Service.createFeedRequest(URL)
,
Service.createInsertRequest(URL)
,
Service.createUpdateRequest(URL)
,
Service.createDeleteRequest(URL)
Nested Class Summary | |
---|---|
static class |
Service.GDataRequest.RequestType
The RequestType enumeration defines the set of expected GData request types. |
Method Summary | |
---|---|
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. |
java.io.OutputStream |
getRequestStream()
Returns a stream that can be used to write request data to the GData service. |
XmlWriter |
getRequestWriter()
Returns an XML writer that can be used to write XML request data to the GData service. |
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. |
Method Detail |
---|
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.io.OutputStream getRequestStream() throws java.io.IOException
java.io.IOException
- error obtaining the request output stream.XmlWriter getRequestWriter() throws java.io.IOException, ServiceException
java.io.IOException
- error obtaining the request writer.
ServiceException
- error obtaining the request writer.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 header
DateTime 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 header
ParseSource 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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |