|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.api.client.http.json.JsonHttpClient
public class JsonHttpClient
JSON HTTP Client.
| Nested Class Summary | |
|---|---|
static class |
JsonHttpClient.Builder
Builder for JsonHttpClient. |
| Constructor Summary | |
|---|---|
|
JsonHttpClient(HttpTransport transport,
JsonFactory jsonFactory,
String baseUrl)
Constructor with required parameters. |
protected |
JsonHttpClient(HttpTransport transport,
JsonHttpRequestInitializer jsonHttpRequestInitializer,
HttpRequestInitializer httpRequestInitializer,
JsonFactory jsonFactory,
String baseUrl,
String applicationName)
Construct the JsonHttpClient. |
| Method Summary | |
|---|---|
static JsonHttpClient.Builder |
builder(HttpTransport transport,
JsonFactory jsonFactory,
GenericUrl baseUrl)
Returns an instance of a new builder. |
protected HttpRequest |
buildHttpRequest(HttpMethod method,
GenericUrl url,
Object body)
Create an HttpRequest suitable for use against this service. |
protected JsonHttpParser |
createParser()
Creates a JSON parser. |
protected JsonHttpContent |
createSerializer(Object body)
Create a JSON serializer for a request object. |
protected InputStream |
executeAsInputStream(HttpMethod method,
GenericUrl url,
Object body)
Builds and executes an HttpRequest and then returns the content input stream of
HttpResponse. |
protected HttpResponse |
executeUnparsed(HttpMethod method,
GenericUrl url,
Object body)
Builds and executes a HttpRequest. |
String |
getApplicationName()
Returns the application name to be sent in the User-Agent header of each request or null for none. |
String |
getBaseUrl()
Returns the base URL of the service, for example "https://www.googleapis.com/tasks/v1/"
. |
JsonFactory |
getJsonFactory()
Returns the JSON Factory. |
JsonHttpParser |
getJsonHttpParser()
Returns the JSON HTTP Parser. |
JsonHttpRequestInitializer |
getJsonHttpRequestInitializer()
Returns the JSON HTTP request initializer or null for none. |
HttpRequestFactory |
getRequestFactory()
Returns the HTTP request factory. |
protected void |
initialize(JsonHttpRequest jsonHttpRequest)
Initializes a JsonHttpRequest using a JsonHttpRequestInitializer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JsonHttpClient(HttpTransport transport,
JsonFactory jsonFactory,
String baseUrl)
Use builder(com.google.api.client.http.HttpTransport, com.google.api.client.json.JsonFactory, com.google.api.client.http.GenericUrl) if you need to specify any of the optional parameters.
transport - The transport to use for requestsjsonFactory - A factory for creating JSON parsers and serializersbaseUrl - The base URL of the service. Must end with a "/"
protected JsonHttpClient(HttpTransport transport,
JsonHttpRequestInitializer jsonHttpRequestInitializer,
HttpRequestInitializer httpRequestInitializer,
JsonFactory jsonFactory,
String baseUrl,
String applicationName)
JsonHttpClient.
transport - The transport to use for requestsjsonHttpRequestInitializer - The initializer to use when creating an
JsonHttpRequest or null for nonehttpRequestInitializer - The initializer to use when creating an HttpRequest or
null for nonejsonFactory - A factory for creating JSON parsers and serializersbaseUrl - The base URL of the service. Must end with a "/"applicationName - The application name to be sent in the User-Agent header of requests or
null for none| Method Detail |
|---|
public final String getBaseUrl()
"https://www.googleapis.com/tasks/v1/"
. Must be URL-encoded and must end with a "/". This is determined when the library is generated
and normally should not be changed.
public final String getApplicationName()
null for none.
public final JsonFactory getJsonFactory()
public final HttpRequestFactory getRequestFactory()
public final JsonHttpRequestInitializer getJsonHttpRequestInitializer()
null for none.
public final JsonHttpParser getJsonHttpParser()
protected JsonHttpParser createParser()
JsonHttpParser
implementations are required.
protected JsonHttpContent createSerializer(Object body)
JsonHttpContent implementations are required.
body - A POJO that can be serialized into JSON
protected void initialize(JsonHttpRequest jsonHttpRequest)
throws IOException
JsonHttpRequest using a JsonHttpRequestInitializer. Subclasses
may override if specific behavior is required.
Must be called before the JSON HTTP request is executed, preferably right after the request is instantiated. Sample usage:
public class Get extends JsonHttpRequest {
...
}
public Get get(String userId) throws IOException {
Get result = new Get(userId);
initialize(result);
return result;
}
jsonHttpRequest - JSON HTTP Request type
IOException
protected HttpRequest buildHttpRequest(HttpMethod method,
GenericUrl url,
Object body)
throws IOException
HttpRequest suitable for use against this service.
Subclasses may override if specific behavior is required, for example if a sequence of requests
need to be built instead of a single request then subclasses should throw an
UnsupportedOperationException. Subclasses which override this method can make use of
HttpRequest.addParser(com.google.api.client.http.HttpParser), HttpRequest.setContent(com.google.api.client.http.HttpContent) and
HttpRequest.setEnableGZipContent(boolean).
method - HTTP Method typeurl - The complete URL of the service where requests should be sentbody - A POJO that can be serialized into JSON or null for none
HttpRequest
IOException
protected HttpResponse executeUnparsed(HttpMethod method,
GenericUrl url,
Object body)
throws IOException
HttpRequest. Subclasses may override if specific behavior is
required, for example if a sequence of requests need to be built instead of a single request.
Callers are responsible for closing the response's content input stream by calling
HttpResponse.ignore().
method - HTTP Method typeurl - The complete URL of the service where requests should be sentbody - A POJO that can be serialized into JSON or null for none
HttpRequest type
IOException - if the request fails
protected InputStream executeAsInputStream(HttpMethod method,
GenericUrl url,
Object body)
throws IOException
HttpRequest and then returns the content input stream of
HttpResponse. Subclasses may override if specific behavior is required.
Callers are responsible for closing the input stream.
method - HTTP Method typeurl - The complete URL of the service where requests should be sentbody - A POJO that can be serialized into JSON or null for none
IOException - if the request fails
public static JsonHttpClient.Builder builder(HttpTransport transport,
JsonFactory jsonFactory,
GenericUrl baseUrl)
transport - The transport to use for requestsjsonFactory - A factory for creating JSON parsers and serializersbaseUrl - The base URL of the service. Must end with a "/"
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||