Interface ResourceWriter
- All Known Implementing Classes:
AbstractResourceWriter
,FileResourceWriter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Interface (contract) for writers to define the algorithm or strategy for writing data to a target
Resource
,
such as by using the WritableResource's
WritableResource.getOutputStream()
OutputStream}.- Since:
- 1.3.1
- See Also:
-
Resource
WritableResource
-
Method Summary
Modifier and TypeMethodDescriptiondefault ResourceWriter
thenWriteTo
(ResourceWriter writer) Composes thisResourceWriter
with the givenResourceWriter
using the Composite Software Design Pattern.void
write
(org.springframework.core.io.Resource resource, byte[] data) Writes data to the targetResource
as defined by the algorithm/strategy of this writer.default void
write
(org.springframework.core.io.Resource resource, ByteBuffer data) Writes data contained in theByteBuffer
to the targetResource
as defined by the algorithm/strategy of this writer.
-
Method Details
-
write
void write(@NonNull org.springframework.core.io.Resource resource, byte[] data) Writes data to the targetResource
as defined by the algorithm/strategy of this writer. This method should throw anUnhandledResourceException
if the algorithm or strategy used by this writer is not able to or capable of writing to theResource
at its location. This allows subsequent writers in a composition to possibly handle theResource
. Any otherException
thrown by thiswrite
method will break the chain of write calls in the composition.- Parameters:
resource
-Resource
to write data to.data
- array of bytes containing the data to write to the targetResource
.- See Also:
-
Resource
-
write
Writes data contained in theByteBuffer
to the targetResource
as defined by the algorithm/strategy of this writer. This method should throw anUnhandledResourceException
if the algorithm or strategy used by this writer is not able to or capable of writing to theResource
at its location. This allows subsequent writers in a composition to possibly handle theResource
. Any otherException
thrown by thiswrite
method will break the chain of write calls in the composition.- Parameters:
resource
-Resource
to write data to.data
-ByteBuffer
containing the data to write to the targetResource
.- See Also:
-
Resource
ByteBuffer
write(Resource, byte[])
-
thenWriteTo
Composes thisResourceWriter
with the givenResourceWriter
using the Composite Software Design Pattern.- Parameters:
writer
-ResourceWriter
to compose with this writer.- Returns:
- a composite
ResourceWriter
composed of thisResourceWriter
and the givenResourceWriter
. If the givenResourceWriter
is null, then thisResourceWriter
is returned. - See Also:
-