Class ProtonCompositeBufferImpl
- All Implemented Interfaces:
- AutoCloseable,- Comparable<ProtonBuffer>,- ProtonBuffer,- ProtonBufferAccessors,- ProtonCompositeBuffer,- Resource<ProtonBuffer>
- 
Constructor SummaryConstructorsConstructorDescriptionProtonCompositeBufferImpl(ProtonBufferAllocator allocator) Creates a new empty composite buffer.
- 
Method SummaryModifier and TypeMethodDescriptionappend(ProtonBuffer buffer) Appends the given buffer to this composite buffer if all the constraints on buffer composites are met, otherwise thrown an exception.bufferIterator(int offset, int length) Creates and returns a newProtonBufferIteratorthat iterates from the given offset and continues until specified number of bytes has been traversed.bufferReverseIterator(int offset, int length) Creates and returns a newProtonBufferIteratorthat reverse iterates from the given offset and continues until specified number of bytes has been traversed.intcapacity()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.Returns a component access object that can be used to gain access to the constituent buffer components for use in IO operations or other lower level buffer operations that need to work on single compoents.intReturns the number of constituent buffer components that are contained in this buffer instance which for a non-composite buffer will always be one (namely itself).Converts this buffer instance to a read-only buffer, any write operation that is performed on this buffer following this call will fail.copy(int index, int length, boolean readOnly) Returns a copy of this buffer's sub-region.voidcopyInto(int offset, byte[] destination, int destOffset, int length) Copies the given number of bytes from this buffer into the specified target byte array starting at the given offset into this buffer.voidcopyInto(int offset, ByteBuffer destination, int destOffset, int length) Copies the given number of bytes from this buffer into the specified targetByteBufferstarting at the given offset into this buffer.voidcopyInto(int offset, ProtonBuffer destination, int destOffset, int length) Copies the given number of bytes from this buffer into the specified targetProtonBufferstarting at the given offset into this buffer.static ProtonCompositeBuffercreate(ProtonBufferAllocator allocator) Create an emptyProtonCompositeBufferwith the given allocator which will be used any time the buffer needs to allocate additional storage space for implicit write or explicit ensure writable calls.static ProtonCompositeBuffercreate(ProtonBufferAllocator allocator, ProtonBuffer buffer) Create an emptyProtonCompositeBufferwith the given allocator which will be used any time the buffer needs to allocate additional storage space for implicit write or explicit ensure writable calls.static ProtonCompositeBuffercreate(ProtonBufferAllocator allocator, ProtonBuffer[] buffers) Create an emptyProtonCompositeBufferwith the given allocator which will be used any time the buffer needs to allocate additional storage space for implicit write or explicit ensure writable calls.Splits the composite buffer up into a collection of buffers that comprise it and leaves this buffer in what is effectively a closed state.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.booleanfill(byte value) Assigns the given value to every byte in the buffer without respect for the buffer read or write offsets.bytegetByte(int index) Reads a single byte at the given index and returns it without modification to the target buffer read offset.chargetChar(int index) Gets a 2-byte char from the specified index, this method will not modify the read or write index.intgetInt(int index) Gets a int from the specified index, this method will not modify the read or write index.longgetLong(int index) Gets a long from the specified index, this method will not modify the read or write index.intshortgetShort(int index) Gets a short from the specified index, this method will not modify the read or write index.intinthashCode()intReturns 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.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.intindexOf(byte needle, int offset, int length) Starting from the given offset into this buffer, find the next offset (index) in the buffer where the given value is located or-1if the value is not found by the time the specified number of bytes has been searched.booleanbooleanisDirect()booleanintReturns the number of readable constituent buffer components that are contained in this buffer instance which for a non-composite buffer will always be zero or one (namely itself).bytereadByte()Reads one byte from the buffer and advances the read index by one.charreadChar()Reads a character value from the buffer and advances the read index by four.intreadInt()Reads a integer value from the buffer and advances the read index by four.longreadLong()Reads a long value from the buffer and advances the read index by eight.shortReads a short value from the buffer and advances the read index by two.protected voidprotected RuntimeExceptionsetByte(int index, byte value) Sets the byte value at the given write index in this buffer's backing data store.setChar(int index, char value) Sets the char value at the given write index in this buffer's backing data store.setInt(int index, int value) Sets the int value at the given write index in this buffer's backing data store.setLong(int index, long value) Sets the long value at the given write index in this buffer's backing data store.setReadOffset(int value) Sets the read offset for this buffer.setShort(int index, short value) Sets the short value at the given write index in this buffer's backing data store.setWriteOffset(int value) Sets the write offset for this buffer.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.toString()inttransferFrom(FileChannel channel, long position, int length) Reads a sequence of bytes from the given channel into this buffer.inttransferFrom(ReadableByteChannel channel, int length) Reads a sequence of bytes from the given channel into this buffer.protected ProtonBufferinttransferTo(WritableByteChannel channel, int length) Read from this buffer and write to the given channel.unwrap()Return the underlying buffer object that backs thisProtonBufferinstance, or self if there is no backing object.intReturns the number of writable constituent buffer components that are contained in this buffer instance which for a non-composite buffer will always be zero or one (namely itself).writeByte(byte value) Writes a single byte to the buffer and advances the write index by one.writeBytes(byte[] source, int offset, int length) Writes into this buffer, the given number of bytes from the byte array.writeBytes(ProtonBuffer source) Writes into this buffer, all the readable bytes from the given buffer.writeChar(char value) Writes a single character to the buffer and advances the write index by four.writeInt(int value) Writes a single integer to the buffer and advances the write index by four.writeLong(long value) Writes a single long to the buffer and advances the write index by eight.writeShort(short value) Writes a single short to the buffer and advances the write index by two.Methods inherited from class org.apache.qpid.protonj2.resource.SharedResourceacquire, close, isClosed, isShared, transferMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.qpid.protonj2.buffer.ProtonBufferbufferIterator, bufferReverseIterator, clear, close, compareTo, getReadableBytes, getWritableBytes, indexOf, isClosed, isReadable, isWritable, readCharSequence, toString, writeCharSequenceMethods inherited from interface org.apache.qpid.protonj2.buffer.ProtonBufferAccessorsgetBoolean, getDouble, getFloat, getUnsignedByte, getUnsignedInt, getUnsignedShort, readBoolean, readDouble, readFloat, readUnsignedByte, readUnsignedInt, readUnsignedShort, setBoolean, setDouble, setFloat, setUnsignedByte, setUnsignedInt, setUnsignedShort, writeBoolean, writeDouble, writeFloat, writeUnsignedByte, writeUnsignedInt, writeUnsignedShortMethods inherited from interface org.apache.qpid.protonj2.buffer.ProtonCompositeBufferadvanceReadOffset, advanceWriteOffset, copy, copy, copy, ensureWritable, readBytes, readBytes, readSplit, split, writeBytes, writeBytes, writeSplit
- 
Constructor Details- 
ProtonCompositeBufferImplCreates a new empty composite buffer.- Parameters:
- allocator- the allocator that created this composite buffer.
 
 
- 
- 
Method Details- 
allocator- Returns:
- this buffer's allocator which was assigned on create.
 
- 
isDirectpublic boolean isDirect()- Specified by:
- isDirectin interface- ProtonBuffer
- Returns:
- true if the buffer is backed by native memory.
 
- 
convertToReadOnlyDescription 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
- Specified by:
- convertToReadOnlyin interface- ProtonCompositeBuffer
- Returns:
- this buffer for use in chaining.
 
- 
implicitGrowthLimitpublic int implicitGrowthLimit()Description copied from interface:ProtonBufferReturns 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. - Specified by:
- implicitGrowthLimitin interface- ProtonBuffer
- Returns:
- the number of bytes this buffer can currently grow to..
 
- 
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
- Specified by:
- implicitGrowthLimitin interface- ProtonCompositeBuffer
- Parameters:
- limit- The limit to assign as the maximum capacity this buffer can grow
- Returns:
- this buffer for using in call chaining.
 
- 
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
- Specified by:
- fillin interface- ProtonCompositeBuffer
- Parameters:
- value- The byte value to assign each byte in this buffer.
- Returns:
- this ProtonBuffer for chaining.
 
- 
isCompositepublic boolean isComposite()- Specified by:
- isCompositein interface- ProtonBuffer
- Returns:
- true if the buffer is backed by one or more ProtonBufferinstances.
 
- 
componentCountpublic int componentCount()Description copied from interface:ProtonBufferReturns the number of constituent buffer components that are contained in this buffer instance which for a non-composite buffer will always be one (namely itself). For a composite buffer this count is the total count of all buffers mapped to the composite.- Specified by:
- componentCountin interface- ProtonBuffer
- Returns:
- the number of buffers managed by this ProtonBufferinstance.
 
- 
readableComponentCountpublic int readableComponentCount()Description copied from interface:ProtonBufferReturns the number of readable constituent buffer components that are contained in this buffer instance which for a non-composite buffer will always be zero or one (namely itself). For a composite buffer this count is the total count of all buffers mapped to the composite which are readable.- Specified by:
- readableComponentCountin interface- ProtonBuffer
- Returns:
- the number of readable buffers managed by this ProtonBufferinstance.
 
- 
writableComponentCountpublic int writableComponentCount()Description copied from interface:ProtonBufferReturns the number of writable constituent buffer components that are contained in this buffer instance which for a non-composite buffer will always be zero or one (namely itself). For a composite buffer this count is the total count of all buffers mapped to the composite which are writable.- Specified by:
- writableComponentCountin interface- ProtonBuffer
- Returns:
- the number of writable buffer components managed by this ProtonBufferinstance.
 
- 
isReadOnlypublic boolean isReadOnly()- Specified by:
- isReadOnlyin interface- ProtonBuffer
- Returns:
- whether this buffer instance is read-only or not.
 
- 
capacitypublic int capacity()- Specified by:
- capacityin interface- ProtonBuffer
- Returns:
- the number of bytes this buffer can currently contain.
 
- 
unwrapDescription copied from interface:ProtonBufferReturn the underlying buffer object that backs thisProtonBufferinstance, or self if there is no backing object. This method should be overridden in buffer abstraction when access to the underlying backing store is needed such as when wrapping pooled resources that need explicit release calls.- Specified by:
- unwrapin interface- ProtonBuffer
- Returns:
- an underlying buffer object or other backing store for this buffer.
 
- 
getReadOffsetpublic int getReadOffset()- Specified by:
- getReadOffsetin interface- ProtonBuffer
- Returns:
- the current value of the read offset for this buffer.
 
- 
setReadOffsetDescription copied from interface:ProtonBufferSets the read offset for this buffer.- Specified by:
- setReadOffsetin interface- ProtonBuffer
- Specified by:
- setReadOffsetin interface- ProtonCompositeBuffer
- Parameters:
- value- The offset into the buffer where the read offset should be positioned.
- Returns:
- this buffer for use in chaining.
 
- 
getWriteOffsetpublic int getWriteOffset()- Specified by:
- getWriteOffsetin interface- ProtonBuffer
- Returns:
- the current value of the write offset for this buffer.
 
- 
setWriteOffsetDescription copied from interface:ProtonBufferSets the write offset for this buffer.- Specified by:
- setWriteOffsetin interface- ProtonBuffer
- Specified by:
- setWriteOffsetin interface- ProtonCompositeBuffer
- Parameters:
- value- The offset into the buffer where the write offset should be positioned.
- Returns:
- this buffer for use in chaining.
 
- 
compactDescription 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
- Specified by:
- compactin interface- ProtonCompositeBuffer
- Returns:
- this buffer for using in call chaining.
 
- 
copyIntopublic void copyInto(int offset, byte[] destination, int destOffset, int length) Description copied from interface:ProtonBufferCopies the given number of bytes from this buffer into the specified target byte array starting at the given offset into this buffer. The copied region is written into the target starting at the given offset and continues for the specified length of elements.- Specified by:
- copyIntoin interface- ProtonBuffer
- Parameters:
- offset- The offset into this buffer where the copy begins from.
- destination- The destination byte array where the copied bytes are written.
- destOffset- The offset into the destination to begin writing the copied bytes.
- length- The number of bytes to copy into the destination.
 
- 
copyIntoDescription copied from interface:ProtonBufferCopies the given number of bytes from this buffer into the specified targetByteBufferstarting at the given offset into this buffer. The copied region is written into the target starting at the given offset and continues for the specified length of elements.- Specified by:
- copyIntoin interface- ProtonBuffer
- Parameters:
- offset- The offset into this buffer where the copy begins from.
- destination- The destination- ByteBufferwhere the copied bytes are written.
- destOffset- The offset into the destination to begin writing the copied bytes.
- length- The number of bytes to copy into the destination.
 
- 
copyIntoDescription copied from interface:ProtonBufferCopies the given number of bytes from this buffer into the specified targetProtonBufferstarting at the given offset into this buffer. The copied region is written into the target starting at the given offset and continues for the specified length of elements.- Specified by:
- copyIntoin interface- ProtonBuffer
- Parameters:
- offset- The offset into this buffer where the copy begins from.
- destination- The destination- ProtonBufferwhere the copied bytes are written.
- destOffset- The offset into the destination to begin writing the copied bytes.
- length- The number of bytes to copy into the destination.
 
- 
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
- Specified by:
- writeBytesin interface- ProtonCompositeBuffer
- 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, 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
- Specified by:
- writeBytesin interface- ProtonCompositeBuffer
- Parameters:
- source- The buffer to read from.
- Returns:
- This buffer.
 
- 
appendDescription copied from interface:ProtonCompositeBufferAppends the given buffer to this composite buffer if all the constraints on buffer composites are met, otherwise thrown an exception.- Specified by:
- appendin interface- ProtonCompositeBuffer
- Parameters:
- buffer- The buffer to append to this composite collection of buffers.
- Returns:
- this composite buffer instance.
 
- 
decomposeBufferDescription copied from interface:ProtonCompositeBufferSplits 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..- Specified by:
- decomposeBufferin interface- ProtonCompositeBuffer
- Returns:
- the collection of buffers that comprised this composite buffer.
 
- 
ensureWritablepublic ProtonCompositeBuffer 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
- Specified by:
- ensureWritablein interface- ProtonCompositeBuffer
- 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.
 
- 
copypublic ProtonCompositeBuffer copy(int index, int length, boolean readOnly) throws IllegalArgumentException Description 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
- Specified by:
- copyin interface- ProtonCompositeBuffer
- 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.
 
- 
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
- Specified by:
- splitin interface- ProtonCompositeBuffer
- Parameters:
- splitOffset- The offset in this buffer where the split should occur.
- Returns:
- A new buffer that owns the memory spanning the range given.
 
- 
splitComponentsFloorDescription copied from interface:ProtonCompositeBufferSplit 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.- Specified by:
- splitComponentsFloorin interface- ProtonCompositeBuffer
- 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.
 
- 
splitComponentsCeilDescription copied from interface:ProtonCompositeBufferSplit 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.- Specified by:
- splitComponentsCeilin interface- ProtonCompositeBuffer
- 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.
 
- 
getBytepublic byte getByte(int index) Description copied from interface:ProtonBufferAccessorsReads a single byte at the given index and returns it without modification to the target buffer read offset.- Specified by:
- getBytein interface- ProtonBufferAccessors
- Parameters:
- index- The index into the buffer where the value should be read.
- Returns:
- the value read from the given index.
 
- 
getCharpublic char getChar(int index) Description copied from interface:ProtonBufferAccessorsGets a 2-byte char from the specified index, this method will not modify the read or write index.- Specified by:
- getCharin interface- ProtonBufferAccessors
- Parameters:
- index- The index into the buffer where the value should be read.
- Returns:
- the value read from the given index.
 
- 
getShortpublic short getShort(int index) Description copied from interface:ProtonBufferAccessorsGets a short from the specified index, this method will not modify the read or write index.- Specified by:
- getShortin interface- ProtonBufferAccessors
- Parameters:
- index- The index into the buffer where the value should be read.
- Returns:
- the value read from the given index.
 
- 
getIntpublic int getInt(int index) Description copied from interface:ProtonBufferAccessorsGets a int from the specified index, this method will not modify the read or write index.- Specified by:
- getIntin interface- ProtonBufferAccessors
- Parameters:
- index- The index into the buffer where the value should be read.
- Returns:
- the value read from the given index.
 
- 
getLongpublic long getLong(int index) Description copied from interface:ProtonBufferAccessorsGets a long from the specified index, this method will not modify the read or write index.- Specified by:
- getLongin interface- ProtonBufferAccessors
- Parameters:
- index- The index into the buffer where the value should be read.
- Returns:
- the value read from the given index.
 
- 
setByteDescription copied from interface:ProtonBufferAccessorsSets the byte value at the given write index in this buffer's backing data store.- Specified by:
- setBytein interface- ProtonBufferAccessors
- Parameters:
- index- The index to start the write from.
- value- The value to write at the given index.
- Returns:
- a reference to this ProtonBuffer for chaining.
 
- 
setCharDescription copied from interface:ProtonBufferAccessorsSets the char value at the given write index in this buffer's backing data store.- Specified by:
- setCharin interface- ProtonBufferAccessors
- Parameters:
- index- The index to start the write from.
- value- The value to write at the given index.
- Returns:
- a reference to this ProtonBuffer for chaining.
 
- 
setShortDescription copied from interface:ProtonBufferAccessorsSets the short value at the given write index in this buffer's backing data store.- Specified by:
- setShortin interface- ProtonBufferAccessors
- Parameters:
- index- The index to start the write from.
- value- The value to write at the given index.
- Returns:
- a reference to this ProtonBuffer for chaining.
 
- 
setIntDescription copied from interface:ProtonBufferAccessorsSets the int value at the given write index in this buffer's backing data store.- Specified by:
- setIntin interface- ProtonBufferAccessors
- Parameters:
- index- The index to start the write from.
- value- The value to write at the given index.
- Returns:
- a reference to this ProtonBuffer for chaining.
 
- 
setLongDescription copied from interface:ProtonBufferAccessorsSets the long value at the given write index in this buffer's backing data store.- Specified by:
- setLongin interface- ProtonBufferAccessors
- Parameters:
- index- The index to start the write from.
- value- The value to write at the given index.
- Returns:
- a reference to this ProtonBuffer for chaining.
 
- 
readBytepublic byte readByte()Description copied from interface:ProtonBufferAccessorsReads one byte from the buffer and advances the read index by one.- Specified by:
- readBytein interface- ProtonBufferAccessors
- Returns:
- a single byte from the ProtonBuffer.
 
- 
readCharpublic char readChar()Description copied from interface:ProtonBufferAccessorsReads a character value from the buffer and advances the read index by four.- Specified by:
- readCharin interface- ProtonBufferAccessors
- Returns:
- char value read from the buffer.
 
- 
readShortpublic short readShort()Description copied from interface:ProtonBufferAccessorsReads a short value from the buffer and advances the read index by two.- Specified by:
- readShortin interface- ProtonBufferAccessors
- Returns:
- short value read from the buffer.
 
- 
readIntpublic int readInt()Description copied from interface:ProtonBufferAccessorsReads a integer value from the buffer and advances the read index by four.- Specified by:
- readIntin interface- ProtonBufferAccessors
- Returns:
- integer value read from the buffer.
 
- 
readLongpublic long readLong()Description copied from interface:ProtonBufferAccessorsReads a long value from the buffer and advances the read index by eight.- Specified by:
- readLongin interface- ProtonBufferAccessors
- Returns:
- long value read from the buffer.
 
- 
writeByteDescription copied from interface:ProtonBufferAccessorsWrites a single byte to the buffer and advances the write index by one.- Specified by:
- writeBytein interface- ProtonBufferAccessors
- Parameters:
- value- The byte to write into the buffer.
- Returns:
- this ProtonBuffer for chaining.
 
- 
writeCharDescription copied from interface:ProtonBufferAccessorsWrites a single character to the buffer and advances the write index by four.- Specified by:
- writeCharin interface- ProtonBufferAccessors
- Parameters:
- value- The char to write into the buffer.
- Returns:
- this ProtonBuffer for chaining.
 
- 
writeShortDescription copied from interface:ProtonBufferAccessorsWrites a single short to the buffer and advances the write index by two.- Specified by:
- writeShortin interface- ProtonBufferAccessors
- Parameters:
- value- The short to write into the buffer.
- Returns:
- this ProtonBuffer for chaining.
 
- 
writeIntDescription copied from interface:ProtonBufferAccessorsWrites a single integer to the buffer and advances the write index by four.- Specified by:
- writeIntin interface- ProtonBufferAccessors
- Parameters:
- value- The integer to write into the buffer.
- Returns:
- this ProtonBuffer for chaining.
 
- 
writeLongDescription copied from interface:ProtonBufferAccessorsWrites a single long to the buffer and advances the write index by eight.- Specified by:
- writeLongin interface- ProtonBufferAccessors
- Parameters:
- value- The long to write into the buffer.
- Returns:
- this ProtonBuffer for chaining.
 
- 
equals
- 
hashCodepublic int hashCode()
- 
toString
- 
transferToDescription copied from interface:ProtonBufferRead from this buffer and write to the given channel.The number of bytes actually written to the channel are returned. No more than the given lengthof bytes, or the number of readable bytes, will be written to the channel, whichever is smaller. A channel that has a position marker, will be advanced by the number of bytes written. The read offset of this buffer will also be advanced by the number of bytes written.- Specified by:
- transferToin interface- ProtonBuffer
- Parameters:
- channel- The channel to write to.
- length- The maximum number of bytes to write.
- Returns:
- The actual number of bytes written, possibly zero.
- Throws:
- IOException- If the write-operation on the channel failed for some reason.
 
- 
transferFromDescription copied from interface:ProtonBufferReads a sequence of bytes from the given channel into this buffer.The method reads a given amount of bytes from the provided channel and returns the number of bytes actually read which can be zero or -1 if the channel has reached the end of stream state. The length value given is a maximum limit however the code will adjust this if the number of writable bytes in this buffer is smaller (or zero) and the result will indicate how many bytes where actually read. The write offset of this buffer will be advanced by the number of bytes read from the buffer as will the channel position index if one exists. - Specified by:
- transferFromin interface- ProtonBuffer
- Parameters:
- channel- The readable byte channel where the bytes are read
- length- The maximum number of bytes to read from the channel
- Returns:
- The number of bytes read, possibly zero, or -1 if the channel has reached end-of-stream
- Throws:
- IOException- if the read operation fails
 
- 
transferFromDescription copied from interface:ProtonBufferReads a sequence of bytes from the given channel into this buffer.The method reads a given amount of bytes from the provided channel and returns the number of bytes actually read which can be zero or -1 if the channel has reached the end of stream state. The length value given is a maximum limit however the code will adjust this if the number of writable bytes in this buffer is smaller (or zero) and the result will indicate how many bytes where actually read. The write offset of this buffer will be advanced by the number of bytes read from the buffer, the channel will not have its position modified. - Specified by:
- transferFromin interface- ProtonBuffer
- Parameters:
- channel- The File channel where the bytes are read
- position- The position in the channel where the read should begin
- length- The maximum number of bytes to read from the channel
- Returns:
- The number of bytes read, possibly zero, or -1 if the channel has reached end-of-stream
- Throws:
- IOException- if the read operation fails
 
- 
bufferIteratorDescription copied from interface:ProtonBufferCreates and returns a newProtonBufferIteratorthat iterates from the given offset and continues until specified number of bytes has been traversed. The source buffer read and write offsets are not modified by an iterator instance.The caller must ensure that the source buffer lifetime extends beyond the lifetime of the returned ProtonBufferIterator.- Specified by:
- bufferIteratorin interface- ProtonBuffer
- Parameters:
- offset- The offset into the buffer where iteration begins
- length- The number of bytes to iterate over.
- Returns:
- a new buffer iterator that iterates over the readable bytes.
 
- 
bufferReverseIteratorDescription copied from interface:ProtonBufferCreates and returns a newProtonBufferIteratorthat reverse iterates from the given offset and continues until specified number of bytes has been traversed. The source buffer read and write offsets are not modified by an iterator instance.The caller must ensure that the source buffer lifetime extends beyond the lifetime of the returned ProtonBufferIterator.- Specified by:
- bufferReverseIteratorin interface- ProtonBuffer
- Parameters:
- offset- The offset into the buffer where iteration begins
- length- The number of bytes to iterate over.
- Returns:
- a new buffer iterator that iterates over the readable bytes.
 
- 
indexOfpublic int indexOf(byte needle, int offset, int length) Description copied from interface:ProtonBufferStarting from the given offset into this buffer, find the next offset (index) in the buffer where the given value is located or-1if the value is not found by the time the specified number of bytes has been searched. This method does not affect the read or write offset and can be called from any point in the buffer regardless of the current read or write offsets. The search bounds are that of the buffer's readable bytes meaning that the starting office cannot be less than the read offset and the length cannot cause the search to read past the readable bytes otherwise anIndexOutOfBoundsExceptionwill be thrown.- Specified by:
- indexOfin interface- ProtonBuffer
- Parameters:
- needle- The byte value to search for in the remaining buffer bytes.
- offset- The offset into the buffer where the search should begin from.
- length- The offset into the buffer where the search should begin from.
- Returns:
- the location in the buffer where the value was found or -1if not found.
 
- 
componentAccessorDescription copied from interface:ProtonBufferReturns a component access object that can be used to gain access to the constituent buffer components for use in IO operations or other lower level buffer operations that need to work on single compoents.The general usage of the component access object should be within a try-with-resource block as follows: try (ProtonBufferComponentAccessor accessor = buffer.componentAccessor()) { for (ProtonBufferComponent component : accessor.readableComponents()) { // Access logic here.... } }- Specified by:
- componentAccessorin interface- ProtonBuffer
- Returns:
- a component access object instance used to view the buffer internal components
 
- 
createCreate an emptyProtonCompositeBufferwith the given allocator which will be used any time the buffer needs to allocate additional storage space for implicit write or explicit ensure writable calls.- Parameters:
- allocator- the allocator to use when expanding capacity
- Returns:
- a new ProtonCompositeBufferthat uses the provided allocator
 
- 
createCreate an emptyProtonCompositeBufferwith the given allocator which will be used any time the buffer needs to allocate additional storage space for implicit write or explicit ensure writable calls.- Parameters:
- allocator- the allocator to use when expanding capacity.
- buffers- the sequence of buffers to compose.
- Returns:
- a new ProtonCompositeBufferthat uses the provided allocator
 
- 
createCreate an emptyProtonCompositeBufferwith the given allocator which will be used any time the buffer needs to allocate additional storage space for implicit write or explicit ensure writable calls.- Parameters:
- allocator- the allocator to use when expanding capacity.
- buffer- the buffers to compose.
- Returns:
- a new ProtonCompositeBufferthat uses the provided allocator
 
- 
releaseResourceOwnershipprotected void releaseResourceOwnership()- Specified by:
- releaseResourceOwnershipin class- SharedResource<ProtonBuffer>
 
- 
transferTheResource- Specified by:
- transferTheResourcein class- SharedResource<ProtonBuffer>
 
- 
resourceIsClosedException- Specified by:
- resourceIsClosedExceptionin class- SharedResource<ProtonBuffer>
 
 
-