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:
-
ByteBufferResource
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]read(org.springframework.core.io.Resource resource) Reads data from the non-nullResourceinto a byte array.default ByteBufferreadIntoByteBuffer(org.springframework.core.io.Resource resource) Reads data from the non-nullResourceinto aByteBuffer.default ResourceReaderthenReadFrom(ResourceReader reader) Composes thisResourceReaderwith the givenResourceReaderusing the Composite Software Design Pattern.
-
Method Details
-
read
@NonNull byte[] read(@NonNull org.springframework.core.io.Resource resource) Reads data from the non-nullResourceinto a byte array. This method should throw anUnhandledResourceExceptionif the algorithm and strategy used by this reader is not able to or capable of reading from theResourceat its location. This allows subsequent readers in a composition to possibly handle theResource. Any otherThrowablethrown by thisreadmethod will break the chain of read calls in the composition.- Parameters:
resource-Resourceto 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-nullResourceinto aByteBuffer.- Parameters:
resource-Resourceto read data from.- Returns:
- a non-null
ByteBuffercontaining the data from theResource. - See Also:
-
ResourceByteBufferread(Resource)
-
thenReadFrom
Composes thisResourceReaderwith the givenResourceReaderusing the Composite Software Design Pattern.- Parameters:
reader-ResourceReaderto compose with this reader.- Returns:
- a composite
ResourceReadercomposed of thisResourceReaderand the givenResourceReader. If the givenResourceReaderis null, then thisResourceReaderis returned. - See Also:
-