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:
-
InputStreamResourceResourceReader
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract byte[]doRead(InputStream resourceInputStream) Reads data from the targetResource(intentionally) by using theInputStreamreturned byInputStreamSource.getInputStream().protected booleanisAbleToHandle(org.springframework.core.io.Resource resource) Determines whether this reader is able to handle and read from the targetResource.protected org.springframework.core.io.ResourcepreProcess(org.springframework.core.io.Resource resource) Pre-processes the targetResourcebefore reading from theResource.byte[]read(org.springframework.core.io.Resource resource) Reads data from the non-nullResourceinto a byte array.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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) Description copied from interface:ResourceReaderReads 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.- Specified by:
readin interfaceResourceReader- Parameters:
resource-Resourceto 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 theResourcecan be handled if theResourcehandle is not null.- Parameters:
resource-Resourceto 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 theInputStreamreturned byInputStreamSource.getInputStream(). However, other algorithm/strategy implementations are free to read from theResourceas is appropriate for the given context (e.g. cloud environment). In those cases, implementors should override theread(Resource)method.- Parameters:
resourceInputStream-InputStreamused 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 targetResourcebefore reading from theResource.- Parameters:
resource-Resourceto pre-process; never null.- Returns:
- the given, target
Resource. - See Also:
-
Resource
-