|
Spring for Android | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.http.converter.AbstractHttpMessageConverter<java.lang.Object>
org.springframework.http.converter.ObjectToStringHttpMessageConverter
public class ObjectToStringHttpMessageConverter
An HttpMessageConverter that uses StringHttpMessageConverter
for reading and writing content and a ConversionService for converting
the String content to and from the target object type.
By default, this converter supports the media type text/plain only.
This can be overridden by setting the
supportedMediaTypes property.
| Constructor Summary | |
|---|---|
ObjectToStringHttpMessageConverter(ConversionService conversionService)
A constructor accepting a ConversionService to use to convert the
(String) message body to/from the target class type. |
|
ObjectToStringHttpMessageConverter(ConversionService conversionService,
java.nio.charset.Charset defaultCharset)
A constructor accepting a ConversionService as well as a default
charset. |
|
| Method Summary | |
|---|---|
boolean |
canRead(java.lang.Class<?> clazz,
MediaType mediaType)
This implementation checks if the given class is supported, and if the supported media types include the given media type. |
boolean |
canWrite(java.lang.Class<?> clazz,
MediaType mediaType)
This implementation checks if the given class is supported, and if the supported media types include the given media type. |
protected java.lang.Long |
getContentLength(java.lang.Object obj,
MediaType contentType)
Returns the content length for the given type. |
protected java.lang.Object |
readInternal(java.lang.Class<? extends java.lang.Object> clazz,
HttpInputMessage inputMessage)
Abstract template method that reads the actual object. |
void |
setWriteAcceptCharset(boolean writeAcceptCharset)
Indicates whether the Accept-Charset should be written to any outgoing request. |
protected boolean |
supports(java.lang.Class<?> clazz)
Indicates whether the given class is supported by this converter. |
protected void |
writeInternal(java.lang.Object obj,
HttpOutputMessage outputMessage)
Abstract template method that writes the actual body. |
| Methods inherited from class org.springframework.http.converter.AbstractHttpMessageConverter |
|---|
canRead, canWrite, getDefaultContentType, getSupportedMediaTypes, read, setSupportedMediaTypes, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ObjectToStringHttpMessageConverter(ConversionService conversionService)
ConversionService to use to convert the
(String) message body to/from the target class type. This constructor
uses StringHttpMessageConverter.DEFAULT_CHARSET as the default
charset.
conversionService - the conversion service
public ObjectToStringHttpMessageConverter(ConversionService conversionService,
java.nio.charset.Charset defaultCharset)
ConversionService as well as a default
charset.
conversionService - the conversion servicedefaultCharset - the default charset| Method Detail |
|---|
public void setWriteAcceptCharset(boolean writeAcceptCharset)
Accept-Charset should be written to any outgoing request.
Default is true.
public boolean canRead(java.lang.Class<?> clazz,
MediaType mediaType)
AbstractHttpMessageConverter
canRead in interface HttpMessageConverter<java.lang.Object>canRead in class AbstractHttpMessageConverter<java.lang.Object>clazz - the class to test for readabilitymediaType - the media type to read, can be null if not specified.
Typically the value of a Content-Type header.
true if readable; false otherwise
public boolean canWrite(java.lang.Class<?> clazz,
MediaType mediaType)
AbstractHttpMessageConverter
canWrite in interface HttpMessageConverter<java.lang.Object>canWrite in class AbstractHttpMessageConverter<java.lang.Object>clazz - the class to test for writabilitymediaType - the media type to write, can be null if not specified.
Typically the value of an Accept header.
true if writable; false otherwiseprotected boolean supports(java.lang.Class<?> clazz)
AbstractHttpMessageConverter
supports in class AbstractHttpMessageConverter<java.lang.Object>clazz - the class to test for support
true if supported; false otherwise
protected java.lang.Object readInternal(java.lang.Class<? extends java.lang.Object> clazz,
HttpInputMessage inputMessage)
throws java.io.IOException
AbstractHttpMessageConverterAbstractHttpMessageConverter.read(java.lang.Class extends T>, org.springframework.http.HttpInputMessage).
readInternal in class AbstractHttpMessageConverter<java.lang.Object>clazz - the type of object to returninputMessage - the HTTP input message to read from
java.io.IOException - in case of I/O errors
protected void writeInternal(java.lang.Object obj,
HttpOutputMessage outputMessage)
throws java.io.IOException
AbstractHttpMessageConverterAbstractHttpMessageConverter.write(T, org.springframework.http.MediaType, org.springframework.http.HttpOutputMessage).
writeInternal in class AbstractHttpMessageConverter<java.lang.Object>obj - the object to write to the output messageoutputMessage - the HTTP output message to write to
java.io.IOException - in case of I/O errors
protected java.lang.Long getContentLength(java.lang.Object obj,
MediaType contentType)
AbstractHttpMessageConverterBy default, this returns null, meaning that the content length is unknown.
Can be overridden in subclasses.
getContentLength in class AbstractHttpMessageConverter<java.lang.Object>obj - the type to return the content length for
null if not known
|
Spring for Android | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||