Top Description Methods
io.netty5.buffer

public Interface ByteCursor

Known Direct Implementers
io.netty5.buffer.DefaultCompositeBuffer.ForwardCompositeByteCursor, io.netty5.buffer.DefaultCompositeBuffer.ReverseCompositeByteCursor, io.netty5.buffer.bytebuffer.NioBuffer.ForwardNioByteCursor, io.netty5.buffer.bytebuffer.NioBuffer.ReverseNioByteCursor, io.netty5.buffer.unsafe.UnsafeBuffer.ForwardUnsafeByteCursor, io.netty5.buffer.unsafe.UnsafeBuffer.ReverseUnsafeByteCursor
Imports
io.netty5.util.ByteProcessor

The ByteCursor scans through a sequence of bytes. This is similar to ByteProcessor, but for external iteration rather than internal iteration. The external iteration allows the callers to control the pace of the iteration.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

The number of bytes left in the iterator.
bytesLeft
()

Get the current number of bytes left in the iterator.

public int

Returns:

The current iterator offset into the underlying sequence of bytes.
currentOffset
()

The current position of this iterator into the underlying sequence of bytes.

public byte

Returns:

The next byte that was read by the most recent successful call to readByte().
getByte
()

Return the last byte that was read by readByte().

public default int

Returns:

The number of bytes processed, if the process method returned false, or -1 if the whole iterator was processed.
process
(ByteProcessor
The processor to use for processing the bytes in the iterator.
processor
)

Process the remaining bytes in this iterator with the given ByteProcessor.

public boolean

Returns:

true if the cursor read a byte and moved forward, otherwise false.
readByte
()

Check if the iterator has at least one byte left, and if so, read that byte and move the cursor forward.

Method Detail

bytesLeftback to summary
public int bytesLeft()

Get the current number of bytes left in the iterator.

Returns:int

The number of bytes left in the iterator.

currentOffsetback to summary
public int currentOffset()

The current position of this iterator into the underlying sequence of bytes. For instance, if we are iterating a buffer, this would be the iterators current offset into the buffer.

Returns:int

The current iterator offset into the underlying sequence of bytes.

getByteback to summary
public byte getByte()

Return the last byte that was read by readByte(). If readByte() has not been called on this cursor before, then -1 is returned.

Returns:byte

The next byte that was read by the most recent successful call to readByte().

processback to summary
public default int process(ByteProcessor processor)

Process the remaining bytes in this iterator with the given ByteProcessor. This method consumes the iterator.

Parameters
processor:ByteProcessor

The processor to use for processing the bytes in the iterator.

Returns:int

The number of bytes processed, if the process method returned false, or -1 if the whole iterator was processed.

readByteback to summary
public boolean readByte()

Check if the iterator has at least one byte left, and if so, read that byte and move the cursor forward. The byte will then be available through the getByte().

Returns:boolean

true if the cursor read a byte and moved forward, otherwise false.