Top Description Inners Fields Constructors Methods
io.netty5.buffer

pack-priv final Class DefaultCompositeBuffer

extends ResourceSupport<Buffer, DefaultCompositeBuffer>
implements CompositeBuffer
Class Inheritance
All Implemented Interfaces
io.netty5.buffer.CompositeBuffer, io.netty5.buffer.Buffer, io.netty5.buffer.BufferAccessor, io.netty5.util.Resource, java.lang.AutoCloseable
Imports
io.netty5.buffer.ComponentIterator.Next, io.netty5.buffer.internal.InternalBufferUtils, .ResourceSupport, io.netty5.util.SafeCloseable, .Send, java.io.IOException, java.nio.ByteBuffer, .ReadOnlyBufferException, java.nio.channels.FileChannel, .GatheringByteChannel, .ReadableByteChannel, .ScatteringByteChannel, .WritableByteChannel, java.util.ArrayList, .Arrays, .Collection, .List, .Objects

The default implementation of the CompositeBuffer interface.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static interface
private static class
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private final BufferAllocator
private Buffer[]
private int
private boolean
private static final Drop<DefaultCompositeBuffer>
private static final Buffer[]
private static final int
FIRST_AUTOMATIC_COMPONENT_SIZE

The various write*() methods may automatically grow the buffer, if there is not enough capacity to service the write operation.

private int
private int[]
private boolean
private int
private int
private final DefaultCompositeBuffer.TornBufferAccessor
private int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private boolean
private CompositeBuffer
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.
private void
checkGetBounds(int index, int size)

private void
checkReadBounds(int index, int size)

private void
checkSplit(int splitOffset)

private void
checkWriteBounds(int index, int size)

private BufferAccessor
chooseBuffer(int index, int size)

private BufferAccessor
public CompositeBuffer
compact()

Implements io.netty5.buffer.CompositeBuffer.compact.

Discards the read bytes, and moves the buffer contents to the beginning of the buffer.
public static CompositeBuffer
public static CompositeBuffer
compose(BufferAllocator
The allocator for the composite buffer. This allocator will be used e.g. to service ensureWritable(int) calls.
allocator
)

Hides io.netty5.buffer.CompositeBuffer.compose.

Create an empty composite buffer, that has no components.
private void
public CompositeBuffer
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.CompositeBuffer.copy.

Returns a copy of the given region of this 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 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.
private void
copyInto(int srcPos, DefaultCompositeBuffer.CopyInto dest, int destPos, int length)

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.
private static int
countAndPrepareBuffersForChannelIO(int byteLength, ByteBuffer[] byteBuffers)

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.
protected RuntimeException
public Buffer[]
decomposeBuffer()

Implements io.netty5.buffer.CompositeBuffer.decomposeBuffer.

Break a composite buffer into its constituent components.
public CompositeBuffer
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.CompositeBuffer.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.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public CompositeBuffer
extendWith(Send<Buffer>
The buffer to extend the composite buffer with.
extension
)

Implements io.netty5.buffer.CompositeBuffer.extendWith.

Extend this composite buffer with the given extension buffer.
public CompositeBuffer
fill(byte
The byte value to write at every offset in the buffer.
value
)

Implements io.netty5.buffer.CompositeBuffer.fill.

Fills the buffer with the given byte value.
private static Buffer[]
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 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.
pack-priv long
getPassThrough(int roff)

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 CompositeBuffer
implicitCapacityLimit(int
The maximum size this buffers capacity will implicitly grow to via write* methods.
limit
)

Implements io.netty5.buffer.CompositeBuffer.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.
private RuntimeException
indexOutOfBounds(int index, boolean write)

public boolean
isDirect()

Implements io.netty5.buffer.Buffer.isDirect.

Queries if this buffer is backed by native memory, or not.
protected boolean
isOwned()

Overrides io.netty5.buffer.internal.ResourceSupport.isOwned.

Query if this object is in an "owned" state, which means no other references have been acquired to it.
protected void
makeInaccessible()

Overrides io.netty5.buffer.internal.ResourceSupport.makeInaccessible.

Called when this resource needs to be considered inaccessible.
public CompositeBuffer
makeReadOnly()

Implements io.netty5.buffer.CompositeBuffer.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(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.
protected Owned<DefaultCompositeBuffer>
prepareSend()

Implements abstract io.netty5.buffer.internal.ResourceSupport.prepareSend.

Prepare this instance for ownership transfer.
private BufferAccessor
prepGet(int index, int size)

private BufferAccessor
prepRead(int size)

private BufferAccessor
prepRead(int index, int size)

private BufferAccessor
prepWrite(int size)

private BufferAccessor
prepWrite(int index, int size)

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 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 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 CompositeBuffer
readerOffset(int
The reader offset to set.
index
)

Implements io.netty5.buffer.CompositeBuffer.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.
pack-priv long
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 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.
private int
searchOffsets(int index)

public CompositeBuffer
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.CompositeBuffer.setByte.

Set the given byte value at the given write offset.
public CompositeBuffer
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.CompositeBuffer.setChar.

Set the given char value at the given write offset.
public CompositeBuffer
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.CompositeBuffer.setDouble.

Set the given double value at the given write offset.
public CompositeBuffer
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.CompositeBuffer.setFloat.

Set the given float value at the given write offset.
public CompositeBuffer
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.CompositeBuffer.setInt.

Set the given int value at the given write offset.
public CompositeBuffer
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.CompositeBuffer.setLong.

Set the given long value at the given write offset.
public CompositeBuffer
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.CompositeBuffer.setMedium.

Set the given int value at the given write offset.
pack-priv void
setPassThrough(int woff, int value)

public CompositeBuffer
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.CompositeBuffer.setShort.

Set the given short value at the given write offset.
public CompositeBuffer
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.CompositeBuffer.setUnsignedByte.

Set the given unsigned byte value at the given write offset.
public CompositeBuffer
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.CompositeBuffer.setUnsignedInt.

Set the given unsigned int value at the given write offset.
public CompositeBuffer
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.CompositeBuffer.setUnsignedMedium.

Set the given unsigned int value at the given write offset.
public CompositeBuffer
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.CompositeBuffer.setUnsignedShort.

Set the given unsigned short value at the given write offset.
public CompositeBuffer
split()

Overrides default io.netty5.buffer.CompositeBuffer.split.

Splits the buffer into two, at the write offset position.
public CompositeBuffer
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.CompositeBuffer.split.

Splits the buffer into two, at the given splitOffset.
public CompositeBuffer
splitComponentsCeil(int
The minimum split offset. The real split offset will be at a component boundary that is greater than or equal to this offset.
splitOffset
)

Implements io.netty5.buffer.CompositeBuffer.splitComponentsCeil.

Split this buffer at a component boundary that is greater than or equal to the given offset.
public CompositeBuffer
splitComponentsFloor(int
The maximum split offset. The real split offset will be at a component boundary that is less than or equal to this offset.
splitOffset
)

Implements io.netty5.buffer.CompositeBuffer.splitComponentsFloor.

Split this buffer at a component boundary that is less than or equal to the given offset.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public CompositeBuffer
touch(Object
An optional hint about this access and its context. May be null.
hint
)

Overrides io.netty5.buffer.internal.ResourceSupport.touch.

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.
private void
public CompositeBuffer
writeByte(byte
The byte value to write.
value
)

Implements io.netty5.buffer.CompositeBuffer.writeByte.

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

Implements io.netty5.buffer.CompositeBuffer.writeChar.

Write the given char value at the current Buffer#writerOffset(), and increase the writer offset by 2.
public CompositeBuffer
writeDouble(double
The double value to write.
value
)

Implements io.netty5.buffer.CompositeBuffer.writeDouble.

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

Implements io.netty5.buffer.CompositeBuffer.writeFloat.

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

Implements io.netty5.buffer.CompositeBuffer.writeInt.

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

Implements io.netty5.buffer.CompositeBuffer.writeLong.

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

Implements io.netty5.buffer.CompositeBuffer.writeMedium.

Write the given int value at the current Buffer#writerOffset(), and increase the writer offset by 3.
pack-priv void
writePassThrough(int value)

public int
writerOffset()

Implements io.netty5.buffer.Buffer.writerOffset.

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

Implements io.netty5.buffer.CompositeBuffer.writerOffset.

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

Implements io.netty5.buffer.CompositeBuffer.writeShort.

Write the given short value at the current Buffer#writerOffset(), and increase the writer offset by Short#BYTES.
public CompositeBuffer
writeUnsignedByte(int
The int value to write.
value
)

Implements io.netty5.buffer.CompositeBuffer.writeUnsignedByte.

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

Implements io.netty5.buffer.CompositeBuffer.writeUnsignedInt.

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

Implements io.netty5.buffer.CompositeBuffer.writeUnsignedMedium.

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

Implements io.netty5.buffer.CompositeBuffer.writeUnsignedShort.

Write the given unsigned short value at the current Buffer#writerOffset(), and increase the writer offset by Short#BYTES.
Inherited from io.netty5.buffer.internal.ResourceSupport:
acquireattachTraceclosecountBorrowsisAccessiblenotSendableExceptionsendunsafeGetDropunsafeSetDrop