|
||||||||||
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,
String uriTemplate,
JsonHttpRequest jsonHttpRequest)
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 HttpResponse |
execute(HttpMethod method,
String uriTemplate,
Object body,
JsonHttpRequest jsonHttpRequest)
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 noneMethod Detail |
---|
public 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.
Overriding this method is not supported, except for the Google generated libraries for backwards-compatibility reasons. This method will be made final in the 1.7 release.
public String getApplicationName()
null
for none.
Overriding this method is not supported, except for the Google generated libraries for backwards-compatibility reasons. This method will be made final in the 1.7 release.
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 JSONprotected 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, String uriTemplate, JsonHttpRequest jsonHttpRequest) throws IOException
HttpRequest
suitable for use against this service. Subclasses may override if
specific behavior is required.
method
- HTTP Method typeuriTemplate
- URI template for the path relative to the base URL. Must not start with a
"/"jsonHttpRequest
- JSON HTTP Request type
HttpRequest
IOException
protected HttpResponse execute(HttpMethod method, String uriTemplate, Object body, JsonHttpRequest jsonHttpRequest) throws IOException
HttpRequest
. Subclasses may override if specific behavior is
required.
method
- HTTP Method typeuriTemplate
- URI template for the path relative to the base URL. Must not start with a
"/"body
- A POJO that can be serialized into JSON or null
for nonejsonHttpRequest
- JSON HTTP Request type
HttpRequest
type
IOException
- if the request failspublic 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 |