Package org.apache.qpid.protonj2.buffer
Interface ProtonBufferComponent
- All Known Implementing Classes:
- Netty4ToProtonBufferAdapter,- Netty5ToProtonBufferAdapter,- ProtonByteArrayBuffer
public interface ProtonBufferComponent
A buffer component represents a single component of the memory backing
 a 
ProtonBuffer which could be a buffer that inherently made up of more
 than one section of memory or it could be a intentional composite buffer
 that collect individual buffers each with their own component backing.- 
Method SummaryModifier and TypeMethodDescriptionadvanceReadOffset(int amount) Advances the internally maintained read offset for this component by the given amount.advanceWriteOffset(int amount) Advances the internally maintained write offset for this component by the given amount.Creates and returns a newProtonBufferIteratorthat iterates from the current read offset and continues until all readable bytes have been traversed.longGets the native address of the backing buffer if one exists otherwise returns 0.longGets the native address where reads from this buffer component should start.longGets the native address where write to this buffer component should start.byte[]Returns the readable array if one exists or throws an exception.intintReturns the readable array if one exists or throws an exception.intReturns the number of readable bytes in the buffer safely regards of the actual memory backing this component.byte[]Returns the writable array if one exists or throws an exception.intintReturns the writableByteBufferif one exists or throws an exception.intReturns the number of writable bytes in the buffer safely regards of the actual memory backing this component.booleanbooleanunwrap()Unwraps the backing resource of this buffer component which can be an external buffer type or other managed resource.
- 
Method Details- 
unwrapObject unwrap()Unwraps the backing resource of this buffer component which can be an external buffer type or other managed resource.- Returns:
- the resource backing this component or null if none exists.
 
- 
getReadableBytesint getReadableBytes()Returns the number of readable bytes in the buffer safely regards of the actual memory backing this component.- Returns:
- the number of readable bytes in this buffer component
 
- 
hasReadbleArrayboolean hasReadbleArray()- Returns:
- true if the component is backed by a byte array that has a readable portion.
 
- 
advanceReadOffsetAdvances the internally maintained read offset for this component by the given amount. If the amount to advance is greater than the available readable bytes an exception is thrown.- Parameters:
- amount- The amount to advance the read offset of this component by.
- Returns:
- this ProtonBufferComponentinstance.
- Throws:
- UnsupportedOperationException- if the component is not backed by a readable array.
 
- 
getReadableArraybyte[] getReadableArray()Returns the readable array if one exists or throws an exception.- Returns:
- the readable array that backs this buffer component.
- Throws:
- UnsupportedOperationException- if the component is not backed by an array or has no readable bytes.
 
- 
getReadableArrayOffsetint getReadableArrayOffset()- Returns:
- the offset into the readable array where the readable bytes begin.
- Throws:
- UnsupportedOperationException- if the component is not backed by a readable array.
 
- 
getReadableArrayLengthint getReadableArrayLength()- Returns:
- the length of the readable array from the offset that is owned by this component..
- Throws:
- UnsupportedOperationException- if the component is not backed by a readable array.
 
- 
getReadableBufferByteBuffer getReadableBuffer()Returns the readable array if one exists or throws an exception.- Returns:
- the readable array that backs this buffer component.
- Throws:
- UnsupportedOperationException- if the component does not contain a readable portion.
 
- 
getWritableBytesint getWritableBytes()Returns the number of writable bytes in the buffer safely regards of the actual memory backing this component.- Returns:
- the number of writable bytes in this buffer component
 
- 
advanceWriteOffsetAdvances the internally maintained write offset for this component by the given amount. If the amount to advance is greater than the available writable bytes an exception is thrown.- Parameters:
- amount- The amount to advance the write offset of this component by.
- Returns:
- this ProtonBufferComponentinstance.
- Throws:
- UnsupportedOperationException- if the component is not backed by a writable array.
 
- 
hasWritableArrayboolean hasWritableArray()- Returns:
- true if the component is backed by a byte array that has writable bytes.
 
- 
getWritableArraybyte[] getWritableArray()Returns the writable array if one exists or throws an exception.- Returns:
- the writable array that backs this buffer component.
- Throws:
- UnsupportedOperationException- if the component is not backed by an writable array.
 
- 
getWritableArrayOffsetint getWritableArrayOffset()- Returns:
- the offset into the writable array where the writable bytes begin.
- Throws:
- UnsupportedOperationException- if the component is not backed by a writable array.
 
- 
getWritableArrayLengthint getWritableArrayLength()- Returns:
- the length of the writable array from the offset that is owned by this component..
- Throws:
- UnsupportedOperationException- if the component is not backed by a writable array.
 
- 
getWritableBufferByteBuffer getWritableBuffer()Returns the writableByteBufferif one exists or throws an exception.- Returns:
- the writable buffer that backs this buffer component.
- Throws:
- UnsupportedOperationException- if the component does not contain a writable portion.
 
- 
bufferIteratorProtonBufferIterator bufferIterator()Creates and returns a newProtonBufferIteratorthat iterates from the current read offset and continues until all readable bytes have 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.- Returns:
- a new buffer iterator that iterates over the readable bytes.
 
- 
getNativeAddresslong getNativeAddress()Gets the native address of the backing buffer if one exists otherwise returns 0.The returned address is the base address for the memory region that back this buffer which should not be used for reads and write as the backing region could be larger and not all portions of the backing region might be owned by this buffer component. The caller should use the methods getNativeReadAddress()andgetNativeWriteAddress()which each use this method to compute where these value actually fall in the native memory region.- Returns:
- The native memory address for the region backing this buffer, if any, otherwise 0.
 
- 
getNativeReadAddresslong getNativeReadAddress()Gets the native address where reads from this buffer component should start.- Returns:
- The native memory address where reads start, if any, otherwise 0.
 
- 
getNativeWriteAddresslong getNativeWriteAddress()Gets the native address where write to this buffer component should start.- Returns:
- The native memory address where writing should start, if any, otherwise 0.
 
 
-