AbstractHttpMessageConverter<T> class
Abstract base class for most HttpMessageConverter implementations.
- Implemented types
- Implementers
Constructors
Properties
- defaultCharset ↔ dynamic
-
read / write
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
-
supportedMediaTypes
↔ List<
MediaType> -
read / write
Methods
-
addDefaultHeaders(
HttpHeadersWrapper headers, T t, MediaType contentType) → void -
- Add default headers to the output message.
- This implementation delegates to #getDefaultContentType(Object) if a content
- type was not provided, set if necessary the default character set, calls
- #getContentLength, and sets the corresponding headers.
- Add default headers to the output message.
-
canRead(
MediaType mediaType) → bool -
- Returns true if any of the #setSupportedMediaTypes(List)
- supported media types MediaType#includes(MediaType) include the
- given media type.
- @param mediaType the media type to read, can be null if not specified.
- Typically the value of a Content-Type header.
- @return true if the supported media types include the media type,
- or if the media type is null
override - Returns true if any of the #setSupportedMediaTypes(List)
-
canWrite(
MediaType mediaType) → bool -
- Returns true if the given media type includes any of the
- #setSupportedMediaTypes(List) supported media types.
- @param mediaType the media type to write, can be null if not specified.
- Typically the value of an Accept header.
- @return true if the supported media types are compatible with the media type,
- or if the media type is null
override - Returns true if the given media type includes any of the
-
getContentLength(
T t, MediaType contentType) → num -
- Returns the content length for the given type.
- By default, this returns null, meaning that the content length is unknown.
- Can be overridden in subclasses.
- @param t the type to return the content length for
- @return the content length, or null if not known
- Returns the content length for the given type.
-
getDefaultContentType(
T t) → MediaType -
- Returns the default content type for the given type. Called when #write
- is invoked without a specified content type parameter.
- By default, this returns the first element of the
- #setSupportedMediaTypes(List) supportedMediaTypes property, if any.
- Can be overridden in subclasses.
- @param t the type to return the content type for
- @return the content type, or null if not known
- Returns the default content type for the given type. Called when #write
-
getSupportedMediaTypes(
) → List< MediaType> -
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
read(
HttpInputMessage inputMessage) → T -
- This implementation simple delegates to #readInternal(HttpInputMessage).
- Future implementations might add some default behavior, however.
override - This implementation simple delegates to #readInternal(HttpInputMessage).
-
readInternal(
HttpInputMessage inputMessage) → T -
- Abstract template method that reads the actual object. Invoked from {@link #read}.
- @param clazz the type of object to return
- @param inputMessage the HTTP input message to read from
- @return the converted object
- Abstract template method that reads the actual object. Invoked from {@link #read}.
-
setSupportedMediaTypes(
List< MediaType> supportedMediaTypes) → void -
- Set the list of MediaType objects supported by this converter.
-
toString(
) → String -
Returns a string representation of this object.
inherited
-
write(
T t, MediaType contentType, HttpOutputMessage outputMessage) → void -
- This implementation sets the default headers by calling #addDefaultHeaders,
- and then calls #writeInternal.
override - This implementation sets the default headers by calling #addDefaultHeaders,
-
writeInternal(
T t, HttpOutputMessage outputMessage) → void -
- Abstract template method that writes the actual body. Invoked from #write.
- @param t the object to write to the output message
- @param outputMessage the HTTP output message to write to
- Abstract template method that writes the actual body. Invoked from #write.
Operators
-
operator ==(
Object other) → bool -
The equality operator. [...]
inherited