-
public interface BufferComponentA view onto the buffer component being processed in a given iteration ofBuffer.forEachComponent().
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description longbaseNativeAddress()Give the base native memory address backing this buffer, or return 0 if this buffer has no native memory address.booleanhasReadableArray()Check if this component is backed by a cached byte array that can be accessed cheaply.booleanhasWritableArray()Check if this component is backed by a cached byte array that can be accessed cheaply.ByteCursoropenCursor()Open a cursor to iterate the readable bytes of this component.byte[]readableArray()Get a byte array of the contents of this component.intreadableArrayLength()The number of bytes in thereadableArray()that belong to this component.intreadableArrayOffset()An offset into thereadableArray()where this component starts.ByteBufferreadableBuffer()Get aByteBufferinstance for this memory component.intreadableBytes()Get the number of readable bytes from this component.longreadableNativeAddress()Give the native memory address backing this buffer, or return 0 if this buffer has no native memory address.BufferComponentskipReadableBytes(int byteCount)Move the read-offset to indicate that the given number of bytes were read from this component.BufferComponentskipWritableBytes(int byteCount)Move the write-offset to indicate that the given number of bytes were written to this component.byte[]writableArray()Get a byte array of the contents of this component.intwritableArrayLength()The number of bytes in thewritableArray()that belong to this component.intwritableArrayOffset()An offset into thewritableArray()where this component starts.ByteBufferwritableBuffer()Get aByteBufferinstance for this memory component, which can be used for modifying the buffer contents.intwritableBytes()Get the space available to be written to this component, as a number of bytes.longwritableNativeAddress()Give the native memory address backing this buffer, or return 0 if this buffer has no native memory address.
-
-
-
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:
trueifreadableArray()is a cheap operation, otherwisefalse.
-
hasWritableArray
boolean hasWritableArray()
Check if this component is backed by a cached byte array that can be accessed cheaply.- Returns:
trueifwritableArray()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()
-
writableArray
byte[] writableArray()
Get a byte array of the contents of this component.- Returns:
- A byte array of the contents of this component.
- Throws:
UnsupportedOperationException- ifhasWritableArray()returnsfalse.- See Also:
writableArrayOffset(),writableArrayLength()
-
readableArrayOffset
int readableArrayOffset()
An offset into thereadableArray()where this component starts.- Returns:
- An offset into
readableArray(). - Throws:
UnsupportedOperationException- ifhasReadableArray()returnsfalse.
-
writableArrayOffset
int writableArrayOffset()
An offset into thewritableArray()where this component starts.- Returns:
- An offset into
writableArray(). - Throws:
UnsupportedOperationException- ifhasWritableArray()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.
-
writableArrayLength
int writableArrayLength()
The number of bytes in thewritableArray()that belong to this component.- Returns:
- The number of bytes, from the
writableArrayOffset()into thewritableArray(), that belong to this component. - Throws:
UnsupportedOperationException- ifhasWritableArray()returnsfalse.
-
baseNativeAddress
long baseNativeAddress()
Give the base native memory address backing this buffer, or return 0 if this buffer has no native memory address.The base native address, is the address that the buffer components internal read- and write-offsets are relative to, and which is used to compute the
readableNativeAddress()and thewritableNativeAddress().Note that the address should not be used for reading or writing. It should only be used for offset calculations.
- Returns:
- The base native memory address, if any, otherwise 0.
-
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 readable native memory address, if any, otherwise 0.
-
writableNativeAddress
long writableNativeAddress()
Give the native memory address backing this buffer, or return 0 if this buffer has no native memory address.- Returns:
- The writable native memory address, if any, otherwise 0.
-
readableBuffer
ByteBuffer readableBuffer()
Get aByteBufferinstance for this memory component.Note that the
ByteBufferis read-only, to prevent write accesses to the memory, when the buffer component is obtained throughBuffer.forEachComponent().- Returns:
- A new
ByteBuffer, with its own position and limit, for this memory component.
-
writableBuffer
ByteBuffer writableBuffer()
Get aByteBufferinstance for this memory component, which can be used for modifying the buffer contents.- 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.
-
writableBytes
int writableBytes()
Get the space available to be written to this component, as a number of bytes.- Returns:
- The maximum number of bytes that can be written to this 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
ByteCursorfor iterating the readable bytes of this buffer. - See Also:
Buffer.openCursor()
-
skipReadableBytes
BufferComponent 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)
-
skipWritableBytes
BufferComponent skipWritableBytes(int byteCount)
Move the write-offset to indicate that the given number of bytes were written to this component.- Parameters:
byteCount- The number of bytes written to this component.- Returns:
- itself.
- See Also:
Buffer.skipWritableBytes(int)
-
-