类 AbstractGenericHttpMessageConverter<T>
java.lang.Object
cn.taketoday.http.converter.AbstractHttpMessageConverter<T>
cn.taketoday.http.converter.AbstractGenericHttpMessageConverter<T>
- 类型参数:
T- the converted object type
- 所有已实现的接口:
GenericHttpMessageConverter<T>,HttpMessageConverter<T>
- 直接已知子类:
AbstractJackson2HttpMessageConverter,AbstractJsonHttpMessageConverter,ResourceRegionHttpMessageConverter
public abstract class AbstractGenericHttpMessageConverter<T>
extends AbstractHttpMessageConverter<T>
implements GenericHttpMessageConverter<T>
Abstract base class for most
GenericHttpMessageConverter implementations.- 从以下版本开始:
- 4.0
- 作者:
- Sebastien Deleuze, Juergen Hoeller, Harry Yang
-
字段概要
从类继承的字段 cn.taketoday.http.converter.AbstractHttpMessageConverter
logger -
构造器概要
构造器限定符构造器说明protectedConstruct anAbstractGenericHttpMessageConverterwith no supported media types.protectedAbstractGenericHttpMessageConverter(MediaType supportedMediaType) Construct anAbstractGenericHttpMessageConverterwith one supported media type.protectedAbstractGenericHttpMessageConverter(MediaType... supportedMediaTypes) Construct anAbstractGenericHttpMessageConverterwith multiple supported media type. -
方法概要
修饰符和类型方法说明booleanIndicates whether the given type can be read by this converter.booleanIndicates whether the given class can be written by this converter.protected booleanIndicates whether the given class is supported by this converter.final voidwrite(T t, Type type, MediaType contentType, HttpOutputMessage outputMessage) This implementation sets the default headers by callingAbstractHttpMessageConverter.addDefaultHeaders(cn.taketoday.http.HttpHeaders, T, cn.taketoday.http.MediaType), and then callswriteInternal(T, cn.taketoday.http.HttpOutputMessage).protected voidwriteInternal(T t, HttpOutputMessage outputMessage) Abstract template method that writes the actual body.protected abstract voidwriteInternal(T t, Type type, HttpOutputMessage outputMessage) Abstract template method that writes the actual body.从类继承的方法 cn.taketoday.http.converter.AbstractHttpMessageConverter
addDefaultHeaders, canRead, canRead, canWrite, canWrite, getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, readInternal, setDefaultCharset, setSupportedMediaTypes, write从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.http.converter.GenericHttpMessageConverter
read从接口继承的方法 cn.taketoday.http.converter.HttpMessageConverter
canRead, canWrite, getSupportedMediaTypes, getSupportedMediaTypes, read, write
-
构造器详细资料
-
AbstractGenericHttpMessageConverter
protected AbstractGenericHttpMessageConverter()Construct anAbstractGenericHttpMessageConverterwith no supported media types. -
AbstractGenericHttpMessageConverter
Construct anAbstractGenericHttpMessageConverterwith one supported media type.- 参数:
supportedMediaType- the supported media type
-
AbstractGenericHttpMessageConverter
Construct anAbstractGenericHttpMessageConverterwith multiple supported media type.- 参数:
supportedMediaTypes- the supported media types
-
-
方法详细资料
-
supports
从类复制的说明:AbstractHttpMessageConverterIndicates whether the given class is supported by this converter.- 指定者:
supports在类中AbstractHttpMessageConverter<T>- 参数:
clazz- the class to test for support- 返回:
trueif supported;falseotherwise
-
canRead
从接口复制的说明:GenericHttpMessageConverterIndicates whether the given type can be read by this converter. This method should perform the same checks thanHttpMessageConverter.canRead(Class, MediaType)with additional ones related to the generic type.- 指定者:
canRead在接口中GenericHttpMessageConverter<T>- 参数:
type- the (potentially generic) type to test for readabilitycontextClass- a context class for the target type, for example a class in which the target type appears in a method signature (can benull)mediaType- the media type to read, can benullif not specified. Typically the value of aContent-Typeheader.- 返回:
trueif readable;falseotherwise
-
canWrite
从接口复制的说明:GenericHttpMessageConverterIndicates whether the given class can be written by this converter.This method should perform the same checks than
HttpMessageConverter.canWrite(Class, MediaType)with additional ones related to the generic type.- 指定者:
canWrite在接口中GenericHttpMessageConverter<T>- 参数:
type- the (potentially generic) type to test for writability (can benullif not specified)clazz- the source object class to test for writabilitymediaType- the media type to write (can benullif not specified); typically the value of anAcceptheader.- 返回:
trueif writable;falseotherwise
-
write
public final void write(T t, @Nullable Type type, @Nullable MediaType contentType, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException This implementation sets the default headers by callingAbstractHttpMessageConverter.addDefaultHeaders(cn.taketoday.http.HttpHeaders, T, cn.taketoday.http.MediaType), and then callswriteInternal(T, cn.taketoday.http.HttpOutputMessage).- 指定者:
write在接口中GenericHttpMessageConverter<T>- 参数:
t- the object to write to the output message. The type of this object must have previously been passed to thecanWritemethod of this interface, which must have returnedtrue.type- the (potentially generic) type of object to write. This type must have previously been passed to thecanWritemethod of this interface, which must have returnedtrue. Can benullif not specified.contentType- the content type to use when writing. May benullto indicate that the default content type of the converter must be used. If notnull, this media type must have previously been passed to thecanWritemethod of this interface, which must have returnedtrue.outputMessage- the message to write to- 抛出:
IOException- in case of I/O errorsHttpMessageNotWritableException- in case of conversion errors
-
writeInternal
protected void writeInternal(T t, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException 从类复制的说明:AbstractHttpMessageConverterAbstract template method that writes the actual body. Invoked fromAbstractHttpMessageConverter.write(T, cn.taketoday.http.MediaType, cn.taketoday.http.HttpOutputMessage).- 指定者:
writeInternal在类中AbstractHttpMessageConverter<T>- 参数:
t- the object to write to the output messageoutputMessage- the HTTP output message to write to- 抛出:
IOException- in case of I/O errorsHttpMessageNotWritableException- in case of conversion errors
-
writeInternal
protected abstract void writeInternal(T t, @Nullable Type type, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException Abstract template method that writes the actual body. Invoked fromwrite(T, java.lang.reflect.Type, cn.taketoday.http.MediaType, cn.taketoday.http.HttpOutputMessage).- 参数:
t- the object to write to the output messagetype- the type of object to write (may benull)outputMessage- the HTTP output message to write to- 抛出:
IOException- in case of I/O errorsHttpMessageNotWritableException- in case of conversion errors
-