Class AbstractResourceReader

java.lang.Object
org.springframework.geode.core.io.AbstractResourceReader
All Implemented Interfaces:
ResourceReader
Direct Known Subclasses:
ByteArrayResourceReader

public abstract class AbstractResourceReader extends Object implements ResourceReader
Abstract base class providing functionality common to all ResourceReader implementations.
Since:
1.3.1
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract byte[]
    doRead(InputStream resourceInputStream)
    Reads data from the target Resource (intentionally) by using the InputStream returned by InputStreamSource.getInputStream().
    protected boolean
    isAbleToHandle(org.springframework.core.io.Resource resource)
    Determines whether this reader is able to handle and read from the target Resource.
    protected org.springframework.core.io.Resource
    preProcess(org.springframework.core.io.Resource resource)
    Pre-processes the target Resource before reading from the Resource.
    byte[]
    read(org.springframework.core.io.Resource resource)
    Reads data from the non-null Resource into a byte array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.geode.core.io.ResourceReader

    readIntoByteBuffer, thenReadFrom
  • Constructor Details

    • AbstractResourceReader

      public AbstractResourceReader()
  • Method Details

    • read

      @NonNull public 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.
      Specified by:
      read in interface ResourceReader
      Parameters:
      resource - Resource to read data from.
      Returns:
      a non-null byte array containing the data from the Resource.
      See Also:
      • Resource
    • isAbleToHandle

      protected boolean isAbleToHandle(@Nullable org.springframework.core.io.Resource resource)
      Determines whether this reader is able to handle and read from the target Resource. The default implementation determines that the Resource can be handled if the Resource handle is not null.
      Parameters:
      resource - Resource to evaluate.
      Returns:
      a boolean value indicating whether this reader is able to handle and read from the target Resource.
      See Also:
      • Resource
    • doRead

      @NonNull protected abstract byte[] doRead(@NonNull InputStream resourceInputStream) throws IOException
      Reads data from the target Resource (intentionally) by using the InputStream returned by InputStreamSource.getInputStream(). However, other algorithm/strategy implementations are free to read from the Resource as is appropriate for the given context (e.g. cloud environment). In those cases, implementors should override the read(Resource) method.
      Parameters:
      resourceInputStream - InputStream used to read data from the target Resource.
      Returns:
      a non-null byte array containing the data from the target Resource.
      Throws:
      IOException - if an I/O error occurs while reading from the Resource.
      See Also:
    • preProcess

      @NonNull protected org.springframework.core.io.Resource preProcess(@NonNull org.springframework.core.io.Resource resource)
      Pre-processes the target Resource before reading from the Resource.
      Parameters:
      resource - Resource to pre-process; never null.
      Returns:
      the given, target Resource.
      See Also:
      • Resource