public abstract class AbstractResourceWriter extends java.lang.Object implements ResourceWriter
ResourceWriter implementations.OutputStream,
Resource,
WritableResource,
ResourceWriter| Constructor and Description |
|---|
AbstractResourceWriter() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
doWrite(java.io.OutputStream resourceOutputStream,
byte[] data)
Writes the given data to the target
Resource (intentionally) by using the OutputStream
returned by WritableResource.getOutputStream(). |
protected boolean |
isAbleToHandle(org.springframework.core.io.Resource resource)
Determines whether this writer is able to handle and write to the target
Resource. |
protected org.springframework.core.io.WritableResource |
preProcess(org.springframework.core.io.WritableResource resource)
Pre-processes the target
WritableResource before writing to the WritableResource. |
void |
write(org.springframework.core.io.Resource resource,
byte[] data)
Writes data to the target
Resource as defined by the algorithm/strategy of this writer. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitthenWriteTo, writepublic void write(@NonNull
org.springframework.core.io.Resource resource,
byte[] data)
ResourceWriterResource as defined by the algorithm/strategy of this writer.
This method should throw an UnhandledResourceException if the algorithm or strategy used by this writer
is not able to or capable of writing to the Resource at its location. This allows subsequent writers
in a composition to possibly handle the Resource. Any other Exception thrown by this
write method will break the chain of write calls in the composition.write in interface ResourceWriterresource - Resource to write data to.data - array of bytes containing the data to write to the target 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.Resourceprotected abstract void doWrite(java.io.OutputStream resourceOutputStream,
byte[] data)
throws java.io.IOException
Resource (intentionally) by using the OutputStream
returned by WritableResource.getOutputStream().
However, other algorithm/strategy implementations are free to write to the Resource as is appropriate
for the given context (e.g. cloud environment). In those cases, implementors should override
the write(Resource, byte[]) method.resourceOutputStream - OutputStream returned from WritableResource.getOutputStream()
used to write the given data to the locations identified by the target Resource.data - array of bytes containing the data to write.java.io.IOException - if an I/O error occurs while writing to the target Resource.OutputStream@NonNull
protected org.springframework.core.io.WritableResource preProcess(@NonNull
org.springframework.core.io.WritableResource resource)
WritableResource before writing to the WritableResource.resource - WritableResource to pre-process; never null.WritableResource.WritableResource