|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.api.client.http.AbstractHttpContent
com.google.api.client.http.UrlEncodedContent
public class UrlEncodedContent
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) {
request.setContent(new UrlEncodedContent(item));
}
Implementation is not thread-safe.
Constructor Summary | |
---|---|
UrlEncodedContent(Object data)
Upgrade warning: prior to version 1.7, the data parameter could be null but now
null is not allowed and instead a new instance of an implementation of Map will
be created. |
Method Summary | |
---|---|
static UrlEncodedContent |
getContent(HttpRequest request)
Returns the URL-encoded content of the given HTTP request, or if none return and set as content a new instance of UrlEncodedContent (whose getData() is an implementation of
Map ). |
Object |
getData()
Returns the key name/value data or null for none. |
UrlEncodedContent |
setData(Object data)
Sets the key name/value data. |
UrlEncodedContent |
setMediaType(HttpMediaType mediaType)
Sets the media type to use for the Content-Type header, or null if unspecified. |
UrlEncodedContent |
setType(String type)
Deprecated. (scheduled to be removed in 1.11) Use setMediaType(HttpMediaType) instead. |
void |
writeTo(OutputStream out)
Writes the content to the given output stream. |
Methods inherited from class com.google.api.client.http.AbstractHttpContent |
---|
computeLength, getCharset, getEncoding, getLength, getMediaType, getType, retrySupported |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UrlEncodedContent(Object data)
Upgrade warning: prior to version 1.7, the data
parameter could be null
but now
null
is not allowed and instead a new instance of an implementation of Map
will
be created. In version 1.8 a NullPointerException
will be thrown instead.
data
- key name/value dataMethod Detail |
---|
public void writeTo(OutputStream out) throws IOException
HttpContent
The recommendation for implementations is that they should not close the output stream. Callers should not assume whether or not the output stream has been closed. Implementations that do not close the output stream should flush it at the end of the method.
IOException
@Deprecated public UrlEncodedContent setType(String type)
setMediaType(HttpMediaType)
instead.
null
for none. Will override any pre-set media type parameter.
Default value is UrlEncodedParser.CONTENT_TYPE
.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
public UrlEncodedContent setMediaType(HttpMediaType mediaType)
AbstractHttpContent
null
if unspecified.
This will also overwrite any previously set parameter of the media type (for example
"charset"
), and therefore might change other properties as well.
setMediaType
in class AbstractHttpContent
public Object getData()
null
for none.
Upgrade warning: prior to version 1.7 this could return null
but now it always returns
a non-null
value. Also overriding this method is no longer supported, and will be made
final in 1.8.
public UrlEncodedContent setData(Object data)
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Upgrade warning: prior to version 1.7, the data
parameter could be null
but now
null
is not allowed and instead a new instance of an implementation of Map
will
be created. In version 1.8 a NullPointerException
will be thrown instead.
public static UrlEncodedContent getContent(HttpRequest request)
UrlEncodedContent
(whose getData()
is an implementation of
Map
).
request
- HTTP request
ClassCastException
- if the HTTP request has a content defined that is not
UrlEncodedContent
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |