Class AbstractGoogleJsonClientRequest<T> (2.1.2)

public abstract class AbstractGoogleJsonClientRequest<T> extends AbstractGoogleClientRequest<T>

Google JSON request for a AbstractGoogleJsonClient.

Implementation is not thread-safe.

Inheritance

Object > java.util.AbstractMap > com.google.api.client.util.GenericData > AbstractGoogleClientRequest > AbstractGoogleJsonClientRequest<T>

Type Parameter

Name Description
T

Constructors

AbstractGoogleJsonClientRequest(AbstractGoogleJsonClient abstractGoogleJsonClient, String requestMethod, String uriTemplate, Object jsonContent, Class<T> responseClass)

protected AbstractGoogleJsonClientRequest(AbstractGoogleJsonClient abstractGoogleJsonClient, String requestMethod, String uriTemplate, Object jsonContent, Class<T> responseClass)
Parameters
Name Description
abstractGoogleJsonClient AbstractGoogleJsonClient

Google JSON client

requestMethod String

HTTP Method

uriTemplate String

URI template for the path relative to the base URL. If it starts with a "/" the base path from the base URL will be stripped out. The URI template can also be a full URL. URI template expansion is done using UriTemplate#expand(String, String, Object, boolean)

jsonContent Object

POJO that can be serialized into JSON content or null for none

responseClass Class<T>

response class to parse into

Methods

getAbstractGoogleClient()

public AbstractGoogleJsonClient getAbstractGoogleClient()

Returns the Google client.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Returns
Type Description
AbstractGoogleJsonClient
Overrides

getJsonContent()

public Object getJsonContent()

Returns POJO that can be serialized into JSON content or null for none.

Returns
Type Description
Object

newExceptionOnError(HttpResponse response)

protected GoogleJsonResponseException newExceptionOnError(HttpResponse response)

Returns the exception to throw on an HTTP error response as defined by HttpResponse#isSuccessStatusCode().

It is guaranteed that HttpResponse#isSuccessStatusCode() is false. Default implementation is to call HttpResponseException#HttpResponseException(HttpResponse), but subclasses may override.

Parameter
Name Description
response com.google.api.client.http.HttpResponse
Returns
Type Description
GoogleJsonResponseException
Overrides

queue(BatchRequest batchRequest, JsonBatchCallback<T> callback)

public final void queue(BatchRequest batchRequest, JsonBatchCallback<T> callback)

Queues the request into the specified batch request container.

Batched requests are then executed when BatchRequest#execute() is called.

Example usage:


 request.queue(batchRequest, new JsonBatchCallback<SomeResponseType>() {

   public void onSuccess(SomeResponseType content, HttpHeaders responseHeaders) {
     log("Success");
   }

   public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) {
     log(e.getMessage());
   }
 });
 
Parameters
Name Description
batchRequest BatchRequest

batch request container

callback JsonBatchCallback<T>

batch callback

Exceptions
Type Description
IOException

set(String fieldName, Object value)

public AbstractGoogleJsonClientRequest<T> set(String fieldName, Object value)
Parameters
Name Description
fieldName String
value Object
Returns
Type Description
AbstractGoogleJsonClientRequest<T>
Overrides

setDisableGZipContent(boolean disableGZipContent)

public AbstractGoogleJsonClientRequest<T> setDisableGZipContent(boolean disableGZipContent)

Sets whether to disable GZip compression of HTTP content.

By default it is false.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
Name Description
disableGZipContent boolean
Returns
Type Description
AbstractGoogleJsonClientRequest<T>
Overrides

setRequestHeaders(HttpHeaders headers)

public AbstractGoogleJsonClientRequest<T> setRequestHeaders(HttpHeaders headers)

Sets the HTTP headers used for the Google client request.

These headers are set on the request after #buildHttpRequest is called, this means that HttpRequestInitializer#initialize is called first.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
Name Description
headers com.google.api.client.http.HttpHeaders
Returns
Type Description
AbstractGoogleJsonClientRequest<T>
Overrides