com.google.api.client.http.json
Class JsonHttpClient.Builder

java.lang.Object
  extended by com.google.api.client.http.json.JsonHttpClient.Builder
Enclosing class:
JsonHttpClient

public static class JsonHttpClient.Builder
extends Object

Builder for JsonHttpClient.

Implementation is not thread-safe.

Since:
1.6

Constructor Summary
protected JsonHttpClient.Builder(HttpTransport transport, JsonFactory jsonFactory, GenericUrl baseUrl)
          Deprecated. (scheduled to be removed in 1.11) Use #Builder(HttpTransport, JsonFactory, String, String, HttpRequestInitializer) instead.
  JsonHttpClient.Builder(HttpTransport transport, JsonFactory jsonFactory, String rootUrl, String servicePath, HttpRequestInitializer httpRequestInitializer)
          Returns an instance of a new builder.
 
Method Summary
 JsonHttpClient build()
          Builds a new instance of JsonHttpClient.
 String getApplicationName()
          Returns the application name to be used in the UserAgent header of each request or null for none.
 GenericUrl getBaseUrl()
          Deprecated. (scheduled to be removed in 1.11) Use getRootUrl() and getServicePath() instead.
 HttpRequestInitializer getHttpRequestInitializer()
          Returns the HTTP request initializer or null for none.
 JsonFactory getJsonFactory()
          Returns the JSON factory.
 JsonHttpRequestInitializer getJsonHttpRequestInitializer()
          Returns the JSON HTTP request initializer or null for none.
 JsonObjectParser getObjectParser()
          Returns the JSON parser used or null if not specified.
 String getRootUrl()
          Returns the root URL of the service, for example https://www.googleapis.com/.
 String getServicePath()
          Returns the service path of the service, for example "tasks/v1/".
 HttpTransport getTransport()
          Returns the HTTP transport.
protected  boolean isBaseUrlUsed()
          Deprecated. (scheduled to be removed in 1.11) Use getRootUrl() and getServicePath() instead.
 JsonHttpClient.Builder setApplicationName(String applicationName)
          Sets the application name to be used in the UserAgent header of each request or null for none.
 JsonHttpClient.Builder setBaseUrl(GenericUrl baseUrl)
          Deprecated. (scheduled to be removed in 1.11) Use setRootUrl(java.lang.String) and setServicePath(java.lang.String) instead.
 JsonHttpClient.Builder setHttpRequestInitializer(HttpRequestInitializer httpRequestInitializer)
          Sets the HTTP request initializer or null for none.
 JsonHttpClient.Builder setJsonHttpRequestInitializer(JsonHttpRequestInitializer jsonHttpRequestInitializer)
          Sets the JSON HTTP request initializer or null for none.
 JsonHttpClient.Builder setObjectParser(JsonObjectParser parser)
          Specifies the JSON parser to use or null if no used.
 JsonHttpClient.Builder setRootUrl(String rootUrl)
          Sets the root URL of the service, for example https://www.googleapis.com/.
 JsonHttpClient.Builder setServicePath(String servicePath)
          Sets the service path of the service, for example "tasks/v1/".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonHttpClient.Builder

@Deprecated
protected JsonHttpClient.Builder(HttpTransport transport,
                                            JsonFactory jsonFactory,
                                            GenericUrl baseUrl)
Deprecated. (scheduled to be removed in 1.11) Use #Builder(HttpTransport, JsonFactory, String, String, HttpRequestInitializer) instead.

Returns an instance of a new builder.

Parameters:
transport - The transport to use for requests
jsonFactory - A factory for creating JSON parsers and serializers
baseUrl - The base URL of the service. Must end with a "/"

JsonHttpClient.Builder

public JsonHttpClient.Builder(HttpTransport transport,
                              JsonFactory jsonFactory,
                              String rootUrl,
                              String servicePath,
                              HttpRequestInitializer httpRequestInitializer)
Returns an instance of a new builder.

Parameters:
transport - The transport to use for requests
jsonFactory - A factory for creating JSON parsers and serializers
rootUrl - The root URL of the service. Must end with a "/"
servicePath - The service path of the service. Must end with a "/" and not begin with a "/". It is allowed to be an empty string "" or a forward slash "/", if it is a forward slash then it is treated as an empty string
httpRequestInitializer - The HTTP request initializer or null for none
Since:
1.10
Method Detail

build

public JsonHttpClient build()
Builds a new instance of JsonHttpClient.


isBaseUrlUsed

@Deprecated
protected final boolean isBaseUrlUsed()
Deprecated. (scheduled to be removed in 1.11) Use getRootUrl() and getServicePath() instead.

Returns if baseUrl is used instead of rootUrl and servicePath.

Since:
1.10

getJsonFactory

public final JsonFactory getJsonFactory()
Returns the JSON factory.


getTransport

public final HttpTransport getTransport()
Returns the HTTP transport.


getObjectParser

public final JsonObjectParser getObjectParser()
Returns the JSON parser used or null if not specified.

Warning: This method will stop returning null in 1.11, and will return JsonFactory.createJsonObjectParser() instead.

Since:
1.10

setObjectParser

public JsonHttpClient.Builder setObjectParser(JsonObjectParser parser)
Specifies the JSON parser to use or null if no used.

Warning: This method will stop accepting null in 1.11. The default will then be JsonFactory.createJsonObjectParser().

Since:
1.10

getBaseUrl

@Deprecated
public final GenericUrl getBaseUrl()
Deprecated. (scheduled to be removed in 1.11) Use getRootUrl() and getServicePath() instead.

Returns the base URL of the service, for example "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.

Use this method only if baseUrl is used instead of rootUrl and servicePath.


setBaseUrl

@Deprecated
public JsonHttpClient.Builder setBaseUrl(GenericUrl baseUrl)
Deprecated. (scheduled to be removed in 1.11) Use setRootUrl(java.lang.String) and setServicePath(java.lang.String) instead.

Sets the base URL of the service, for example "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. Subclasses should override by calling super.

Use this method only if baseUrl is used instead of rootUrl and servicePath.

Since:
1.7

getRootUrl

public final String getRootUrl()
Returns the root URL of the service, for example https://www.googleapis.com/. Must be URL-encoded and must end with a "/".

Use this method only if rootUrl and servicePath are used instead of baseUrl.

Since:
1.10

setRootUrl

public JsonHttpClient.Builder setRootUrl(String rootUrl)
Sets the root URL of the service, for example https://www.googleapis.com/. Must be URL-encoded and must end with a "/". This is determined when the library is generated and normally should be changed. Subclasses should override by calling super.

Use this method only if rootUrl and servicePath are used instead of baseUrl.

Since:
1.10

getServicePath

public final String getServicePath()
Returns the service path of the service, for example "tasks/v1/". Must be URL-encoded and must end with a "/" and not begin with a "/". It is allowed to be an empty string "".

Use this method only if rootUrl and servicePath are used instead of baseUrl.

Since:
1.10

setServicePath

public JsonHttpClient.Builder setServicePath(String servicePath)
Sets the service path of the service, for example "tasks/v1/". Must be URL-encoded and must end with a "/" and not begin with a "/". It is allowed to be an empty string "" or a forward slash "/", if it is a forward slash then it is treated as an empty string. This is determined when the library is generated and normally should not be changed. Subclasses should override by calling super.

Use this method only if rootUrl and servicePath are used instead of baseUrl.

Since:
1.10

setJsonHttpRequestInitializer

public JsonHttpClient.Builder setJsonHttpRequestInitializer(JsonHttpRequestInitializer jsonHttpRequestInitializer)
Sets the JSON HTTP request initializer or null for none. Subclasses should override by calling super.


getJsonHttpRequestInitializer

public JsonHttpRequestInitializer getJsonHttpRequestInitializer()
Returns the JSON HTTP request initializer or null for none.


setHttpRequestInitializer

public JsonHttpClient.Builder setHttpRequestInitializer(HttpRequestInitializer httpRequestInitializer)
Sets the HTTP request initializer or null for none. Subclasses should override by calling super.


getHttpRequestInitializer

public final HttpRequestInitializer getHttpRequestInitializer()
Returns the HTTP request initializer or null for none.


setApplicationName

public JsonHttpClient.Builder setApplicationName(String applicationName)
Sets the application name to be used in the UserAgent header of each request or null for none. Subclasses should override by calling super.


getApplicationName

public final String getApplicationName()
Returns the application name to be used in the UserAgent header of each request or null for none.



Copyright © 2011-2012 Google. All Rights Reserved.