public abstract class DataBufferUtils
extends java.lang.Object
DataBuffers.| Constructor and Description |
|---|
DataBufferUtils() |
| Modifier and Type | Method and Description |
|---|---|
static reactor.core.publisher.Mono<DataBuffer> |
join(org.reactivestreams.Publisher<DataBuffer> dataBuffers)
Return a new
DataBuffer composed of the dataBuffers elements joined together. |
static reactor.core.publisher.Flux<DataBuffer> |
read(java.nio.channels.AsynchronousFileChannel channel,
DataBufferFactory dataBufferFactory,
int bufferSize)
Deprecated.
as of Spring 5.0.3, in favor of
readAsynchronousFileChannel(Callable, DataBufferFactory, int), to be removed in
Spring 5.1 |
static reactor.core.publisher.Flux<DataBuffer> |
read(java.nio.channels.AsynchronousFileChannel channel,
long position,
DataBufferFactory dataBufferFactory,
int bufferSize)
Deprecated.
as of Spring 5.0.3, in favor of
readAsynchronousFileChannel(Callable, long, DataBufferFactory, int), to be removed
in Spring 5.1 |
static reactor.core.publisher.Flux<DataBuffer> |
read(java.io.InputStream inputStream,
DataBufferFactory dataBufferFactory,
int bufferSize)
Deprecated.
as of Spring 5.0.3, in favor of
readInputStream(Callable, DataBufferFactory, int), to be removed in Spring 5.1 |
static reactor.core.publisher.Flux<DataBuffer> |
read(java.nio.channels.ReadableByteChannel channel,
DataBufferFactory dataBufferFactory,
int bufferSize)
Deprecated.
as of Spring 5.0.3, in favor of
readByteChannel(Callable, DataBufferFactory, int), to be removed in Spring 5.1 |
static reactor.core.publisher.Flux<DataBuffer> |
read(Resource resource,
DataBufferFactory dataBufferFactory,
int bufferSize)
Read the given
Resource into a Flux of DataBuffers. |
static reactor.core.publisher.Flux<DataBuffer> |
read(Resource resource,
long position,
DataBufferFactory dataBufferFactory,
int bufferSize)
Read the given
Resource into a Flux of DataBuffers
starting at the given position. |
static reactor.core.publisher.Flux<DataBuffer> |
readAsynchronousFileChannel(java.util.concurrent.Callable<java.nio.channels.AsynchronousFileChannel> channelSupplier,
DataBufferFactory dataBufferFactory,
int bufferSize)
Obtain a
AsynchronousFileChannel from the given supplier, and read it into a
Flux of DataBuffers. |
static reactor.core.publisher.Flux<DataBuffer> |
readAsynchronousFileChannel(java.util.concurrent.Callable<java.nio.channels.AsynchronousFileChannel> channelSupplier,
long position,
DataBufferFactory dataBufferFactory,
int bufferSize)
Obtain a
AsynchronousFileChannel from the given supplier, and read it into a
Flux of DataBuffers, starting at the given position. |
static reactor.core.publisher.Flux<DataBuffer> |
readByteChannel(java.util.concurrent.Callable<java.nio.channels.ReadableByteChannel> channelSupplier,
DataBufferFactory dataBufferFactory,
int bufferSize)
Obtain a
ReadableByteChannel from the given supplier, and read it into a
Flux of DataBuffers. |
static reactor.core.publisher.Flux<DataBuffer> |
readInputStream(java.util.concurrent.Callable<java.io.InputStream> inputStreamSupplier,
DataBufferFactory dataBufferFactory,
int bufferSize)
Obtain a
InputStream from the given supplier, and read it into a Flux
of DataBuffers. |
static boolean |
release(DataBuffer dataBuffer)
Release the given data buffer, if it is a
PooledDataBuffer. |
static java.util.function.Consumer<DataBuffer> |
releaseConsumer()
Return a consumer that calls
release(DataBuffer) on all
passed data buffers. |
static <T extends DataBuffer> |
retain(T dataBuffer)
Retain the given data buffer, it it is a
PooledDataBuffer. |
static reactor.core.publisher.Flux<DataBuffer> |
skipUntilByteCount(org.reactivestreams.Publisher<DataBuffer> publisher,
long maxByteCount)
Skip buffers from the given
Publisher until the total
byte count reaches
the given maximum byte count, or until the publisher is complete. |
static reactor.core.publisher.Flux<DataBuffer> |
takeUntilByteCount(org.reactivestreams.Publisher<DataBuffer> publisher,
long maxByteCount)
Relay buffers from the given
Publisher until the total
byte count reaches
the given maximum byte count, or until the publisher is complete. |
static reactor.core.publisher.Flux<DataBuffer> |
write(org.reactivestreams.Publisher<DataBuffer> source,
java.nio.channels.AsynchronousFileChannel channel,
long position)
Write the given stream of
DataBuffers to the given AsynchronousFileChannel. |
static reactor.core.publisher.Flux<DataBuffer> |
write(org.reactivestreams.Publisher<DataBuffer> source,
java.io.OutputStream outputStream)
Write the given stream of
DataBuffers to the given OutputStream. |
static reactor.core.publisher.Flux<DataBuffer> |
write(org.reactivestreams.Publisher<DataBuffer> source,
java.nio.channels.WritableByteChannel channel)
Write the given stream of
DataBuffers to the given WritableByteChannel. |
@Deprecated public static reactor.core.publisher.Flux<DataBuffer> read(java.io.InputStream inputStream, DataBufferFactory dataBufferFactory, int bufferSize)
readInputStream(Callable, DataBufferFactory, int), to be removed in Spring 5.1InputStream into a read-once Flux of
DataBuffers. Closes the input stream when the flux is terminated.
The resulting Flux can only be subscribed to once. See
readInputStream(Callable, DataBufferFactory, int) for a variant that supports
multiple subscriptions.
inputStream - the input stream to read fromdataBufferFactory - the factory to create data buffers withbufferSize - the maximum size of the data bufferspublic static reactor.core.publisher.Flux<DataBuffer> readInputStream(java.util.concurrent.Callable<java.io.InputStream> inputStreamSupplier, DataBufferFactory dataBufferFactory, int bufferSize)
InputStream from the given supplier, and read it into a Flux
of DataBuffers. Closes the input stream when the flux is terminated.inputStreamSupplier - the supplier for the input stream to read fromdataBufferFactory - the factory to create data buffers withbufferSize - the maximum size of the data buffers@Deprecated public static reactor.core.publisher.Flux<DataBuffer> read(java.nio.channels.ReadableByteChannel channel, DataBufferFactory dataBufferFactory, int bufferSize)
readByteChannel(Callable, DataBufferFactory, int), to be removed in Spring 5.1ReadableByteChannel into a read-once Flux
of DataBuffers. Closes the channel when the flux is terminated.
The resulting Flux can only be subscribed to once. See
readByteChannel(Callable, DataBufferFactory, int) for a variant that supports
multiple subscriptions.
channel - the channel to read fromdataBufferFactory - the factory to create data buffers withbufferSize - the maximum size of the data bufferspublic static reactor.core.publisher.Flux<DataBuffer> readByteChannel(java.util.concurrent.Callable<java.nio.channels.ReadableByteChannel> channelSupplier, DataBufferFactory dataBufferFactory, int bufferSize)
ReadableByteChannel from the given supplier, and read it into a
Flux of DataBuffers. Closes the channel when the flux is terminated.channelSupplier - the supplier for the channel to read fromdataBufferFactory - the factory to create data buffers withbufferSize - the maximum size of the data buffers@Deprecated public static reactor.core.publisher.Flux<DataBuffer> read(java.nio.channels.AsynchronousFileChannel channel, DataBufferFactory dataBufferFactory, int bufferSize)
readAsynchronousFileChannel(Callable, DataBufferFactory, int), to be removed in
Spring 5.1AsynchronousFileChannel into a read-once Flux
of DataBuffers. Closes the channel when the flux is terminated.
The resulting Flux can only be subscribed to once. See
readAsynchronousFileChannel(Callable, DataBufferFactory, int) for a variant that
supports multiple subscriptions.
channel - the channel to read fromdataBufferFactory - the factory to create data buffers withbufferSize - the maximum size of the data buffers@Deprecated public static reactor.core.publisher.Flux<DataBuffer> read(java.nio.channels.AsynchronousFileChannel channel, long position, DataBufferFactory dataBufferFactory, int bufferSize)
readAsynchronousFileChannel(Callable, long, DataBufferFactory, int), to be removed
in Spring 5.1AsynchronousFileChannel into a read-once Flux
of DataBuffers, starting at the given position. Closes the channel when the flux is
terminated.
The resulting Flux can only be subscribed to once. See
readAsynchronousFileChannel(Callable, long, DataBufferFactory, int) for a variant
that supports multiple subscriptions.
channel - the channel to read fromposition - the position to start reading fromdataBufferFactory - the factory to create data buffers withbufferSize - the maximum size of the data bufferspublic static reactor.core.publisher.Flux<DataBuffer> readAsynchronousFileChannel(java.util.concurrent.Callable<java.nio.channels.AsynchronousFileChannel> channelSupplier, DataBufferFactory dataBufferFactory, int bufferSize)
AsynchronousFileChannel from the given supplier, and read it into a
Flux of DataBuffers. Closes the channel when the flux is terminated.channelSupplier - the supplier for the channel to read fromdataBufferFactory - the factory to create data buffers withbufferSize - the maximum size of the data bufferspublic static reactor.core.publisher.Flux<DataBuffer> readAsynchronousFileChannel(java.util.concurrent.Callable<java.nio.channels.AsynchronousFileChannel> channelSupplier, long position, DataBufferFactory dataBufferFactory, int bufferSize)
AsynchronousFileChannel from the given supplier, and read it into a
Flux of DataBuffers, starting at the given position. Closes the
channel when the flux is terminated.channelSupplier - the supplier for the channel to read fromposition - the position to start reading fromdataBufferFactory - the factory to create data buffers withbufferSize - the maximum size of the data bufferspublic static reactor.core.publisher.Flux<DataBuffer> read(Resource resource, DataBufferFactory dataBufferFactory, int bufferSize)
Resource into a Flux of DataBuffers.
If the resource is a file, it is read into an
AsynchronousFileChannel and turned to Flux via
readAsynchronousFileChannel(Callable, DataBufferFactory, int) or else
fall back to readByteChannel(Callable, DataBufferFactory, int).
Closes the channel when the flux is terminated.
resource - the resource to read fromdataBufferFactory - the factory to create data buffers withbufferSize - the maximum size of the data bufferspublic static reactor.core.publisher.Flux<DataBuffer> read(Resource resource, long position, DataBufferFactory dataBufferFactory, int bufferSize)
Resource into a Flux of DataBuffers
starting at the given position.
If the resource is a file, it is read into an
AsynchronousFileChannel and turned to Flux via
readAsynchronousFileChannel(Callable, DataBufferFactory, int) or else
fall back on readByteChannel(Callable, DataBufferFactory, int).
Closes the channel when the flux is terminated.
resource - the resource to read fromposition - the position to start reading fromdataBufferFactory - the factory to create data buffers withbufferSize - the maximum size of the data bufferspublic static reactor.core.publisher.Flux<DataBuffer> write(org.reactivestreams.Publisher<DataBuffer> source, java.io.OutputStream outputStream)
DataBuffers to the given OutputStream. Does
not close the output stream when the flux is terminated, and does
not release the data buffers in the
source. If releasing is required, then subscribe to the returned Flux with a
releaseConsumer().
Note that the writing process does not start until the returned Flux is subscribed to.
source - the stream of data buffers to be writtenoutputStream - the output stream to write tosource, that starts the writing
process when subscribed to, and that publishes any writing errors and the completion signalpublic static reactor.core.publisher.Flux<DataBuffer> write(org.reactivestreams.Publisher<DataBuffer> source, java.nio.channels.WritableByteChannel channel)
DataBuffers to the given WritableByteChannel. Does
not close the channel when the flux is terminated, and does
not release the data buffers in the
source. If releasing is required, then subscribe to the returned Flux with a
releaseConsumer().
Note that the writing process does not start until the returned Flux is subscribed to.
source - the stream of data buffers to be writtenchannel - the channel to write tosource, that starts the writing
process when subscribed to, and that publishes any writing errors and the completion signalpublic static reactor.core.publisher.Flux<DataBuffer> write(org.reactivestreams.Publisher<DataBuffer> source, java.nio.channels.AsynchronousFileChannel channel, long position)
DataBuffers to the given AsynchronousFileChannel.
Does not close the channel when the flux is terminated, and does
not release the data buffers in the
source. If releasing is required, then subscribe to the returned Flux with a
releaseConsumer().
Note that the writing process does not start until the returned Flux is subscribed to.
source - the stream of data buffers to be writtenchannel - the channel to write tosource, that starts the writing
process when subscribed to, and that publishes any writing errors and the completion signalpublic static reactor.core.publisher.Flux<DataBuffer> takeUntilByteCount(org.reactivestreams.Publisher<DataBuffer> publisher, long maxByteCount)
Publisher until the total
byte count reaches
the given maximum byte count, or until the publisher is complete.publisher - the publisher to filtermaxByteCount - the maximum byte countmaxByteCountpublic static reactor.core.publisher.Flux<DataBuffer> skipUntilByteCount(org.reactivestreams.Publisher<DataBuffer> publisher, long maxByteCount)
Publisher until the total
byte count reaches
the given maximum byte count, or until the publisher is complete.publisher - the publisher to filtermaxByteCount - the maximum byte countpublic static <T extends DataBuffer> T retain(T dataBuffer)
PooledDataBuffer.dataBuffer - the data buffer to retainpublic static boolean release(@Nullable DataBuffer dataBuffer)
PooledDataBuffer.dataBuffer - the data buffer to releasetrue if the buffer was released; false otherwise.public static java.util.function.Consumer<DataBuffer> releaseConsumer()
release(DataBuffer) on all
passed data buffers.public static reactor.core.publisher.Mono<DataBuffer> join(org.reactivestreams.Publisher<DataBuffer> dataBuffers)
DataBuffer composed of the dataBuffers elements joined together.
Depending on the DataBuffer implementation, the returned buffer may be a single
buffer containing all data of the provided buffers, or it may be a true composite that
contains references to the buffers.dataBuffers - the data buffers that are to be composeddataBuffers argument