com.google.api.client.http.json
Class JsonHttpContent

java.lang.Object
  extended by com.google.api.client.http.json.JsonHttpContent
All Implemented Interfaces:
HttpContent

public class JsonHttpContent
extends Object
implements HttpContent

Serializes JSON HTTP content based on the data key/value mapping object for an item.

Sample usage:

 
  static void setContent(HttpRequest request, Object data) {
    JsonHttpContent content = new JsonHttpContent();
    content.jsonFactory = new JacksonFactory();
    content.data = data;
    request.content = content;
  }
 
 

Since:
1.0
Author:
Yaniv Inbar

Field Summary
 String contentType
          Content type.
 Object data
          Key/value pair data.
 JsonFactory jsonFactory
          (Required) JSON factory to use.
 
Constructor Summary
JsonHttpContent()
           
 
Method Summary
 String getEncoding()
          Returns the content encoding (for example "gzip") or null for none.
 long getLength()
          Returns the content length or less than zero if not known.
 String getType()
          Returns the content type or null for none.
 boolean retrySupported()
          Returns whether or not retry is supported on this content type.
 void writeTo(OutputStream out)
          Writes the content to the given output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

contentType

public String contentType
Content type. Default value is Json.CONTENT_TYPE.


data

public Object data
Key/value pair data.


jsonFactory

public JsonFactory jsonFactory
(Required) JSON factory to use.

Since:
1.3
Constructor Detail

JsonHttpContent

public JsonHttpContent()
Method Detail

getLength

public long getLength()
Description copied from interface: HttpContent
Returns the content length or less than zero if not known.

Specified by:
getLength in interface HttpContent

getEncoding

public final String getEncoding()
Description copied from interface: HttpContent
Returns the content encoding (for example "gzip") or null for none.

Specified by:
getEncoding in interface HttpContent

getType

public String getType()
Description copied from interface: HttpContent
Returns the content type or null for none.

Specified by:
getType in interface HttpContent

writeTo

public void writeTo(OutputStream out)
             throws IOException
Description copied from interface: HttpContent
Writes the content to the given output stream.

Specified by:
writeTo in interface HttpContent
Throws:
IOException

retrySupported

public boolean retrySupported()
Description copied from interface: HttpContent
Returns whether or not retry is supported on this content type. This is a backward incompatible change that affects versions prior to 1.4.

Specified by:
retrySupported in interface HttpContent


Copyright © 2010-2011 Google. All Rights Reserved.