Package io.netty5.buffer.api
Interface ByteCursor
-
public interface ByteCursorThe ByteCursor scans through a sequence of bytes. This is similar toByteProcessor, but for external iteration rather than internal iteration. The external iteration allows the callers to control the pace of the iteration.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description intbytesLeft()Get the current number of bytes left in the iterator.intcurrentOffset()The current position of this iterator into the underlying sequence of bytes.bytegetByte()Return the last byte that was read byreadByte().default intprocess(io.netty5.util.ByteProcessor processor)Process the remaining bytes in this iterator with the givenByteProcessor.booleanreadByte()Check if the iterator has at least one byte left, and if so, read that byte and move the cursor forward.
-
-
-
Method Detail
-
readByte
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 thegetByte().- Returns:
trueif the cursor read a byte and moved forward, otherwisefalse.
-
getByte
byte getByte()
Return the last byte that was read byreadByte(). IfreadByte()has not been called on this cursor before, then-1is returned.- Returns:
- The next byte that was read by the most recent successful call to
readByte().
-
currentOffset
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:
- The current iterator offset into the underlying sequence of bytes.
-
bytesLeft
int bytesLeft()
Get the current number of bytes left in the iterator.- Returns:
- The number of bytes left in the iterator.
-
process
default int process(io.netty5.util.ByteProcessor processor)
Process the remaining bytes in this iterator with the givenByteProcessor. This method consumes the iterator.- Parameters:
processor- The processor to use for processing the bytes in the iterator.- Returns:
- The number of bytes processed, if the
processmethod returnedfalse, or-1if the whole iterator was processed.
-
-