Interface ProtonCompositeBuffer
- All Superinterfaces:
- AutoCloseable,- Comparable<ProtonBuffer>,- ProtonBuffer,- ProtonBufferAccessors,- Resource<ProtonBuffer>
- All Known Implementing Classes:
- ProtonCompositeBufferImpl
- 
Method SummaryModifier and TypeMethodDescriptiondefault ProtonCompositeBufferadvanceReadOffset(int length) Adjusts the currentProtonBuffer.getReadOffset()of this buffer by the specifiedlength.default ProtonCompositeBufferadvanceWriteOffset(int length) Adjusts the currentProtonBuffer.getWriteOffset()of this buffer by the specifiedlength.append(ProtonBuffer buffer) Appends the given buffer to this composite buffer if all the constraints on buffer composites are met, otherwise thrown an exception.compact()Moves the readable portion of the buffer to the beginning of the underlying buffer storage and possibly makes additional bytes available for writes before a buffer expansion would occur via anProtonBuffer.ensureWritable(int)call.Converts this buffer instance to a read-only buffer, any write operation that is performed on this buffer following this call will fail.default ProtonCompositeBuffercopy()Create a deep copy of the readable bytes of this ProtonBuffer, the returned buffer can be modified without affecting the contents or position markers of this instance.default ProtonCompositeBuffercopy(boolean readOnly) Returns a copy of this buffer's readable bytes and sets the read-only state of the returned buffer based on the value of the read-only flag.default ProtonCompositeBuffercopy(int index, int length) Returns a copy of this buffer's sub-region.copy(int index, int length, boolean readOnly) Returns a copy of this buffer's sub-region.static ProtonCompositeBuffercreate(ProtonBufferAllocator allocator) Create an empty composite buffer that will use the provided allocator to create new buffer capacity if writes are performed and insufficient space remains (unless the capacity limit is reached).static ProtonCompositeBuffercreate(ProtonBufferAllocator allocator, ProtonBuffer buffer) Create an composite buffer with the given buffer instance as the initial buffer payload.static ProtonCompositeBuffercreate(ProtonBufferAllocator allocator, ProtonBuffer[] buffers) Create an composite buffer with the given array of buffers as the initial buffer payload.Splits the composite buffer up into a collection of buffers that comprise it and leaves this buffer in what is effectively a closed state.default ProtonCompositeBufferensureWritable(int amount) Ensures that the requested number of bytes is available for write operations in the current buffer, growing the buffer if needed to meet the requested writable capacity.ensureWritable(int size, int minimumGrowth, boolean allowCompaction) Ensures that the requested number of bytes is available for write operations in the current buffer, growing the buffer if needed to meet the requested writable capacity.fill(byte value) Assigns the given value to every byte in the buffer without respect for the buffer read or write offsets.implicitGrowthLimit(int limit) Configures the limit assigned to this buffer if one was set which controls how large the capacity of the buffer can grow implicitly via write calls.static booleanisComposite(ProtonBuffer buffer) Checks if the given buffer is an composite buffer instance or not.default ProtonCompositeBufferreadBytes(byte[] destination, int offset, int length) Read from this buffer, into the destination array, the given number of bytes.default ProtonCompositeBufferreadBytes(ByteBuffer destination) Read from this buffer, into the destinationByteBufferThis updates the read offset of this buffer and also the position of the destinationByteBuffer.default ProtonCompositeBufferreadSplit(int length) Splits this buffer at the read offset + the length given.setReadOffset(int value) Sets the read offset for this buffer.setWriteOffset(int value) Sets the write offset for this buffer.default ProtonCompositeBuffersplit()Splits this buffer at the write offset.split(int splitOffset) Splits this buffer at the given offset.splitComponentsCeil(int splitOffset) Split this buffer returning a composite that consists of all the buffer components up to and including the buffer that contains the split offset, no buffer components are split.splitComponentsFloor(int splitOffset) Split this buffer returning a composite that consists of all the buffer components that come before the buffer that contains the split offset, no buffer components are split.default ProtonCompositeBufferwriteBytes(byte[] source) Writes into this buffer, all the bytes from the given byte array.default ProtonCompositeBufferwriteBytes(byte[] source, int offset, int length) Writes into this buffer, the given number of bytes from the byte array.default ProtonCompositeBufferwriteBytes(ByteBuffer source) Writes into this buffer from the sourceByteBuffer.default ProtonCompositeBufferwriteBytes(ProtonBuffer source) Writes into this buffer, all the readable bytes from the given buffer.default ProtonCompositeBufferwriteSplit(int length) Splits this buffer at the write offset + the length given.Methods inherited from interface org.apache.qpid.protonj2.buffer.ProtonBufferbufferIterator, bufferIterator, bufferReverseIterator, bufferReverseIterator, capacity, clear, close, compareTo, componentAccessor, componentCount, copyInto, copyInto, copyInto, getReadableBytes, getReadOffset, getWritableBytes, getWriteOffset, implicitGrowthLimit, indexOf, indexOf, isClosed, isComposite, isDirect, isReadable, isReadOnly, isWritable, readableComponentCount, readCharSequence, toString, transferFrom, transferFrom, transferTo, unwrap, writableComponentCount, writeCharSequenceMethods inherited from interface org.apache.qpid.protonj2.buffer.ProtonBufferAccessorsgetBoolean, getByte, getChar, getDouble, getFloat, getInt, getLong, getShort, getUnsignedByte, getUnsignedInt, getUnsignedShort, readBoolean, readByte, readChar, readDouble, readFloat, readInt, readLong, readShort, readUnsignedByte, readUnsignedInt, readUnsignedShort, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setShort, setUnsignedByte, setUnsignedInt, setUnsignedShort, writeBoolean, writeByte, writeChar, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort
- 
Method Details- 
createCreate an empty composite buffer that will use the provided allocator to create new buffer capacity if writes are performed and insufficient space remains (unless the capacity limit is reached).- Parameters:
- allocator- The allocator to use when adding new buffer capacity automatically.
- Returns:
- a new empty composite buffer instance.
 
- 
createCreate an composite buffer with the given buffer instance as the initial buffer payload. The provided buffer allocator will use the provided allocator to create new buffer capacity if writes are performed and insufficient space remains (unless the capacity limit is reached).- Parameters:
- allocator- The allocator to use when adding new buffer capacity automatically.
- buffer- The initial buffer to append as the body of the returned composite buffer.
- Returns:
- a new composite buffer instance that wraps the given buffer.
 
- 
createCreate an composite buffer with the given array of buffers as the initial buffer payload. The provided buffer allocator will use the provided allocator to create new buffer capacity if writes are performed and insufficient space remains (unless the capacity limit is reached).- Parameters:
- allocator- The allocator to use when adding new buffer capacity automatically.
- buffers- The initial buffers to append as the body of the returned composite buffer.
- Returns:
- a new composite buffer instance that wraps the given buffers.
 
- 
isCompositeChecks if the given buffer is an composite buffer instance or not.- Parameters:
- buffer- the buffer instance to check.
- Returns:
- true if the buffer given is a composite buffer or false if not.
 
- 
appendAppends the given buffer to this composite buffer if all the constraints on buffer composites are met, otherwise thrown an exception.- Parameters:
- buffer- The buffer to append to this composite collection of buffers.
- Returns:
- this composite buffer instance.
 
- 
decomposeBufferIterable<ProtonBuffer> decomposeBuffer()Splits the composite buffer up into a collection of buffers that comprise it and leaves this buffer in what is effectively a closed state. The returned buffers are now the property of the caller who must ensure they are closed when no longer in use..- Returns:
- the collection of buffers that comprised this composite buffer.
 
- 
splitComponentsFloorSplit this buffer returning a composite that consists of all the buffer components that come before the buffer that contains the split offset, no buffer components are split. This allows for operations such as reclaiming read bytes from a buffer to reduce overall memory use.- Parameters:
- splitOffset- The index into the buffer where the split should be performed.
- Returns:
- A ProtonCompositeBufferthat owns all buffers that come before the buffer that holds given index.
 
- 
splitComponentsCeilSplit this buffer returning a composite that consists of all the buffer components up to and including the buffer that contains the split offset, no buffer components are split.- Parameters:
- splitOffset- The index into the buffer where the split should be performed.
- Returns:
- A ProtonCompositeBufferthat owns all buffers up to and including the buffer that holds given index.
 
- 
fillDescription copied from interface:ProtonBufferAssigns the given value to every byte in the buffer without respect for the buffer read or write offsets.- Specified by:
- fillin interface- ProtonBuffer
- Parameters:
- value- The byte value to assign each byte in this buffer.
- Returns:
- this ProtonBuffer for chaining.
 
- 
setReadOffsetDescription copied from interface:ProtonBufferSets the read offset for this buffer.- Specified by:
- setReadOffsetin interface- ProtonBuffer
- Parameters:
- value- The offset into the buffer where the read offset should be positioned.
- Returns:
- this buffer for use in chaining.
 
- 
advanceReadOffsetDescription copied from interface:ProtonBufferAdjusts the currentProtonBuffer.getReadOffset()of this buffer by the specifiedlength.- Specified by:
- advanceReadOffsetin interface- ProtonBuffer
- Parameters:
- length- the number of bytes to advance the read offset by.
- Returns:
- this ProtonBuffer for chaining.
 
- 
setWriteOffsetDescription copied from interface:ProtonBufferSets the write offset for this buffer.- Specified by:
- setWriteOffsetin interface- ProtonBuffer
- Parameters:
- value- The offset into the buffer where the write offset should be positioned.
- Returns:
- this buffer for use in chaining.
 
- 
advanceWriteOffsetDescription copied from interface:ProtonBufferAdjusts the currentProtonBuffer.getWriteOffset()of this buffer by the specifiedlength.- Specified by:
- advanceWriteOffsetin interface- ProtonBuffer
- Parameters:
- length- the number of bytes to advance the write offset by.
- Returns:
- this ProtonBuffer for chaining.
 
- 
implicitGrowthLimitDescription copied from interface:ProtonBufferConfigures the limit assigned to this buffer if one was set which controls how large the capacity of the buffer can grow implicitly via write calls. Once the limit is hit any write call that requires more capacity than is currently available will throw an exception instead of allocating more space.When a capacity limit is hit the buffer can still be enlarged but must be done explicitly via the ensure writable APIs. The growth limit set applies only to this buffer instance and is not carried over to a copied buffer of the split buffer created from any of the buffer split calls. - Specified by:
- implicitGrowthLimitin interface- ProtonBuffer
- Parameters:
- limit- The limit to assign as the maximum capacity this buffer can grow
- Returns:
- this buffer for using in call chaining.
 
- 
ensureWritabledefault ProtonCompositeBuffer ensureWritable(int amount) throws IndexOutOfBoundsException, IllegalArgumentException Description copied from interface:ProtonBufferEnsures that the requested number of bytes is available for write operations in the current buffer, growing the buffer if needed to meet the requested writable capacity. This method will not alter the write offset but may change the value returned from the capacity method if new buffer space is allocated.This method allows buffer compaction as a strategy to reclaim already read space to make room for additional writes. This implies that a composite buffer can reuse already read buffers to extend the buffer's writable space by moving them to the end of the set of composite buffers and reseting their index values to make them fully writable. - Specified by:
- ensureWritablein interface- ProtonBuffer
- Parameters:
- amount- The number of bytes beyond the current write index needed.
- Returns:
- this buffer for using in call chaining.
- Throws:
- IndexOutOfBoundsException- if the amount given would result in the buffer exceeding the maximum capacity for this buffer.
- IllegalArgumentException- if the amount given is less than zero.
 
- 
ensureWritableProtonCompositeBuffer ensureWritable(int size, int minimumGrowth, boolean allowCompaction) throws IndexOutOfBoundsException, IllegalArgumentException Description copied from interface:ProtonBufferEnsures that the requested number of bytes is available for write operations in the current buffer, growing the buffer if needed to meet the requested writable capacity. This method will not alter the write offset but may change the value returned from the capacity method if new buffer space is allocated. If the buffer cannot create the required number of byte via compaction then the buffer will be grown by either the requested number of bytes or by the minimum allowed value specified.This method allows buffer compaction as a strategy to reclaim already read space to make room for additional writes. This implies that a composite buffer can reuse already read buffers to extend the buffer's writable space by moving them to the end of the set of composite buffers and reseting their index values to make them fully writable. - Specified by:
- ensureWritablein interface- ProtonBuffer
- Parameters:
- size- The number of bytes beyond the current write index needed.
- minimumGrowth- The minimum number of byte that the buffer can grow by
- allowCompaction- Can the buffer use compaction as a strategy to create more writable space.
- Returns:
- this buffer for using in call chaining.
- Throws:
- IndexOutOfBoundsException- if the amount given would result in the buffer exceeding the maximum capacity for this buffer.
- IllegalArgumentException- if the amount given is less than zero.
 
- 
convertToReadOnlyProtonCompositeBuffer convertToReadOnly()Description copied from interface:ProtonBufferConverts this buffer instance to a read-only buffer, any write operation that is performed on this buffer following this call will fail. A buffer cannot be made writable after this call.- Specified by:
- convertToReadOnlyin interface- ProtonBuffer
- Returns:
- this buffer for use in chaining.
 
- 
copyDescription copied from interface:ProtonBufferCreate a deep copy of the readable bytes of this ProtonBuffer, the returned buffer can be modified without affecting the contents or position markers of this instance. The returned copy will not be read-only regardless of the read-only state of this buffer instance at the time of copy.- Specified by:
- copyin interface- ProtonBuffer
- Returns:
- a deep copy of this ProtonBuffer instance.
 
- 
copyDescription copied from interface:ProtonBufferReturns a copy of this buffer's sub-region. Modifying the content of the returned buffer or this buffer does not affect each other at all. This method does not modify the value returned fromProtonBuffer.getReadOffset()orProtonBuffer.getWriteOffset()of this buffer.The returned buffer will not be read-only even if this buffer is and as such the contents will be a deep copy regardless of this buffer's read-only state. - Specified by:
- copyin interface- ProtonBuffer
- Parameters:
- index- The index in this buffer where the copy should begin
- length- The number of bytes to copy to the new buffer from this one.
- Returns:
- a new ProtonBuffer instance containing the copied bytes.
 
- 
copyDescription copied from interface:ProtonBufferReturns a copy of this buffer's readable bytes and sets the read-only state of the returned buffer based on the value of the read-only flag. If this buffer is read-only and the flag indicates a read-only copy then the copy may be a shallow copy that references the readable bytes of the source buffer.- Specified by:
- copyin interface- ProtonBuffer
- Parameters:
- readOnly- Should the returned buffer be read-only or not.
- Returns:
- a new ProtonBuffer instance containing the copied bytes.
 
- 
copyDescription copied from interface:ProtonBufferReturns a copy of this buffer's sub-region. Modifying the content of the returned buffer or this buffer does not affect each other at all. This method does not modify the value returned fromProtonBuffer.getReadOffset()orProtonBuffer.getWriteOffset()of this buffer.If this buffer is read-only and the requested copy is also read-only the copy may be shallow and allow each buffer to share the same memory. - Specified by:
- copyin interface- ProtonBuffer
- Parameters:
- index- The index in this buffer where the copy should begin
- length- The number of bytes to copy to the new buffer from this one.
- readOnly- Should the returned buffer be read-only or not.
- Returns:
- a new ProtonBuffer instance containing the copied bytes.
- Throws:
- IllegalArgumentException- if the offset or length given are out of bounds.
 
- 
compactProtonCompositeBuffer compact()Description copied from interface:ProtonBufferMoves the readable portion of the buffer to the beginning of the underlying buffer storage and possibly makes additional bytes available for writes before a buffer expansion would occur via anProtonBuffer.ensureWritable(int)call.- Specified by:
- compactin interface- ProtonBuffer
- Returns:
- this buffer for using in call chaining.
 
- 
readSplitDescription copied from interface:ProtonBufferSplits this buffer at the read offset + the length given.- Specified by:
- readSplitin interface- ProtonBuffer
- Parameters:
- length- The number of bytes beyond the read offset where the split should occur
- Returns:
- A new buffer that owns the memory spanning the range given.
 
- 
writeSplitDescription copied from interface:ProtonBufferSplits this buffer at the write offset + the length given.- Specified by:
- writeSplitin interface- ProtonBuffer
- Parameters:
- length- The number of bytes beyond the write offset where the split should occur
- Returns:
- A new buffer that owns the memory spanning the range given.
 
- 
splitDescription copied from interface:ProtonBufferSplits this buffer at the write offset.This creates two independent buffers that can manage differing views of the same memory region or in the case of a composite buffer two buffers that take ownership of differing sections of the composite buffer range. For a composite buffer a single buffer might be split if the offset lays within its bounds but all others buffers are divided amongst the two split buffers. If this buffer is a read-only buffer then the resulting split buffer will also be read-only. - Specified by:
- splitin interface- ProtonBuffer
- Returns:
- A new buffer that owns the memory spanning the range given.
 
- 
splitDescription copied from interface:ProtonBufferSplits this buffer at the given offset.This creates two independent buffers that can manage differing views of the same memory region or in the case of a composite buffer two buffers that take ownership of differing sections of the composite buffer range. For a composite buffer a single buffer might be split if the offset lays within its bounds but all others buffers are divided amongst the two split buffers. If this buffer is a read-only buffer then the resulting split buffer will also be read-only. - Specified by:
- splitin interface- ProtonBuffer
- Parameters:
- splitOffset- The offset in this buffer where the split should occur.
- Returns:
- A new buffer that owns the memory spanning the range given.
 
- 
writeBytesDescription copied from interface:ProtonBufferWrites into this buffer, all the readable bytes from the given buffer. This updates theProtonBuffer.getWriteOffset()of this buffer, and theProtonBuffer.getReadOffset()of the given buffer.- Specified by:
- writeBytesin interface- ProtonBuffer
- Parameters:
- source- The buffer to read from.
- Returns:
- This buffer.
 
- 
writeBytesDescription copied from interface:ProtonBufferWrites into this buffer, all the bytes from the given byte array. This updates the ProtonBuffer.getWriteOffset() of this buffer by the length of the array.- Specified by:
- writeBytesin interface- ProtonBuffer
- Parameters:
- source- The byte array to read from.
- Returns:
- this buffer for using in call chaining.
 
- 
writeBytesDescription copied from interface:ProtonBufferWrites into this buffer, the given number of bytes from the byte array. This updates the ProtonBuffer.getWriteOffset() of this buffer by the length argument. Implementations are recommended to specialize this method and provide a more efficient version.- Specified by:
- writeBytesin interface- ProtonBuffer
- Parameters:
- source- The byte array to read from.
- offset- The position in the- sourcefrom where bytes should be written to this buffer.
- length- The number of bytes to copy.
- Returns:
- this buffer for using in call chaining.
 
- 
writeBytesDescription copied from interface:ProtonBufferWrites into this buffer from the sourceByteBuffer. This updates theProtonBuffer.getWriteOffset()of this buffer and also the position of the sourceByteBuffer. Implementations are recommended to specialize this method and provide a more efficient version.Note: the behavior is undefined if the given ByteBufferis an alias for the memory in this buffer.- Specified by:
- writeBytesin interface- ProtonBuffer
- Parameters:
- source- The- ByteBufferto read from.
- Returns:
- this buffer for using in call chaining.
 
- 
readBytesDescription copied from interface:ProtonBufferRead from this buffer, into the destinationByteBufferThis updates the read offset of this buffer and also the position of the destinationByteBuffer.Note: the behavior is undefined if the given ByteBufferis an alias for the memory in this buffer.- Specified by:
- readBytesin interface- ProtonBuffer
- Parameters:
- destination- The- ByteBufferto write into.
- Returns:
- this buffer for using in call chaining.
 
- 
readBytesDescription copied from interface:ProtonBufferRead from this buffer, into the destination array, the given number of bytes. This updates the read offset of this buffer by the length argument.- Specified by:
- readBytesin interface- ProtonBuffer
- Parameters:
- destination- The byte array to write into.
- offset- Position in the- destinationto where bytes should be written from this buffer.
- length- The number of bytes to copy.
- Returns:
- This buffer.
 
 
-