public abstract class AbstractResourceReader extends java.lang.Object implements ResourceReader
ResourceReader implementations.InputStream,
Resource,
ResourceReader| Constructor and Description |
|---|
AbstractResourceReader() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract byte[] |
doRead(java.io.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. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitreadIntoByteBuffer, thenReadFrom@NonNull
public byte[] read(@NonNull
org.springframework.core.io.Resource resource)
ResourceReaderResource 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.read in interface ResourceReaderresource - Resource to read data from.Resource.Resourceprotected boolean isAbleToHandle(@Nullable
org.springframework.core.io.Resource resource)
Resource.
The default implementation determines that the Resource can be handled if the Resource handle
is not null.resource - Resource to evaluate.Resource.Resource@NonNull
protected abstract byte[] doRead(@NonNull
java.io.InputStream resourceInputStream)
throws java.io.IOException
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.resourceInputStream - InputStream used to read data from the target Resource.Resource.java.io.IOException - if an I/O error occurs while reading from the Resource.InputStream,
read(Resource)@NonNull
protected org.springframework.core.io.Resource preProcess(@NonNull
org.springframework.core.io.Resource resource)
Resource before reading from the Resource.resource - Resource to pre-process; never null.Resource.Resource