Top Description Fields Constructors Methods
io.netty5.buffer

public Class BufferStub

extends Object
implements Buffer
Class Inheritance
All Implemented Interfaces
io.netty5.buffer.Buffer, io.netty5.buffer.BufferAccessor, io.netty5.util.Resource, java.lang.AutoCloseable
Imports
io.netty5.buffer.ComponentIterator.Next, io.netty5.util.Send, java.io.IOException, java.nio.ByteBuffer, java.nio.channels.FileChannel, .ReadableByteChannel, .WritableByteChannel, java.nio.charset.Charset

A stub of a Buffer implementation that implements all buffer methods by delegating them to a wrapped buffer instance.

This can be used when writing automated tests for code that integrates with Buffer, but should not be used in production code.

Field Summary

Modifier and TypeField and Description
protected final Buffer

Constructor Summary

AccessConstructor and Description
public
BufferStub(Buffer
The buffer instance to delegate all method calls to.
delegate
)

Create a new buffer stub that delegates all calls to the given instance.

Method Summary

Modifier and TypeMethod and Description
public int
bytesBefore(byte
The byte value to search for.
needle
)

Implements io.netty5.buffer.Buffer.bytesBefore.

Get the number of readable bytes, until the given needle is found in this buffer.
public int
bytesBefore(Buffer
The buffer value to search for.
needle
)

Implements io.netty5.buffer.Buffer.bytesBefore.

Get the number of readable bytes, until the given needle is found in this buffer.
public int
capacity()

Implements io.netty5.buffer.Buffer.capacity.

The capacity of this buffer, that is, the maximum number of bytes it can contain.
public void
close()

Implements io.netty5.util.Resource.close.

Close the resource, making it inaccessible.
public Buffer
compact()

Implements io.netty5.buffer.Buffer.compact.

Discards the read bytes, and moves the buffer contents to the beginning of the buffer.
public Buffer
copy()

Overrides default io.netty5.buffer.Buffer.copy.

Returns a copy of this buffer's readable bytes.
public Buffer
copy(int
The offset where copying should start from. This is the offset of the first byte copied.
offset
,
int
The number of bytes to copy, and the capacity of the returned buffer.
length
,
boolean
The desired readOnly() state of the returned buffer.
readOnly
)

Implements io.netty5.buffer.Buffer.copy.

Returns a copy of the given region of this buffer.
public Buffer
copy(int
The offset where copying should start from. This is the offset of the first byte copied.
offset
,
int
The number of bytes to copy, and the capacity of the returned buffer.
length
)

Overrides default io.netty5.buffer.Buffer.copy.

Returns a copy of the given region of this buffer.
public Buffer
copy(boolean
The desired readOnly() state of the returned buffer.
readOnly
)

Overrides default io.netty5.buffer.Buffer.copy.

Returns a copy of this buffer's readable bytes, with the given read-only setting.
public void
copyInto(int
The byte offset into this buffer from where the copying should start; the byte at this offset in this buffer will be copied to the destPos index in the dest array.
srcPos
,
byte[]
The destination byte array.
dest
,
int
The index into the dest array from where the copying should start.
destPos
,
int
The number of bytes to copy.
length
)

Implements io.netty5.buffer.Buffer.copyInto.

Copies the given length of data from this buffer into the given destination array, beginning at the given source position in this buffer, and the given destination position in the destination array.
public void
copyInto(int
The byte offset into this buffer from where the copying should start; the byte at this offset in this buffer will be copied to the destPos index in the dest ByteBuffer.
srcPos
,
ByteBuffer
The destination byte buffer.
dest
,
int
The index into the dest ByteBuffer from where the copying should start.
destPos
,
int
The number of bytes to copy.
length
)

Implements io.netty5.buffer.Buffer.copyInto.

Copies the given length of data from this buffer into the given destination byte buffer, beginning at the given source position in this buffer, and the given destination position in the destination byte buffer.
public void
copyInto(int
The byte offset into this buffer from where the copying should start; the byte at this offset in this buffer will be copied to the destPos index in the dest buffer.
srcPos
,
Buffer
The destination buffer.
dest
,
int
The index into the dest buffer from where the copying should start.
destPos
,
int
The number of bytes to copy.
length
)

Implements io.netty5.buffer.Buffer.copyInto.

Copies the given length of data from this buffer into the given destination buffer, beginning at the given source position in this buffer, and the given destination position in the destination buffer.
public int
countComponents()

Implements io.netty5.buffer.Buffer.countComponents.

Get the number of components in this buffer.
public int
countReadableComponents()

Implements io.netty5.buffer.Buffer.countReadableComponents.

Get the number of "components" in this buffer, that are readable.
public int
countWritableComponents()

Implements io.netty5.buffer.Buffer.countWritableComponents.

Get the number of "components" in this buffer, that are writable.
public Buffer
ensureWritable(int
The requested number of bytes of space that should be available for writing.
size
)

Overrides default io.netty5.buffer.Buffer.ensureWritable.

Ensures that this buffer has at least the given number of bytes of available space for writing.
public Buffer
ensureWritable(int
The requested number of bytes of space that should be available for writing.
size
,
int
The minimum number of bytes to grow by. If it is determined that memory should be allocated and copied, make sure that the new memory allocation is bigger than the old one by at least this many bytes. This way, the buffer can grow by more than what is immediately necessary, thus amortising the costs of allocating and copying.
minimumGrowth
,
boolean
true if the method is allowed to modify the reader offset and writer offset, otherwise false.
allowCompaction
)

Implements io.netty5.buffer.Buffer.ensureWritable.

Ensures that this buffer has at least the given number of bytes of available space for writing.
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public Buffer
fill(byte
The byte value to write at every offset in the buffer.
value
)

Implements io.netty5.buffer.Buffer.fill.

Fills the buffer with the given byte value.
public <T extends BufferComponent & ComponentIterator.Next> ComponentIterator<T>
forEachComponent()

Implements io.netty5.buffer.Buffer.forEachComponent.

Create a component iterator for all components in this buffer.
public boolean
getBoolean(int
The read offset, an absolute offset into this buffer, to read from.
roff
)

Overrides default io.netty5.buffer.BufferAccessor.getBoolean.

Get the boolean value at the given reader offset.
public byte
getByte(int
The read offset, an absolute offset into this buffer, to read from.
roff
)

Implements io.netty5.buffer.BufferAccessor.getByte.

Get the byte value at the given reader offset.
public char
getChar(int
The read offset, an absolute offset into this buffer, to read from.
roff
)

Implements io.netty5.buffer.BufferAccessor.getChar.

Get the char value at the given reader offset.
public double
getDouble(int
The read offset, an absolute offset into this buffer, to read from.
roff
)

Implements io.netty5.buffer.BufferAccessor.getDouble.

Get the double value at the given reader offset.
public float
getFloat(int
The read offset, an absolute offset into this buffer, to read from.
roff
)

Implements io.netty5.buffer.BufferAccessor.getFloat.

Get the float value at the given reader offset.
public int
getInt(int
The read offset, an absolute offset into this buffer, to read from.
roff
)

Implements io.netty5.buffer.BufferAccessor.getInt.

Get the int value at the given reader offset.
public long
getLong(int
The read offset, an absolute offset into this buffer, to read from.
roff
)

Implements io.netty5.buffer.BufferAccessor.getLong.

Get the long value at the given reader offset.
public int
getMedium(int
The read offset, an absolute offset into this buffer, to read from.
roff
)

Implements io.netty5.buffer.BufferAccessor.getMedium.

Get the int value at the given reader offset.
public short
getShort(int
The read offset, an absolute offset into this buffer, to read from.
roff
)

Implements io.netty5.buffer.BufferAccessor.getShort.

Get the short value at the given reader offset.
public int
getUnsignedByte(int
The read offset, an absolute offset into this buffer, to read from.
roff
)

Implements io.netty5.buffer.BufferAccessor.getUnsignedByte.

Get the unsigned byte value at the given reader offset.
public long
getUnsignedInt(int
The read offset, an absolute offset into this buffer, to read from.
roff
)

Implements io.netty5.buffer.BufferAccessor.getUnsignedInt.

Get the unsigned int value at the given reader offset.
public int
getUnsignedMedium(int
The read offset, an absolute offset into this buffer, to read from.
roff
)

Implements io.netty5.buffer.BufferAccessor.getUnsignedMedium.

Get the unsigned int value at the given reader offset.
public int
getUnsignedShort(int
The read offset, an absolute offset into this buffer, to read from.
roff
)

Implements io.netty5.buffer.BufferAccessor.getUnsignedShort.

Get the unsigned short value at the given reader offset.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public Buffer
implicitCapacityLimit(int
The maximum size this buffers capacity will implicitly grow to via write* methods.
limit
)

Implements io.netty5.buffer.Buffer.implicitCapacityLimit.

Set an upper limit to the implicit capacity growth.
public int
implicitCapacityLimit()

Implements io.netty5.buffer.Buffer.implicitCapacityLimit.

Returns the implicit capacity limit of the buffer.
public boolean
isAccessible()

Implements io.netty5.util.Resource.isAccessible.

Check if this object is accessible.
public boolean
isDirect()

Implements io.netty5.buffer.Buffer.isDirect.

Queries if this buffer is backed by native memory, or not.
public Buffer
makeReadOnly()

Implements io.netty5.buffer.Buffer.makeReadOnly.

Makes this buffer read-only.
public ByteCursor
openCursor()

Implements io.netty5.buffer.Buffer.openCursor.

Opens a cursor to iterate the readable bytes of this buffer.
public ByteCursor
openCursor(int
The offset into the buffer where iteration should start. The first byte read from the iterator will be the byte at this offset.
fromOffset
,
int
The number of bytes to iterate.
length
)

Implements io.netty5.buffer.Buffer.openCursor.

Opens a cursor to iterate the given number bytes of this buffer, starting at the given offset.
public ByteCursor
openReverseCursor()

Overrides default io.netty5.buffer.Buffer.openReverseCursor.

Opens a cursor to iterate the readable bytes of this buffer, in reverse.
public ByteCursor
openReverseCursor(int
The offset into the buffer where iteration should start. The first byte read from the iterator will be the byte at this offset.
fromOffset
,
int
The number of bytes to iterate.
length
)

Implements io.netty5.buffer.Buffer.openReverseCursor.

Opens a cursor to iterate the given number bytes of this buffer, in reverse, starting at the given offset.
public int
readableBytes()

Overrides default io.netty5.buffer.Buffer.readableBytes.

Returns the number of readable bytes which is equal to (writerOffset() - readerOffset()).
public boolean
readBoolean()

Overrides default io.netty5.buffer.BufferAccessor.readBoolean.

Read the boolean value at the current Buffer#readerOffset(), and increases the reader offset by Byte#BYTES.
public byte
readByte()

Implements io.netty5.buffer.BufferAccessor.readByte.

Read the byte value at the current Buffer#readerOffset(), and increases the reader offset by Byte#BYTES.
public Buffer
readBytes(byte[]
The byte array to write into.
destination
,
int
Position in the destination to where bytes should be written from this buffer.
destPos
,
int
The number of bytes to copy.
length
)

Overrides default io.netty5.buffer.Buffer.readBytes.

Read from this buffer, into the destination array, the given number of bytes.
public Buffer
readBytes(ByteBuffer
The ByteBuffer to write into.
destination
)

Overrides default io.netty5.buffer.Buffer.readBytes.

Read from this buffer, into the destination ByteBuffer This updates the read offset of this buffer and also the position of the destination ByteBuffer.
public char
readChar()

Implements io.netty5.buffer.BufferAccessor.readChar.

Read the char value at the current Buffer#readerOffset(), and increases the reader offset by 2.
public CharSequence
readCharSequence(int
of CharSequence to read.
length
,
Charset
of the bytes to be read.
charset
)

Overrides default io.netty5.buffer.Buffer.readCharSequence.

Reads a CharSequence of the passed length using the passed Charset.
public double
readDouble()

Implements io.netty5.buffer.BufferAccessor.readDouble.

Read the double value at the current Buffer#readerOffset(), and increases the reader offset by Double#BYTES.
public int
readerOffset()

Implements io.netty5.buffer.Buffer.readerOffset.

Get the current reader offset.
public Buffer
readerOffset(int
The reader offset to set.
offset
)

Implements io.netty5.buffer.Buffer.readerOffset.

Set the reader offset.
public float
readFloat()

Implements io.netty5.buffer.BufferAccessor.readFloat.

Read the float value at the current Buffer#readerOffset(), and increases the reader offset by Float#BYTES.
public int
readInt()

Implements io.netty5.buffer.BufferAccessor.readInt.

Read the int value at the current Buffer#readerOffset(), and increases the reader offset by Integer#BYTES.
public long
readLong()

Implements io.netty5.buffer.BufferAccessor.readLong.

Read the long value at the current Buffer#readerOffset(), and increases the reader offset by Long#BYTES.
public int
readMedium()

Implements io.netty5.buffer.BufferAccessor.readMedium.

Read the int value at the current Buffer#readerOffset(), and increases the reader offset by 3.
public boolean
readOnly()

Implements io.netty5.buffer.Buffer.readOnly.

Queries if this buffer is read-only or not.
public short
readShort()

Implements io.netty5.buffer.BufferAccessor.readShort.

Read the short value at the current Buffer#readerOffset(), and increases the reader offset by Short#BYTES.
public Buffer
readSplit(int length)

Overrides default io.netty5.buffer.Buffer.readSplit.

Splits the buffer into two, at length number of bytes from the current reader offset position.
public int
readUnsignedByte()

Implements io.netty5.buffer.BufferAccessor.readUnsignedByte.

Read the unsigned byte value at the current Buffer#readerOffset(), and increases the reader offset by Byte#BYTES.
public long
readUnsignedInt()

Implements io.netty5.buffer.BufferAccessor.readUnsignedInt.

Read the unsigned int value at the current Buffer#readerOffset(), and increases the reader offset by Integer#BYTES.
public int
readUnsignedMedium()

Implements io.netty5.buffer.BufferAccessor.readUnsignedMedium.

Read the unsigned int value at the current Buffer#readerOffset(), and increases the reader offset by 3.
public int
readUnsignedShort()

Implements io.netty5.buffer.BufferAccessor.readUnsignedShort.

Read the unsigned short value at the current Buffer#readerOffset(), and increases the reader offset by Short#BYTES.
public Buffer
resetOffsets()

Overrides default io.netty5.buffer.Buffer.resetOffsets.

Resets the read offset and the write offset on this buffer to zero, and return this buffer.
public Send<Buffer>
send()

Implements io.netty5.util.Resource.send.

Send this object instance to another Thread, transferring the ownership to the recipient.
public Buffer
setBoolean(int
The write offset, an absolute offset into this buffer to write to.
woff
,
boolean
The boolean value to write.
value
)

Overrides default io.netty5.buffer.BufferAccessor.setBoolean.

Set the given boolean value at the given write offset.
public Buffer
setByte(int
The write offset, an absolute offset into this buffer to write to.
woff
,
byte
The byte value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.setByte.

Set the given byte value at the given write offset.
public Buffer
setChar(int
The write offset, an absolute offset into this buffer to write to.
woff
,
char
The char value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.setChar.

Set the given char value at the given write offset.
public Buffer
setDouble(int
The write offset, an absolute offset into this buffer to write to.
woff
,
double
The double value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.setDouble.

Set the given double value at the given write offset.
public Buffer
setFloat(int
The write offset, an absolute offset into this buffer to write to.
woff
,
float
The float value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.setFloat.

Set the given float value at the given write offset.
public Buffer
setInt(int
The write offset, an absolute offset into this buffer to write to.
woff
,
int
The int value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.setInt.

Set the given int value at the given write offset.
public Buffer
setLong(int
The write offset, an absolute offset into this buffer to write to.
woff
,
long
The long value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.setLong.

Set the given long value at the given write offset.
public Buffer
setMedium(int
The write offset, an absolute offset into this buffer to write to.
woff
,
int
The int value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.setMedium.

Set the given int value at the given write offset.
public Buffer
setShort(int
The write offset, an absolute offset into this buffer to write to.
woff
,
short
The short value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.setShort.

Set the given short value at the given write offset.
public Buffer
setUnsignedByte(int
The write offset, an absolute offset into this buffer to write to.
woff
,
int
The int value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.setUnsignedByte.

Set the given unsigned byte value at the given write offset.
public Buffer
setUnsignedInt(int
The write offset, an absolute offset into this buffer to write to.
woff
,
long
The long value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.setUnsignedInt.

Set the given unsigned int value at the given write offset.
public Buffer
setUnsignedMedium(int
The write offset, an absolute offset into this buffer to write to.
woff
,
int
The int value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.setUnsignedMedium.

Set the given unsigned int value at the given write offset.
public Buffer
setUnsignedShort(int
The write offset, an absolute offset into this buffer to write to.
woff
,
int
The int value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.setUnsignedShort.

Set the given unsigned short value at the given write offset.
public Buffer
skipReadableBytes(int
to accumulate.
delta
)

Overrides default io.netty5.buffer.Buffer.skipReadableBytes.

Move the reader offset forward by the given delta.
public Buffer
skipWritableBytes(int
to accumulate.
delta
)

Overrides default io.netty5.buffer.Buffer.skipWritableBytes.

Move the writer offset to ahead by the given delta.
public Buffer
split()

Overrides default io.netty5.buffer.Buffer.split.

Splits the buffer into two, at the write offset position.
public Buffer
split(int
The offset into this buffer where it should be split. After the split, the data at this offset will be at offset zero in this buffer.
splitOffset
)

Implements io.netty5.buffer.Buffer.split.

Splits the buffer into two, at the given splitOffset.
public String
toString(Charset
used for decoding.
charset
)

Overrides default io.netty5.buffer.Buffer.toString.

Decodes this buffer's readable bytes into a string with the specified Charset.
public Buffer
touch(Object
An optional hint about this access and its context. May be null.
hint
)

Overrides default io.netty5.util.Resource.touch.

Record the current access location for debugging purposes.
public int
transferFrom(FileChannel
The channel to read from.
channel
,
long
The file position.
position
,
int
The maximum number of bytes to read.
length
)

Implements io.netty5.buffer.Buffer.transferFrom.

Read from the given channel starting from the given position and write to this buffer.
public int
transferFrom(ReadableByteChannel
The channel to read from.
channel
,
int
The maximum number of bytes to read.
length
)

Implements io.netty5.buffer.Buffer.transferFrom.

Read from the given channel and write to this buffer.
public int
transferTo(WritableByteChannel
The channel to write to.
channel
,
int
The maximum number of bytes to write.
length
)

Implements io.netty5.buffer.Buffer.transferTo.

Read from this buffer and write to the given channel.
public int
writableBytes()

Overrides default io.netty5.buffer.Buffer.writableBytes.

Returns the number of writable bytes which is equal to (capacity() - writerOffset()).
public Buffer
writeBoolean(boolean
The boolean value to write.
value
)

Overrides default io.netty5.buffer.BufferAccessor.writeBoolean.

Write the given boolean value at the current Buffer#writerOffset(), and increase the writer offset by Byte#BYTES.
public Buffer
writeByte(byte
The byte value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.writeByte.

Write the given byte value at the current Buffer#writerOffset(), and increase the writer offset by Byte#BYTES.
public Buffer
writeBytes(Buffer
The buffer to read from.
source
)

Overrides default io.netty5.buffer.Buffer.writeBytes.

Writes into this buffer, all the readable bytes from the given buffer.
public Buffer
writeBytes(byte[]
The byte array to read from.
source
)

Overrides default io.netty5.buffer.Buffer.writeBytes.

Writes into this buffer, all the bytes from the given byte array.
public Buffer
writeBytes(byte[]
The byte array to read from.
source
,
int
Position in the source from where bytes should be written to this buffer.
srcPos
,
int
The number of bytes to copy.
length
)

Overrides default io.netty5.buffer.Buffer.writeBytes.

Writes into this buffer, the given number of bytes from the byte array.
public Buffer
writeBytes(ByteBuffer
The ByteBuffer to read from.
source
)

Overrides default io.netty5.buffer.Buffer.writeBytes.

Writes into this buffer from the source ByteBuffer.
public Buffer
writeChar(char
The char value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.writeChar.

Write the given char value at the current Buffer#writerOffset(), and increase the writer offset by 2.
public Buffer
writeCharSequence(CharSequence
CharSequence to read from.
source
,
Charset
Charset to use for writing.
charset
)

Overrides default io.netty5.buffer.Buffer.writeCharSequence.

Writes into this buffer, all the bytes from the given source using the passed charset.
public Buffer
writeDouble(double
The double value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.writeDouble.

Write the given double value at the current Buffer#writerOffset(), and increase the writer offset by Double#BYTES.
public Buffer
writeFloat(float
The float value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.writeFloat.

Write the given float value at the current Buffer#writerOffset(), and increase the writer offset by Float#BYTES.
public Buffer
writeInt(int
The int value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.writeInt.

Write the given int value at the current Buffer#writerOffset(), and increase the writer offset by Integer#BYTES.
public Buffer
writeLong(long
The long value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.writeLong.

Write the given long value at the current Buffer#writerOffset(), and increase the writer offset by Long#BYTES.
public Buffer
writeMedium(int
The int value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.writeMedium.

Write the given int value at the current Buffer#writerOffset(), and increase the writer offset by 3.
public int
writerOffset()

Implements io.netty5.buffer.Buffer.writerOffset.

Get the current writer offset.
public Buffer
writerOffset(int
The writer offset to set.
offset
)

Implements io.netty5.buffer.Buffer.writerOffset.

Set the writer offset.
public Buffer
writeShort(short
The short value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.writeShort.

Write the given short value at the current Buffer#writerOffset(), and increase the writer offset by Short#BYTES.
public Buffer
writeSplit(int length)

Overrides default io.netty5.buffer.Buffer.writeSplit.

Splits the buffer into two, at length number of bytes from the current writer offset position.
public Buffer
writeUnsignedByte(int
The int value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.writeUnsignedByte.

Write the given unsigned byte value at the current Buffer#writerOffset(), and increase the writer offset by Byte#BYTES.
public Buffer
writeUnsignedInt(long
The long value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.writeUnsignedInt.

Write the given unsigned int value at the current Buffer#writerOffset(), and increase the writer offset by Integer#BYTES.
public Buffer
writeUnsignedMedium(int
The int value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.writeUnsignedMedium.

Write the given unsigned int value at the current Buffer#writerOffset(), and increase the writer offset by 3.
public Buffer
writeUnsignedShort(int
The int value to write.
value
)

Implements io.netty5.buffer.BufferAccessor.writeUnsignedShort.

Write the given unsigned short value at the current Buffer#writerOffset(), and increase the writer offset by Short#BYTES.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait