Class AvailableByteArrayBody
- All Implemented Interfaces:
AvailableByteBody, ByteBody, CloseableAvailableByteBody, CloseableByteBody, Closeable, AutoCloseable
AvailableByteBody implementation based on a simple byte array.- Since:
- 4.6.0
- Author:
- Jonas Konrad
-
Nested Class Summary
Nested classes/interfaces inherited from interface ByteBody
ByteBody.BodyDiscardedException, ByteBody.SplitBackpressureMode -
Method Summary
Modifier and TypeMethodDescriptionExecutionFlow<? extends CloseableAvailableByteBody> Variant ofInternalByteBody.buffer()that uses theExecutionFlowAPI for extra efficiency.voidclose()Clean up any resources held by this instance.static AvailableByteArrayBodycreate(ByteBufferFactory<?, ?> bufferFactory, byte[] array) Deprecated.static AvailableByteArrayBodycreate(ReadBuffer readBuffer) longlength()The length in bytes of the body.move()Create a newCloseableByteBodywith the same content but an independent lifecycle, claiming this body in the process.peek()split()Equivalent tosplit(SplitBackpressureMode.SLOWEST).byte[]Get this body as a byte array.Get this body as aReadBuffer.Get this body as a reactive stream ofReadBuffers.Methods inherited from class InternalByteBody
buffer, bufferFlow, failClaim, recordClosed, recordPrimaryOp, toByteArrayPublisherMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AvailableByteBody
expectedLength, split, toByteArrayPublisher, toByteBuffer, toByteBufferPublisher, toInputStream, toStringMethods inherited from interface CloseableAvailableByteBody
allowDiscard
-
Method Details
-
create
@Deprecated public static AvailableByteArrayBody create(ByteBufferFactory<?, ?> bufferFactory, byte[] array) Deprecated.Construct throughByteBodyFactoryinsteadCreates a newAvailableByteArrayBodyinstance.- Parameters:
bufferFactory- theByteBufferFactoryto use for creating buffersarray- the byte array to wrap- Returns:
- a new
AvailableByteArrayBodyinstance
-
create
-
split
Description copied from interface:ByteBodyEquivalent tosplit(SplitBackpressureMode.SLOWEST).- Specified by:
splitin interfaceAvailableByteBody- Specified by:
splitin interfaceByteBody- Returns:
- The newly split body. Must be closed by the caller, unless a terminal operation is performed on it
- See Also:
-
length
public long length()Description copied from interface:AvailableByteBodyThe length in bytes of the body.- Specified by:
lengthin interfaceAvailableByteBody- Returns:
- The length
- See Also:
-
toByteArray
public byte[] toByteArray()Description copied from interface:AvailableByteBodyGet this body as a byte array.This is a primary operation. After this operation, no other primary operation or
AvailableByteBody.split()may be done.- Specified by:
toByteArrayin interfaceAvailableByteBody- Returns:
- The bytes
-
toReadBuffer
Description copied from interface:AvailableByteBodyGet this body as aReadBuffer.This is a primary operation. After this operation, no other primary operation or
AvailableByteBody.split()may be done.- Specified by:
toReadBufferin interfaceAvailableByteBody- Returns:
- The bytes
-
toReadBufferPublisher
Description copied from interface:ByteBodyGet this body as a reactive stream ofReadBuffers. Note that the caller must take care to release the returned buffers.This is a primary operation. After this operation, no other primary operation or
ByteBody.split()may be done.- Specified by:
toReadBufferPublisherin interfaceAvailableByteBody- Specified by:
toReadBufferPublisherin interfaceByteBody- Specified by:
toReadBufferPublisherin classInternalByteBody- Returns:
- The streamed bytes
-
move
Description copied from interface:ByteBodyCreate a newCloseableByteBodywith the same content but an independent lifecycle, claiming this body in the process.This is a primary operation. After this operation, no other primary operation or
ByteBody.split()may be done.The purpose of this method is to move the data to a different component in an application, making clear that the receiving component claims ownership of the body. If the sending component then closes the original
ByteBodyfor example, it will have no impact on the newCloseableByteBodythat the receiver is working with.- Specified by:
movein interfaceByteBody- Returns:
- A new
CloseableByteBodywith the same content.
-
close
public void close()Description copied from interface:CloseableByteBodyClean up any resources held by this instance. See class documentation.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceCloseableByteBody
-
bufferFlow
Description copied from class:InternalByteBodyVariant ofInternalByteBody.buffer()that uses theExecutionFlowAPI for extra efficiency.- Specified by:
bufferFlowin classInternalByteBody- Returns:
- A flow that completes when all bytes are available
-
peek
-
ByteBodyFactoryinstead