Top Description Methods
io.netty5.buffer

public Interface BufferComponent

Known Direct Implementers
io.netty5.buffer.DefaultCompositeBuffer.NextComponent, io.netty5.buffer.bytebuffer.NioBuffer, io.netty5.buffer.unsafe.UnsafeBuffer
Imports
java.nio.ByteBuffer

A view onto the buffer component being processed in a given iteration of Buffer#forEachComponent().

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

The base native memory address, if any, otherwise 0.
baseNativeAddress
()

Give the base native memory address backing this buffer, or return 0 if this buffer has no native memory address.

public boolean

Returns:

true if readableArray() is a cheap operation, otherwise false.
hasReadableArray
()

Check if this component is backed by a cached byte array that can be accessed cheaply.

public boolean

Returns:

true if writableArray() is a cheap operation, otherwise false.
hasWritableArray
()

Check if this component is backed by a cached byte array that can be accessed cheaply.

public ByteCursor

Returns:

A ByteCursor for iterating the readable bytes of this buffer.
openCursor
()

Open a cursor to iterate the readable bytes of this component.

public byte[]

Returns:

A byte array of the contents of this component.
readableArray
()

Get a byte array of the contents of this component.

public int

Returns:

The number of bytes, from the readableArrayOffset() into the readableArray(), that belong to this component.
readableArrayLength
()

The number of bytes in the readableArray() that belong to this component.

public int

Returns:

An offset into readableArray().
readableArrayOffset
()

An offset into the readableArray() where this component starts.

public ByteBuffer

Returns:

A new ByteBuffer, with its own position and limit, for this memory component.
readableBuffer
()

Get a ByteBuffer instance for this memory component.

public int

Returns:

The number of bytes that can be read from this readable component.
readableBytes
()

Get the number of readable bytes from this component.

public long

Returns:

The readable native memory address, if any, otherwise 0.
readableNativeAddress
()

Give the native memory address backing this buffer, or return 0 if this buffer has no native memory address.

public BufferComponent

Returns:

itself.
skipReadableBytes
(int
The number of bytes read from this component.
byteCount
)

Move the read-offset to indicate that the given number of bytes were read from this component.

public BufferComponent

Returns:

itself.
skipWritableBytes
(int
The number of bytes written to this component.
byteCount
)

Move the write-offset to indicate that the given number of bytes were written to this component.

public byte[]

Returns:

A byte array of the contents of this component.
writableArray
()

Get a byte array of the contents of this component.

public int

Returns:

The number of bytes, from the writableArrayOffset() into the writableArray(), that belong to this component.
writableArrayLength
()

The number of bytes in the writableArray() that belong to this component.

public int

Returns:

An offset into writableArray().
writableArrayOffset
()

An offset into the writableArray() where this component starts.

public ByteBuffer

Returns:

A new ByteBuffer, with its own position and limit, for this memory component.
writableBuffer
()

Get a ByteBuffer instance for this memory component, which can be used for modifying the buffer contents.

public int

Returns:

The maximum number of bytes that can be written to this component.
writableBytes
()

Get the space available to be written to this component, as a number of bytes.

public long

Returns:

The writable native memory address, if any, otherwise 0.
writableNativeAddress
()

Give the native memory address backing this buffer, or return 0 if this buffer has no native memory address.

Method Detail

baseNativeAddressback to summary
public 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 the writableNativeAddress().

Note

that the address should not be used for reading or writing. It should only be used for offset calculations.

Returns:long

The base native memory address, if any, otherwise 0.

hasReadableArrayback to summary
public 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:boolean

true if readableArray() is a cheap operation, otherwise false.

hasWritableArrayback to summary
public boolean hasWritableArray()

Check if this component is backed by a cached byte array that can be accessed cheaply.

Returns:boolean

true if writableArray() is a cheap operation, otherwise false.

openCursorback to summary
public 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() and Buffer#writerOffset()) are not modified while the iteration takes place. Otherwise, unpredictable behaviour might result.

Returns:ByteCursor

A ByteCursor for iterating the readable bytes of this buffer.

See Also
Buffer#openCursor()
readableArrayback to summary
public 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:byte[]

A byte array of the contents of this component.

Exceptions
UnsupportedOperationException:
if hasReadableArray() returns false.
See Also
readableArrayOffset(), readableArrayLength()
readableArrayLengthback to summary
public int readableArrayLength()

The number of bytes in the readableArray() that belong to this component.

Returns:int

The number of bytes, from the readableArrayOffset() into the readableArray(), that belong to this component.

Exceptions
UnsupportedOperationException:
if hasReadableArray() returns false.
readableArrayOffsetback to summary
public int readableArrayOffset()

An offset into the readableArray() where this component starts.

Returns:int

An offset into readableArray().

Exceptions
UnsupportedOperationException:
if hasReadableArray() returns false.
readableBufferback to summary
public ByteBuffer readableBuffer()

Get a ByteBuffer 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 through Buffer#forEachComponent().

Returns:ByteBuffer

A new ByteBuffer, with its own position and limit, for this memory component.

readableBytesback to summary
public int readableBytes()

Get the number of readable bytes from this component.

Returns:int

The number of bytes that can be read from this readable component.

readableNativeAddressback to summary
public 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:long

The readable native memory address, if any, otherwise 0.

skipReadableBytesback to summary
public BufferComponent skipReadableBytes(int byteCount)

Move the read-offset to indicate that the given number of bytes were read from this component.

Parameters
byteCount:int

The number of bytes read from this component.

Returns:BufferComponent

itself.

See Also
Buffer#skipReadableBytes(int)
skipWritableBytesback to summary
public BufferComponent skipWritableBytes(int byteCount)

Move the write-offset to indicate that the given number of bytes were written to this component.

Parameters
byteCount:int

The number of bytes written to this component.

Returns:BufferComponent

itself.

See Also
Buffer#skipWritableBytes(int)
writableArrayback to summary
public byte[] writableArray()

Get a byte array of the contents of this component.

Returns:byte[]

A byte array of the contents of this component.

Exceptions
UnsupportedOperationException:
if hasWritableArray() returns false.
See Also
writableArrayOffset(), writableArrayLength()
writableArrayLengthback to summary
public int writableArrayLength()

The number of bytes in the writableArray() that belong to this component.

Returns:int

The number of bytes, from the writableArrayOffset() into the writableArray(), that belong to this component.

Exceptions
UnsupportedOperationException:
if hasWritableArray() returns false.
writableArrayOffsetback to summary
public int writableArrayOffset()

An offset into the writableArray() where this component starts.

Returns:int

An offset into writableArray().

Exceptions
UnsupportedOperationException:
if hasWritableArray() returns false.
writableBufferback to summary
public ByteBuffer writableBuffer()

Get a ByteBuffer instance for this memory component, which can be used for modifying the buffer contents.

Returns:ByteBuffer

A new ByteBuffer, with its own position and limit, for this memory component.

writableBytesback to summary
public int writableBytes()

Get the space available to be written to this component, as a number of bytes.

Returns:int

The maximum number of bytes that can be written to this component.

writableNativeAddressback to summary
public long writableNativeAddress()

Give the native memory address backing this buffer, or return 0 if this buffer has no native memory address.

Returns:long

The writable native memory address, if any, otherwise 0.