com.google.api.client.http
Class UrlEncodedContent

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

public final class UrlEncodedContent
extends Object
implements HttpContent

Implements support for HTTP form content encoding serialization of type application/x-www-form-urlencoded as specified in the HTML 4.0 Specification.

Sample usage:

 
 static void setContent(HttpRequest request, Object item) {
   UrlEncodedContent content = new UrlEncodedContent();
   content.setData(item);
   request.content = content;
 }
 
 

Since:
1.0
Author:
Yaniv Inbar

Field Summary
 String contentType
          Content type.
 Object data
          Key/value data or null for none.
 
Constructor Summary
UrlEncodedContent()
           
 
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.
 void setData(Object data)
          Deprecated. (scheduled to be removed in version 1.1) Use data
 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 UrlEncodedParser.CONTENT_TYPE.


data

public Object data
Key/value data or null for none.

Constructor Detail

UrlEncodedContent

public UrlEncodedContent()
Method Detail

setData

@Deprecated
public void setData(Object data)
Deprecated. (scheduled to be removed in version 1.1) Use data

Sets the content input from the given key/value data.

Parameters:
data - key/value data (may be null)

getEncoding

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

Specified by:
getEncoding in interface HttpContent

getLength

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

Specified by:
getLength in interface HttpContent
Throws:
UnsupportedEncodingException

getType

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

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


Copyright © 2010 Google. All Rights Reserved.