Top Description Fields Constructors Methods
org.springframework.core.codec

public abstract Class AbstractEncoder<T>

extends Object
implements Encoder<T>
Class Inheritance
All Implemented Interfaces
org.springframework.core.codec.Encoder
Known Direct Subclasses
org.springframework.core.codec.AbstractSingleValueEncoder, org.springframework.core.codec.ByteArrayEncoder, org.springframework.core.codec.ByteBufferEncoder, org.springframework.core.codec.CharSequenceEncoder, org.springframework.core.codec.DataBufferEncoder, org.springframework.core.codec.Netty5BufferEncoder, org.springframework.core.codec.NettyByteBufEncoder, org.springframework.core.codec.ResourceRegionEncoder
Type Parameters
<T>
the element type
Imports
java.util.Arrays, .List, org.apache.commons.logging.Log, .LogFactory, org.springframework.core.ResolvableType, org.springframework.lang.Nullable, org.springframework.util.MimeType

Abstract base class for Encoder implementations.
Authors
Sebastien Deleuze, Arjen Poutsma
Since
5.0

Field Summary

Modifier and TypeField and Description
private final List<MimeType>
protected Log

Constructor Summary

AccessConstructor and Description
protected
AbstractEncoder(MimeType... supportedMimeTypes)

Method Summary

Modifier and TypeMethod and Description
public boolean
canEncode(ResolvableType
the type of elements in the source stream
elementType
,
MimeType
the MIME type for the output stream (can be null if not specified)
mimeType
)

Implements org.springframework.core.codec.Encoder.canEncode.

Whether the encoder supports the given source element type and the MIME type for the output stream.

public List<MimeType>
getEncodableMimeTypes()

Implements org.springframework.core.codec.Encoder.getEncodableMimeTypes.

Return the list of MIME types supported by this Encoder.

public Log
getLogger()

Return the currently configured Logger.

public void
setLogger(Log
the logger to use
logger
)

Set an alternative logger to use than the one based on the class name.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

encodableMimeTypesback to summary
private final List<MimeType> encodableMimeTypes
loggerback to summary
protected Log logger

Constructor Detail

AbstractEncoderback to summary
protected AbstractEncoder(MimeType... supportedMimeTypes)

Method Detail

canEncodeback to summary
public boolean canEncode(ResolvableType elementType, MimeType mimeType)

Implements org.springframework.core.codec.Encoder.canEncode.

Doc from org.springframework.core.codec.Encoder.canEncode.

Whether the encoder supports the given source element type and the MIME type for the output stream.

Parameters
elementType:ResolvableType

the type of elements in the source stream

mimeType:MimeType

the MIME type for the output stream (can be null if not specified)

Returns:boolean

true if supported, false otherwise

Annotations
@Override
getEncodableMimeTypesback to summary
public List<MimeType> getEncodableMimeTypes()

Implements org.springframework.core.codec.Encoder.getEncodableMimeTypes.

Doc from org.springframework.core.codec.Encoder.getEncodableMimeTypes.

Return the list of MIME types supported by this Encoder. The list may not apply to every possible target element type and calls to this method should typically be guarded via canEncode(elementType, null). The list may also exclude MIME types supported only for a specific element type. Alternatively, use getEncodableMimeTypes(ResolvableType) for a more precise list.

Returns:List<MimeType>

the list of supported MIME types

Annotations
@Override
getLoggerback to summary
public Log getLogger()

Return the currently configured Logger.

Since
5.1
setLoggerback to summary
public void setLogger(Log logger)

Set an alternative logger to use than the one based on the class name.

Parameters
logger:Log

the logger to use

Since
5.1