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.

@FunctionalInterface public interface ResourceReader
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:
  • Method Details

    • read

      @NonNull byte[] read(@NonNull org.springframework.core.io.Resource resource)
      Reads data from the non-null Resource into a byte array. This method should throw an UnhandledResourceException if the algorithm and strategy used by this reader is not able to or capable of reading from the Resource at its location. This allows subsequent readers in a composition to possibly handle the Resource. Any other Throwable thrown by this read 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-null Resource into a ByteBuffer.
      Parameters:
      resource - Resource to read data from.
      Returns:
      a non-null ByteBuffer containing the data from the Resource.
      See Also:
    • thenReadFrom

      @NonNull default ResourceReader thenReadFrom(@Nullable ResourceReader reader)
      Composes this ResourceReader with the given ResourceReader using the Composite Software Design Pattern.
      Parameters:
      reader - ResourceReader to compose with this reader.
      Returns:
      a composite ResourceReader composed of this ResourceReader and the given ResourceReader. If the given ResourceReader is null, then this ResourceReader is returned.
      See Also: