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

public Class ResourceEncoder

extends AbstractSingleValueEncoder<Resource>
Class Inheritance
Imports
java.util.Map, reactor.core.publisher.Flux, org.springframework.core.ResolvableType, org.springframework.core.io.Resource, org.springframework.core.io.buffer.DataBuffer, .DataBufferFactory, .DataBufferUtils, org.springframework.lang.Nullable, org.springframework.util.Assert, .MimeType, .MimeTypeUtils, .StreamUtils

Encoder for Resources.
Author
Arjen Poutsma
Since
5.0

Field Summary

Modifier and TypeField and Description
private final int
public static final int
DEFAULT_BUFFER_SIZE

The default buffer size used by the encoder.

Constructor Summary

AccessConstructor and Description
public
public
ResourceEncoder(int bufferSize)

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
)

Overrides org.springframework.core.codec.AbstractEncoder.canEncode.

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

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

protected Flux<DataBuffer>
encode(Resource
the value to process
resource
,
DataBufferFactory
a buffer factory used to create the output
bufferFactory
,
ResolvableType
the stream element type to process
type
,
MimeType
the mime type to process
mimeType
,
Map<String, Object>
additional information about how to do decode, optional
hints
)

Implements abstract org.springframework.core.codec.AbstractSingleValueEncoder.encode.

Encode T to an output DataBuffer stream.

Inherited from org.springframework.core.codec.AbstractSingleValueEncoder:
encode

Field Detail

bufferSizeback to summary
private final int bufferSize
DEFAULT_BUFFER_SIZEback to summary
public static final int DEFAULT_BUFFER_SIZE

The default buffer size used by the encoder.

Constructor Detail

ResourceEncoderback to summary
public ResourceEncoder()
ResourceEncoderback to summary
public ResourceEncoder(int bufferSize)

Method Detail

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

Overrides org.springframework.core.codec.AbstractEncoder.canEncode.

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
encodeback to summary
protected Flux<DataBuffer> encode(Resource resource, DataBufferFactory bufferFactory, ResolvableType type, MimeType mimeType, Map<String, Object> hints)

Implements abstract org.springframework.core.codec.AbstractSingleValueEncoder.encode.

Doc from org.springframework.core.codec.AbstractSingleValueEncoder.encode.

Encode T to an output DataBuffer stream.

Parameters
resource:Resource

the value to process

bufferFactory:DataBufferFactory

a buffer factory used to create the output

type:ResolvableType

the stream element type to process

mimeType:MimeType

the mime type to process

hints:Map<String, Object>

additional information about how to do decode, optional

Returns:Flux<DataBuffer>

the output stream

Annotations
@Override