Interface ResourceReader
- All Known Implementing Classes:
AbstractResourceReader
,ByteArrayResourceReader
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Interface (contract) for readers to define the algorithm and strategy for reading data from a
Resource
,
such as by using the Resource's
InputStream
.- Since:
- 1.3.1
- See Also:
-
ByteBuffer
Resource
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
read
(org.springframework.core.io.Resource resource) Reads data from the non-nullResource
into a byte array.default ByteBuffer
readIntoByteBuffer
(org.springframework.core.io.Resource resource) Reads data from the non-nullResource
into aByteBuffer
.default ResourceReader
thenReadFrom
(ResourceReader reader) Composes thisResourceReader
with the givenResourceReader
using the Composite Software Design Pattern.
-
Method Details
-
read
@NonNull byte[] read(@NonNull org.springframework.core.io.Resource resource) Reads data from the non-nullResource
into a byte array. This method should throw anUnhandledResourceException
if the algorithm and strategy used by this reader is not able to or capable of reading from theResource
at its location. This allows subsequent readers in a composition to possibly handle theResource
. Any otherThrowable
thrown by thisread
method will break the chain of read calls in the composition.- Parameters:
resource
-Resource
to read data from.- Returns:
- a non-null byte array containing the data from the
Resource
. - See Also:
-
Resource
-
readIntoByteBuffer
@NonNull default ByteBuffer readIntoByteBuffer(@NonNull org.springframework.core.io.Resource resource) Reads data from the non-nullResource
into aByteBuffer
.- Parameters:
resource
-Resource
to read data from.- Returns:
- a non-null
ByteBuffer
containing the data from theResource
. - See Also:
-
Resource
ByteBuffer
read(Resource)
-
thenReadFrom
Composes thisResourceReader
with the givenResourceReader
using the Composite Software Design Pattern.- Parameters:
reader
-ResourceReader
to compose with this reader.- Returns:
- a composite
ResourceReader
composed of thisResourceReader
and the givenResourceReader
. If the givenResourceReader
is null, then thisResourceReader
is returned. - See Also:
-