Class AbstractResourceReader
java.lang.Object
org.springframework.geode.core.io.AbstractResourceReader
- All Implemented Interfaces:
ResourceReader
- Direct Known Subclasses:
ByteArrayResourceReader
Abstract base class providing functionality common to all
ResourceReader
implementations.- Since:
- 1.3.1
- See Also:
-
InputStream
Resource
ResourceReader
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract byte[]
doRead
(InputStream resourceInputStream) Reads data from the targetResource
(intentionally) by using theInputStream
returned byInputStreamSource.getInputStream()
.protected boolean
isAbleToHandle
(org.springframework.core.io.Resource resource) Determines whether this reader is able to handle and read from the targetResource
.protected org.springframework.core.io.Resource
preProcess
(org.springframework.core.io.Resource resource) Pre-processes the targetResource
before reading from theResource
.byte[]
read
(org.springframework.core.io.Resource resource) Reads data from the non-nullResource
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-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.- Specified by:
read
in interfaceResourceReader
- 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 targetResource
. The default implementation determines that theResource
can be handled if theResource
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 targetResource
(intentionally) by using theInputStream
returned byInputStreamSource.getInputStream()
. However, other algorithm/strategy implementations are free to read from theResource
as is appropriate for the given context (e.g. cloud environment). In those cases, implementors should override theread(Resource)
method.- Parameters:
resourceInputStream
-InputStream
used to read data from the targetResource
.- Returns:
- a non-null byte array containing the data from the target
Resource
. - Throws:
IOException
- if an I/O error occurs while reading from theResource
.- See Also:
-
preProcess
@NonNull protected org.springframework.core.io.Resource preProcess(@NonNull org.springframework.core.io.Resource resource) Pre-processes the targetResource
before reading from theResource
.- Parameters:
resource
-Resource
to pre-process; never null.- Returns:
- the given, target
Resource
. - See Also:
-
Resource
-