Top Description Fields Constructors Methods
org.springframework.web.client

public Class HttpMessageConverterExtractor<T>

extends Object
implements ResponseExtractor<T>
Class Inheritance
All Implemented Interfaces
org.springframework.web.client.ResponseExtractor
Type Parameters
<T>
the data type
Imports
java.io.IOException, java.lang.reflect.Type, java.util.List, org.apache.commons.logging.Log, .LogFactory, org.springframework.core.ResolvableType, org.springframework.http.MediaType, org.springframework.http.client.ClientHttpResponse, org.springframework.http.converter.GenericHttpMessageConverter, .HttpMessageConverter, .HttpMessageNotReadableException, org.springframework.lang.Nullable, org.springframework.util.Assert, .FileCopyUtils

Response extractor that uses the given entity converters to convert the response into a type T.
Authors
Arjen Poutsma, Sam Brannen
Since
3.0
See Also
RestTemplate

Field Summary

Modifier and TypeField and Description
private final Log
private final List<HttpMessageConverter<?>>
private final Class<T>
private final Type

Constructor Summary

AccessConstructor and Description
public
HttpMessageConverterExtractor(Class<T> responseType, List<HttpMessageConverter<?>> messageConverters)

Create a new instance of the HttpMessageConverterExtractor with the given response type and message converters.

public
HttpMessageConverterExtractor(Type responseType, List<HttpMessageConverter<?>> messageConverters)

Creates a new instance of the HttpMessageConverterExtractor with the given response type and message converters.

pack-priv
HttpMessageConverterExtractor(Type responseType, List<HttpMessageConverter<?>> messageConverters, Log logger)

Method Summary

Modifier and TypeMethod and Description
public T
extractData(ClientHttpResponse
the HTTP response
response
)

Implements org.springframework.web.client.ResponseExtractor.extractData.

Extract data from the given ClientHttpResponse and return it.

protected MediaType

Returns:

the MediaType, or "application/octet-stream"
getContentType
(ClientHttpResponse
the response
response
)

Determine the Content-Type of the response based on the "Content-Type" header or otherwise default to MediaType#APPLICATION_OCTET_STREAM.

private static byte[]
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loggerback to summary
private final Log logger
messageConvertersback to summary
private final List<HttpMessageConverter<?>> messageConverters
responseClassback to summary
private final Class<T> responseClass
Annotations
@Nullable
responseTypeback to summary
private final Type responseType

Constructor Detail

HttpMessageConverterExtractorback to summary
public HttpMessageConverterExtractor(Class<T> responseType, List<HttpMessageConverter<?>> messageConverters)

Create a new instance of the HttpMessageConverterExtractor with the given response type and message converters. The given converters must support the response type.

HttpMessageConverterExtractorback to summary
public HttpMessageConverterExtractor(Type responseType, 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.

HttpMessageConverterExtractorback to summary
pack-priv HttpMessageConverterExtractor(Type responseType, List<HttpMessageConverter<?>> messageConverters, Log logger)
Annotations
@SuppressWarnings:rawtypes, unchecked

Method Detail

extractDataback to summary
public T extractData(ClientHttpResponse response) throws IOException

Implements org.springframework.web.client.ResponseExtractor.extractData.

Doc from org.springframework.web.client.ResponseExtractor.extractData.

Extract data from the given ClientHttpResponse and return it.

Parameters
response:ClientHttpResponse

the HTTP response

Returns:T

the extracted data

Annotations
@Override
@SuppressWarnings:rawtypes, unchecked, resource
Exceptions
IOException:
in case of I/O errors
getContentTypeback to summary
protected MediaType getContentType(ClientHttpResponse response)

Determine the Content-Type of the response based on the "Content-Type" header or otherwise default to MediaType#APPLICATION_OCTET_STREAM.

Parameters
response:ClientHttpResponse

the response

Returns:MediaType

the MediaType, or "application/octet-stream"

getResponseBodyback to summary
private static byte[] getResponseBody(ClientHttpResponse response)