-
public interface ReadableComponent
A view onto the buffer component being processed in a given iteration ofBuffer.forEachReadable(int, ReadableComponentProcessor)
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
hasReadableArray()
Check if this component is backed by a cached byte array that can be accessed cheaply.ByteCursor
openCursor()
Open a cursor to iterate the readable bytes of this component.byte[]
readableArray()
Get a byte array of the contents of this component.int
readableArrayLength()
The number of bytes in thereadableArray()
that belong to this component.int
readableArrayOffset()
An offset into thereadableArray()
where this component starts.ByteBuffer
readableBuffer()
Get aByteBuffer
instance for this memory component.int
readableBytes()
Get the number of readable bytes from this component.long
readableNativeAddress()
Give the native memory address backing this buffer, or return 0 if this buffer has no native memory address.ReadableComponent
skipReadableBytes(int byteCount)
Move the read-offset to indicate that the given number of bytes were read from this component.
-
-
-
Method Detail
-
hasReadableArray
boolean hasReadableArray()
Check if this component is backed by a cached byte array that can be accessed cheaply.Note that regardless of what this method returns, the array should not be used to modify the contents of this buffer component.
- Returns:
true
ifreadableArray()
is a cheap operation, otherwisefalse
.
-
readableArray
byte[] readableArray()
Get a byte array of the contents of this component.Note that the array is meant to be read-only. It may either be a direct reference to the concrete array instance that is backing this component, or it is a fresh copy. Writing to the array may produce undefined behaviour.
- Returns:
- A byte array of the contents of this component.
- Throws:
UnsupportedOperationException
- ifhasReadableArray()
returnsfalse
.- See Also:
readableArrayOffset()
,readableArrayLength()
-
readableArrayOffset
int readableArrayOffset()
An offset into thereadableArray()
where this component starts.- Returns:
- An offset into
readableArray()
. - Throws:
UnsupportedOperationException
- ifhasReadableArray()
returnsfalse
.
-
readableArrayLength
int readableArrayLength()
The number of bytes in thereadableArray()
that belong to this component.- Returns:
- The number of bytes, from the
readableArrayOffset()
into thereadableArray()
, that belong to this component. - Throws:
UnsupportedOperationException
- ifhasReadableArray()
returnsfalse
.
-
readableNativeAddress
long readableNativeAddress()
Give the native memory address backing this buffer, or return 0 if this buffer has no native memory address.Note that the address should not be used for writing to the buffer memory, and doing so may produce undefined behaviour.
- Returns:
- The native memory address, if any, otherwise 0.
-
readableBuffer
ByteBuffer readableBuffer()
Get aByteBuffer
instance for this memory component.Note that the
ByteBuffer
is read-only, to prevent write accesses to the memory, when the buffer component is obtained throughBuffer.forEachReadable(int, ReadableComponentProcessor)
.- Returns:
- A new
ByteBuffer
, with its own position and limit, for this memory component.
-
readableBytes
int readableBytes()
Get the number of readable bytes from this component.- Returns:
- The number of bytes that can be read from this readable component.
-
openCursor
ByteCursor openCursor()
Open a cursor to iterate the readable bytes of this component. Any offsets internal to the component are not modified by the cursor.Care should be taken to ensure that the buffers lifetime extends beyond the cursor and the iteration, and that the internal offsets of the component (such as
Buffer.readerOffset()
andBuffer.writerOffset()
) are not modified while the iteration takes place. Otherwise, unpredictable behaviour might result.- Returns:
- A
ByteCursor
for iterating the readable bytes of this buffer. - See Also:
Buffer.openCursor()
-
skipReadableBytes
ReadableComponent skipReadableBytes(int byteCount)
Move the read-offset to indicate that the given number of bytes were read from this component.- Parameters:
byteCount
- The number of bytes read from this component.- Returns:
- itself.
- See Also:
Buffer.skipReadableBytes(int)
-
-