org.springframework.web.client
Class HttpMessageConverterExtractor<T>
java.lang.Object
org.springframework.web.client.HttpMessageConverterExtractor<T>
- All Implemented Interfaces:
- ResponseExtractor<T>
public class HttpMessageConverterExtractor<T>
- extends java.lang.Object
- implements ResponseExtractor<T>
Response extractor that uses the given entity converters to convert the response
into a type T
.
- Since:
- 3.0
- Author:
- Arjen Poutsma
- See Also:
RestTemplate
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
responseType
private final java.lang.Class<T> responseType
messageConverters
private final java.util.List<HttpMessageConverter<?>> messageConverters
logger
private final Log logger
HttpMessageConverterExtractor
public HttpMessageConverterExtractor(java.lang.Class<T> responseType,
java.util.List<HttpMessageConverter<?>> messageConverters)
- Creates a new instance of the
HttpMessageConverterExtractor
with the given response type and message
converters. The given converters must support the response type.
HttpMessageConverterExtractor
HttpMessageConverterExtractor(java.lang.Class<T> responseType,
java.util.List<HttpMessageConverter<?>> messageConverters,
Log logger)
extractData
public T extractData(ClientHttpResponse response)
throws java.io.IOException
- Description copied from interface:
ResponseExtractor
- Extract data from the given
ClientHttpResponse
and return it.
- Specified by:
extractData
in interface ResponseExtractor<T>
- Parameters:
response
- the HTTP response
- Returns:
- the extracted data
- Throws:
java.io.IOException
- in case of I/O errors
hasMessageBody
protected boolean hasMessageBody(ClientHttpResponse response)
throws java.io.IOException
- Indicates whether the given response has a message body.
Default implementation returns false
for a response status of 204
or 304
, or a
Content-Length
of 0
.
- Parameters:
response
- the response to check for a message body
- Returns:
true
if the response has a body, false
otherwise
- Throws:
java.io.IOException
- in case of I/O errors