Class EmptyBuffer
- java.lang.Object
-
- io.servicetalk.buffer.api.EmptyBuffer
-
-
Field Summary
Fields Modifier and Type Field Description static EmptyBuffer
EMPTY_BUFFER
An instance ofEmptyBuffer
that can be shared.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
array()
Returns the backing byte array of this buffer.int
arrayOffset()
Returns the offset of the first byte within the backing byte array of this buffer.Buffer
asReadOnly()
Create a read-only view for this buffer.int
bytesBefore(byte value)
Locates the first occurrence of the specifiedvalue
in this buffer.int
bytesBefore(int length, byte value)
Locates the first occurrence of the specifiedvalue
in this buffer.int
bytesBefore(int index, int length, byte value)
Locates the first occurrence of the specifiedvalue
in this buffer.int
capacity()
Returns the number of bytes (octets) this buffer can contain.Buffer
capacity(int newCapacity)
Sets the capacity of this buffer.Buffer
clear()
Sets thereaderIndex
andwriterIndex
of this buffer to0
.Buffer
copy()
Returns a copy of this buffer's readable bytes.Buffer
copy(int index, int length)
Returns a copy of this buffer's sub-region.Buffer
duplicate()
Returns a buffer which shares the whole region of this buffer.Buffer
ensureWritable(int minWritableBytes)
Expands the bufferBuffer.capacity()
to make sure the number of writable bytes is equal to or greater than the specified value.int
ensureWritable(int minWritableBytes, boolean force)
Expands the bufferBuffer.capacity()
to make sure the number of writable bytes is equal to or greater than the specified value.int
forEachByte(int index, int length, ByteProcessor processor)
Iterates over the specified area of this buffer with the specifiedprocessor
in ascending order.int
forEachByte(ByteProcessor processor)
Iterates over the readable bytes of this buffer with the specifiedprocessor
in ascending order.int
forEachByteDesc(int index, int length, ByteProcessor processor)
Iterates over the specified area of this buffer with the specifiedprocessor
in descending order.int
forEachByteDesc(ByteProcessor processor)
Iterates over the readable bytes of this buffer with the specifiedprocessor
in descending order.boolean
getBoolean(int index)
Gets a boolean at the specified absolute (@code index) in this buffer.byte
getByte(int index)
Gets a byte at the specified absoluteindex
in this buffer.Buffer
getBytes(int index, byte[] dst)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.Buffer
getBytes(int index, byte[] dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.Buffer
getBytes(int index, Buffer dst)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
until the destination becomes non-writable.Buffer
getBytes(int index, Buffer dst, int length)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.Buffer
getBytes(int index, Buffer dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.Buffer
getBytes(int index, java.nio.ByteBuffer dst)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
until the destination's position reaches its limit.char
getChar(int index)
Gets a 2-byte UTF-16 character at the specified absoluteindex
in this buffer.double
getDouble(int index)
Gets a 64-bit floating point number at the specified absoluteindex
in this buffer.float
getFloat(int index)
Gets a 32-bit floating point number at the specified absoluteindex
in this buffer.int
getInt(int index)
Gets a 32-bit integer at the specified absoluteindex
in this buffer.int
getIntLE(int index)
Gets a 32-bit integer at the specified absoluteindex
in this buffer with Little Endian Byte Order.long
getLong(int index)
Gets a 64-bit long integer at the specified absoluteindex
in this buffer.long
getLongLE(int index)
Gets a 64-bit long integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.int
getMedium(int index)
Gets a 24-bit medium integer at the specified absoluteindex
in this buffer.int
getMediumLE(int index)
Gets a 24-bit medium integer at the specified absoluteindex
in this buffer in the Little Endian Byte Order.short
getShort(int index)
Gets a 16-bit short integer at the specified absoluteindex
in this buffer.short
getShortLE(int index)
Gets a 16-bit short integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.short
getUnsignedByte(int index)
Gets an unsigned byte at the specified absoluteindex
in this buffer.long
getUnsignedInt(int index)
Gets an unsigned 32-bit integer at the specified absoluteindex
in this buffer.long
getUnsignedIntLE(int index)
Gets an unsigned 32-bit integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.int
getUnsignedMedium(int index)
Gets an unsigned 24-bit medium integer at the specified absoluteindex
in this buffer.int
getUnsignedMediumLE(int index)
Gets an unsigned 24-bit medium integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.int
getUnsignedShort(int index)
Gets an unsigned 16-bit short integer at the specified absoluteindex
in this buffer.int
getUnsignedShortLE(int index)
Gets an unsigned 16-bit short integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.boolean
hasArray()
Returnstrue
if and only if this buffer has a backing byte array.int
indexOf(int fromIndex, int toIndex, byte value)
Locates the first occurrence of the specifiedvalue
in this buffer.boolean
isDirect()
Returnstrue
if the buffer is direct and so not allocated on the heap.boolean
isReadOnly()
Determine if this buffer is read-only.int
maxCapacity()
Returns the maximum allowed capacity of this buffer.int
maxWritableBytes()
Returns the maximum possible number of writable bytes, which is equal to(this.maxCapacity - this.writerIndex)
.int
nioBufferCount()
Returns the maximum number of NIOByteBuffer
s that consist this buffer.int
readableBytes()
Returns the number of readable bytes which is equal to(this.writerIndex - this.readerIndex)
.boolean
readBoolean()
Gets a boolean at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.byte
readByte()
Gets a byte at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.Buffer
readBytes(byte[] dst)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=dst.length
).Buffer
readBytes(byte[] dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).Buffer
readBytes(int length)
Transfers this buffer's data to a newly created buffer starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).Buffer
readBytes(Buffer dst)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
until the destination becomes non-writable, and increases thereaderIndex
by the number of the transferred bytes.Buffer
readBytes(Buffer dst, int length)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).Buffer
readBytes(Buffer dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).Buffer
readBytes(java.nio.ByteBuffer dst)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
until the destination's position reaches its limit, and increases thereaderIndex
by the number of the transferred bytes.char
readChar()
Gets a 2-byte UTF-16 character at the currentreaderIndex
and increases thereaderIndex
by2
in this buffer.double
readDouble()
Gets a 64-bit floating point number at the currentreaderIndex
and increases thereaderIndex
by8
in this buffer.int
readerIndex()
Returns thereaderIndex
of this buffer.Buffer
readerIndex(int readerIndex)
Sets thereaderIndex
of this buffer.float
readFloat()
Gets a 32-bit floating point number at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.int
readInt()
Gets a 32-bit integer at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.int
readIntLE()
Gets a 32-bit integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by4
in this buffer.long
readLong()
Gets a 64-bit integer at the currentreaderIndex
and increases thereaderIndex
by8
in this buffer.long
readLongLE()
Gets a 64-bit integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by8
in this buffer.int
readMedium()
Gets a 24-bit medium integer at the currentreaderIndex
and increases thereaderIndex
by3
in this buffer.int
readMediumLE()
Gets a 24-bit medium integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by3
in this buffer.short
readShort()
Gets a 16-bit short integer at the currentreaderIndex
and increases thereaderIndex
by2
in this buffer.short
readShortLE()
Gets a 16-bit short integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by2
in this buffer.Buffer
readSlice(int length)
Returns a new slice of this buffer's sub-region starting at the currentreaderIndex
and increases thereaderIndex
by the size of the new slice (=length
).short
readUnsignedByte()
Gets an unsigned byte at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.long
readUnsignedInt()
Gets an unsigned 32-bit integer at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.long
readUnsignedIntLE()
Gets an unsigned 32-bit integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by4
in this buffer.int
readUnsignedMedium()
Gets an unsigned 24-bit medium integer at the currentreaderIndex
and increases thereaderIndex
by3
in this buffer.int
readUnsignedMediumLE()
Gets an unsigned 24-bit medium integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by3
in this buffer.int
readUnsignedShort()
Gets an unsigned 16-bit short integer at the currentreaderIndex
and increases thereaderIndex
by2
in this buffer.int
readUnsignedShortLE()
Gets an unsigned 16-bit short integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by2
in this buffer.Buffer
setBoolean(int index, boolean value)
Sets the specified boolean at the specified absoluteindex
in this buffer.Buffer
setByte(int index, int value)
Sets the specified byte at the specified absoluteindex
in this buffer.Buffer
setBytes(int index, byte[] src)
Transfers the specified source array's data to this buffer starting at the specified absoluteindex
.Buffer
setBytes(int index, byte[] src, int srcIndex, int length)
Transfers the specified source array's data to this buffer starting at the specified absoluteindex
.Buffer
setBytes(int index, Buffer src)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
until the source buffer becomes unreadable.Buffer
setBytes(int index, Buffer src, int length)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
.Buffer
setBytes(int index, Buffer src, int srcIndex, int length)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
.int
setBytes(int index, java.io.InputStream src, int length)
Transfers a fixed amount from the specified source InputStream's data to this buffer starting at the specified absoluteindex
untillength
bytes have been read, the end of stream is reached, or an exception is thrown.Buffer
setBytes(int index, java.nio.ByteBuffer src)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
until the source buffer's position reaches its limit.int
setBytesUntilEndStream(int index, java.io.InputStream src, int chunkSize)
Transfers all the specified source InputStream's data to this buffer starting at the specified absoluteindex
until the end of stream is reached or an exception is thrown.Buffer
setChar(int index, int value)
Sets the specified 2-byte UTF-16 character at the specified absoluteindex
in this buffer.Buffer
setDouble(int index, double value)
Sets the specified 64-bit floating-point number at the specified absoluteindex
in this buffer.Buffer
setFloat(int index, float value)
Sets the specified 32-bit floating-point number at the specified absoluteindex
in this buffer.Buffer
setInt(int index, int value)
Sets the specified 32-bit integer at the specified absoluteindex
in this buffer.Buffer
setIntLE(int index, int value)
Sets the specified 32-bit integer at the specified absoluteindex
in this buffer with Little Endian byte order .Buffer
setLong(int index, long value)
Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer.Buffer
setLongLE(int index, long value)
Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.Buffer
setMedium(int index, int value)
Sets the specified 24-bit medium integer at the specified absoluteindex
in this buffer.Buffer
setMediumLE(int index, int value)
Sets the specified 24-bit medium integer at the specified absoluteindex
in this buffer in the Little Endian Byte Order.Buffer
setShort(int index, int value)
Sets the specified 16-bit short integer at the specified absoluteindex
in this buffer.Buffer
setShortLE(int index, int value)
Sets the specified 16-bit short integer at the specified absoluteindex
in this buffer with the Little Endian Byte Order.Buffer
skipBytes(int length)
Increases the currentreaderIndex
by the specifiedlength
in this buffer.Buffer
slice()
Returns a slice of this buffer's readable bytes.Buffer
slice(int index, int length)
Returns a slice of this buffer's sub-region.java.nio.ByteBuffer
toNioBuffer()
Exposes this buffer's readable bytes as an NIOByteBuffer
.java.nio.ByteBuffer
toNioBuffer(int index, int length)
Exposes this buffer's sub-region as an NIOByteBuffer
.java.nio.ByteBuffer[]
toNioBuffers()
Exposes this buffer's readable bytes as an NIOByteBuffer
's.java.nio.ByteBuffer[]
toNioBuffers(int index, int length)
Exposes this buffer's bytes as an NIOByteBuffer
's for the specified index and length The returned buffer shares the content with this buffer, while changing the position and limit of the returned NIO buffer does not affect the indexes of this buffer.java.lang.String
toString(int index, int length, java.nio.charset.Charset charset)
Decodes this buffer's sub-region into a string with the specified character set.java.lang.String
toString(java.nio.charset.Charset charset)
Decodes this buffer's readable bytes into a string with the specified character set name.int
writableBytes()
Returns the number of writable bytes which is equal to(this.capacity - this.writerIndex)
.Buffer
writeAscii(java.lang.CharSequence seq)
Encode aCharSequence
in ASCII and write it to this buffer starting atwriterIndex
and increases thewriterIndex
by the number of the transferred bytes.Buffer
writeBoolean(boolean value)
Sets the specified boolean at the currentwriterIndex
and increases thewriterIndex
by1
in this buffer.Buffer
writeByte(int value)
Sets the specified byte at the currentwriterIndex
and increases thewriterIndex
by1
in this buffer.Buffer
writeBytes(byte[] src)
Transfers the specified source array's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=src.length
).Buffer
writeBytes(byte[] src, int srcIndex, int length)
Transfers the specified source array's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
).Buffer
writeBytes(Buffer src)
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
until the source buffer becomes unreadable, and increases thewriterIndex
by the number of the transferred bytes.Buffer
writeBytes(Buffer src, int length)
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
).Buffer
writeBytes(Buffer src, int srcIndex, int length)
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
).int
writeBytes(java.io.InputStream src, int length)
Transfers ta fixed amount from the specified sourceInputStream
's data to this buffer starting at the currentwriterIndex
untillength
bytes have been read, the end of stream is reached, or an exception is thrown.Buffer
writeBytes(java.nio.ByteBuffer src)
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
until the source buffer's position reaches its limit, and increases thewriterIndex
by the number of the transferred bytes.int
writeBytesUntilEndStream(java.io.InputStream src, int chunkSize)
Transfers all the specified sourceInputStream
's data to this buffer starting at the currentwriterIndex
until the end of stream is reached or an exception is thrown.Buffer
writeChar(int value)
Sets the specified 2-byte UTF-16 character at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer.Buffer
writeDouble(double value)
Sets the specified 64-bit floating point number at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer.Buffer
writeFloat(float value)
Sets the specified 32-bit floating point number at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer.Buffer
writeInt(int value)
Sets the specified 32-bit integer at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer.Buffer
writeIntLE(int value)
Sets the specified 32-bit integer at the currentwriterIndex
in the Little Endian Byte Order and increases thewriterIndex
by4
in this buffer.Buffer
writeLong(long value)
Sets the specified 64-bit long integer at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer.Buffer
writeLongLE(long value)
Sets the specified 64-bit long integer at the currentwriterIndex
in the Little Endian Byte Order and increases thewriterIndex
by8
in this buffer.Buffer
writeMedium(int value)
Sets the specified 24-bit medium integer at the currentwriterIndex
and increases thewriterIndex
by3
in this buffer.Buffer
writeMediumLE(int value)
Sets the specified 24-bit medium integer at the currentwriterIndex
in the Little Endian Byte Order and increases thewriterIndex
by3
in this buffer.int
writerIndex()
Returns thewriterIndex
of this buffer.Buffer
writerIndex(int writerIndex)
Sets thewriterIndex
of this buffer.Buffer
writeShort(int value)
Sets the specified 16-bit short integer at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer.Buffer
writeShortLE(int value)
Sets the specified 16-bit short integer in the Little Endian Byte Order at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer.Buffer
writeUtf8(java.lang.CharSequence seq)
Encode aCharSequence
in UTF-8 and write it to this buffer starting atwriterIndex
and increases thewriterIndex
by the number of the transferred bytes.Buffer
writeUtf8(java.lang.CharSequence seq, int ensureWritable)
Encode aCharSequence
in UTF-8 and write it to this buffer starting atwriterIndex
and increases thewriterIndex
by the number of the transferred bytes.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.servicetalk.buffer.api.Buffer
equals, hashCode, toString, tryEnsureWritable
-
-
-
-
Field Detail
-
EMPTY_BUFFER
public static final EmptyBuffer EMPTY_BUFFER
An instance ofEmptyBuffer
that can be shared.
-
-
Method Detail
-
capacity
public int capacity()
Description copied from interface:Buffer
Returns the number of bytes (octets) this buffer can contain.
-
capacity
public Buffer capacity(int newCapacity)
Description copied from interface:Buffer
Sets the capacity of this buffer. If thenewCapacity
is less than the current capacity, the content of this buffer is truncated. If thenewCapacity
is greater than the current capacity, the buffer is appended with unspecified data whose length is(newCapacity - currentCapacity)
.
-
maxCapacity
public int maxCapacity()
Description copied from interface:Buffer
Returns the maximum allowed capacity of this buffer. This value provides an upper bound onBuffer.capacity()
.- Specified by:
maxCapacity
in interfaceBuffer
- Returns:
- the max capacity of this buffer.
-
readerIndex
public int readerIndex()
Description copied from interface:Buffer
Returns thereaderIndex
of this buffer.- Specified by:
readerIndex
in interfaceBuffer
- Returns:
- the
readerIndex
of this buffer.
-
readerIndex
public Buffer readerIndex(int readerIndex)
Description copied from interface:Buffer
Sets thereaderIndex
of this buffer.- Specified by:
readerIndex
in interfaceBuffer
- Parameters:
readerIndex
- the new readerIndex of this buffer.- Returns:
- itself.
-
writerIndex
public int writerIndex()
Description copied from interface:Buffer
Returns thewriterIndex
of this buffer.- Specified by:
writerIndex
in interfaceBuffer
- Returns:
- the
writerIndex
of this buffer.
-
writerIndex
public Buffer writerIndex(int writerIndex)
Description copied from interface:Buffer
Sets thewriterIndex
of this buffer.- Specified by:
writerIndex
in interfaceBuffer
- Parameters:
writerIndex
- the new writerIndex of this buffer.- Returns:
- itself.
-
readableBytes
public int readableBytes()
Description copied from interface:Buffer
Returns the number of readable bytes which is equal to(this.writerIndex - this.readerIndex)
.- Specified by:
readableBytes
in interfaceBuffer
- Returns:
- the number of readables bytes in this buffer.
-
writableBytes
public int writableBytes()
Description copied from interface:Buffer
Returns the number of writable bytes which is equal to(this.capacity - this.writerIndex)
.- Specified by:
writableBytes
in interfaceBuffer
- Returns:
- the number of writable bytes in this buffer.
-
maxWritableBytes
public int maxWritableBytes()
Description copied from interface:Buffer
Returns the maximum possible number of writable bytes, which is equal to(this.maxCapacity - this.writerIndex)
.- Specified by:
maxWritableBytes
in interfaceBuffer
- Returns:
- the maximum possible number of writable bytes in this buffer.
-
ensureWritable
public Buffer ensureWritable(int minWritableBytes)
Description copied from interface:Buffer
Expands the bufferBuffer.capacity()
to make sure the number of writable bytes is equal to or greater than the specified value. If there are enough writable bytes in this buffer, this method returns with no side effect.- Specified by:
ensureWritable
in interfaceBuffer
- Parameters:
minWritableBytes
- the expected minimum number of writable bytes- Returns:
- this object.
-
ensureWritable
public int ensureWritable(int minWritableBytes, boolean force)
Description copied from interface:Buffer
Expands the bufferBuffer.capacity()
to make sure the number of writable bytes is equal to or greater than the specified value. UnlikeBuffer.ensureWritable(int)
, this method returns a status code.- Specified by:
ensureWritable
in interfaceBuffer
- Parameters:
minWritableBytes
- the expected minimum number of writable bytesforce
- WhenBuffer.writerIndex()
+minWritableBytes
>Buffer.maxCapacity()
:true
- the capacity of the buffer is expanded toBuffer.maxCapacity()
false
- the capacity of the buffer is unchanged
- Returns:
0
if the buffer has enough writable bytes, and its capacity is unchanged.1
if the buffer does not have enough bytes, and its capacity is unchanged.2
if the buffer has enough writable bytes, and its capacity has been increased.3
if the buffer does not have enough bytes, but its capacity has been increased to its maximum.
-
clear
public Buffer clear()
Description copied from interface:Buffer
Sets thereaderIndex
andwriterIndex
of this buffer to0
.Please note that the behavior of this method is different from that of NIO buffer, which sets the
limit
to thecapacity
of the buffer.
-
getBoolean
public boolean getBoolean(int index)
Description copied from interface:Buffer
Gets a boolean at the specified absolute (@code index) in this buffer. This method does not modify thereaderIndex
orwriterIndex
of this buffer.- Specified by:
getBoolean
in interfaceBuffer
- Parameters:
index
- absolute (@code index) in this buffer.- Returns:
- a boolean.
-
getByte
public byte getByte(int index)
Description copied from interface:Buffer
Gets a byte at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
getUnsignedByte
public short getUnsignedByte(int index)
Description copied from interface:Buffer
Gets an unsigned byte at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
getUnsignedByte
in interfaceBuffer
- Parameters:
index
- absolute (@code index) in this buffer.- Returns:
- an unsigned byte.
-
getShort
public short getShort(int index)
Description copied from interface:Buffer
Gets a 16-bit short integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
getShortLE
public short getShortLE(int index)
Description copied from interface:Buffer
Gets a 16-bit short integer at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
getShortLE
in interfaceBuffer
- Parameters:
index
- absolute (@code index) in this buffer.- Returns:
- a short.
-
getUnsignedShort
public int getUnsignedShort(int index)
Description copied from interface:Buffer
Gets an unsigned 16-bit short integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
getUnsignedShort
in interfaceBuffer
- Parameters:
index
- absolute (@code index) in this buffer.- Returns:
- a short.
-
getUnsignedShortLE
public int getUnsignedShortLE(int index)
Description copied from interface:Buffer
Gets an unsigned 16-bit short integer at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
getUnsignedShortLE
in interfaceBuffer
- Parameters:
index
- absolute (@code index) in this buffer.- Returns:
- a short.
-
getMedium
public int getMedium(int index)
Description copied from interface:Buffer
Gets a 24-bit medium integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
getMediumLE
public int getMediumLE(int index)
Description copied from interface:Buffer
Gets a 24-bit medium integer at the specified absoluteindex
in this buffer in the Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
getMediumLE
in interfaceBuffer
- Parameters:
index
- absolute (@code index) in this buffer.- Returns:
- a medium int.
-
getUnsignedMedium
public int getUnsignedMedium(int index)
Description copied from interface:Buffer
Gets an unsigned 24-bit medium integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
getUnsignedMedium
in interfaceBuffer
- Parameters:
index
- absolute (@code index) in this buffer.- Returns:
- a medium in.
-
getUnsignedMediumLE
public int getUnsignedMediumLE(int index)
Description copied from interface:Buffer
Gets an unsigned 24-bit medium integer at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
getUnsignedMediumLE
in interfaceBuffer
- Parameters:
index
- absolute (@code index) in this buffer.- Returns:
- a medium int.
-
getInt
public int getInt(int index)
Description copied from interface:Buffer
Gets a 32-bit integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
getIntLE
public int getIntLE(int index)
Description copied from interface:Buffer
Gets a 32-bit integer at the specified absoluteindex
in this buffer with Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
getUnsignedInt
public long getUnsignedInt(int index)
Description copied from interface:Buffer
Gets an unsigned 32-bit integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
getUnsignedInt
in interfaceBuffer
- Parameters:
index
- absolute (@code index) in this buffer.- Returns:
- a unsigned int.
-
getUnsignedIntLE
public long getUnsignedIntLE(int index)
Description copied from interface:Buffer
Gets an unsigned 32-bit integer at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
getUnsignedIntLE
in interfaceBuffer
- Parameters:
index
- absolute (@code index) in this buffer.- Returns:
- a unsigned int.
-
getLong
public long getLong(int index)
Description copied from interface:Buffer
Gets a 64-bit long integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
getLongLE
public long getLongLE(int index)
Description copied from interface:Buffer
Gets a 64-bit long integer at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
getChar
public char getChar(int index)
Description copied from interface:Buffer
Gets a 2-byte UTF-16 character at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
getFloat
public float getFloat(int index)
Description copied from interface:Buffer
Gets a 32-bit floating point number at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
getDouble
public double getDouble(int index)
Description copied from interface:Buffer
Gets a 64-bit floating point number at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
getBytes
public Buffer getBytes(int index, Buffer dst)
Description copied from interface:Buffer
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
until the destination becomes non-writable. This method is basically same withBuffer.getBytes(int, Buffer, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes whileBuffer.getBytes(int, Buffer, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of the source buffer (i.e.this
).
-
getBytes
public Buffer getBytes(int index, Buffer dst, int length)
Description copied from interface:Buffer
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method is basically same withBuffer.getBytes(int, Buffer, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes whileBuffer.getBytes(int, Buffer, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of the source buffer (i.e.this
).
-
getBytes
public Buffer getBytes(int index, Buffer dst, int dstIndex, int length)
Description copied from interface:Buffer
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of both the source (i.e.this
) and the destination.
-
getBytes
public Buffer getBytes(int index, byte[] dst)
Description copied from interface:Buffer
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer
-
getBytes
public Buffer getBytes(int index, byte[] dst, int dstIndex, int length)
Description copied from interface:Buffer
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
getBytes
public Buffer getBytes(int index, java.nio.ByteBuffer dst)
Description copied from interface:Buffer
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
until the destination's position reaches its limit. This method does not modifyreaderIndex
orwriterIndex
of this buffer while the destination'sposition
will be increased.
-
setBoolean
public Buffer setBoolean(int index, boolean value)
Description copied from interface:Buffer
Sets the specified boolean at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
setBoolean
in interfaceBuffer
- Parameters:
index
- absolute (@code index) in this buffer.value
- the value.- Returns:
- itself.
-
setByte
public Buffer setByte(int index, int value)
Description copied from interface:Buffer
Sets the specified byte at the specified absoluteindex
in this buffer. The 24 high-order bits of the specified value are ignored. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
setShort
public Buffer setShort(int index, int value)
Description copied from interface:Buffer
Sets the specified 16-bit short integer at the specified absoluteindex
in this buffer. The 16 high-order bits of the specified value are ignored. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
setShortLE
public Buffer setShortLE(int index, int value)
Description copied from interface:Buffer
Sets the specified 16-bit short integer at the specified absoluteindex
in this buffer with the Little Endian Byte Order. The 16 high-order bits of the specified value are ignored. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
setShortLE
in interfaceBuffer
- Parameters:
index
- absolute (@code index) in this buffer.value
- the value.- Returns:
- itself.
-
setMedium
public Buffer setMedium(int index, int value)
Description copied from interface:Buffer
Sets the specified 24-bit medium integer at the specified absoluteindex
in this buffer. Please note that the most significant byte is ignored in the specified value. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
setMediumLE
public Buffer setMediumLE(int index, int value)
Description copied from interface:Buffer
Sets the specified 24-bit medium integer at the specified absoluteindex
in this buffer in the Little Endian Byte Order. Please note that the most significant byte is ignored in the specified value. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
setMediumLE
in interfaceBuffer
- Parameters:
index
- absolute (@code index) in this buffer.value
- the value.- Returns:
- itself.
-
setInt
public Buffer setInt(int index, int value)
Description copied from interface:Buffer
Sets the specified 32-bit integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
setIntLE
public Buffer setIntLE(int index, int value)
Description copied from interface:Buffer
Sets the specified 32-bit integer at the specified absoluteindex
in this buffer with Little Endian byte order . This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
setLong
public Buffer setLong(int index, long value)
Description copied from interface:Buffer
Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
setLongLE
public Buffer setLongLE(int index, long value)
Description copied from interface:Buffer
Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
setChar
public Buffer setChar(int index, int value)
Description copied from interface:Buffer
Sets the specified 2-byte UTF-16 character at the specified absoluteindex
in this buffer. The 16 high-order bits of the specified value are ignored. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
setFloat
public Buffer setFloat(int index, float value)
Description copied from interface:Buffer
Sets the specified 32-bit floating-point number at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
setDouble
public Buffer setDouble(int index, double value)
Description copied from interface:Buffer
Sets the specified 64-bit floating-point number at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
setBytes
public Buffer setBytes(int index, Buffer src)
Description copied from interface:Buffer
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
until the source buffer becomes unreadable. This method is basically same withBuffer.setBytes(int, Buffer, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes whileBuffer.setBytes(int, Buffer, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of the source buffer (i.e.this
).
-
setBytes
public Buffer setBytes(int index, Buffer src, int length)
Description copied from interface:Buffer
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
. This method is basically same withBuffer.setBytes(int, Buffer, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes whileBuffer.setBytes(int, Buffer, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of the source buffer (i.e.this
).
-
setBytes
public Buffer setBytes(int index, Buffer src, int srcIndex, int length)
Description copied from interface:Buffer
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of both the source (i.e.this
) and the destination.
-
setBytes
public Buffer setBytes(int index, byte[] src)
Description copied from interface:Buffer
Transfers the specified source array's data to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
setBytes
public Buffer setBytes(int index, byte[] src, int srcIndex, int length)
Description copied from interface:Buffer
Transfers the specified source array's data to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
setBytes
public Buffer setBytes(int index, java.nio.ByteBuffer src)
Description copied from interface:Buffer
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
until the source buffer's position reaches its limit. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
setBytes
public int setBytes(int index, java.io.InputStream src, int length) throws java.io.IOException
Description copied from interface:Buffer
Transfers a fixed amount from the specified source InputStream's data to this buffer starting at the specified absoluteindex
untillength
bytes have been read, the end of stream is reached, or an exception is thrown.This method does not modify
readerIndex
orwriterIndex
of this buffer.- Specified by:
setBytes
in interfaceBuffer
- Parameters:
index
- absolute (@code index) in this buffer.src
- the source InputStream.length
- the maximum number of bytes to transfer. The buffer may be resized to accommodate this amount of data.- Returns:
- the actual number of bytes read in from
src
.-1
if the specified channel is closed. - Throws:
java.io.IOException
- if the InputStream throws an exception while being read from.
-
setBytesUntilEndStream
public int setBytesUntilEndStream(int index, java.io.InputStream src, int chunkSize)
Description copied from interface:Buffer
Transfers all the specified source InputStream's data to this buffer starting at the specified absoluteindex
until the end of stream is reached or an exception is thrown.This method does not modify
readerIndex
orwriterIndex
of this buffer.This method may modify the underlying storage size of this array to accomidate for reading data.
- Specified by:
setBytesUntilEndStream
in interfaceBuffer
- Parameters:
index
- absolute (@code index) in this buffer.src
- the source InputStream.chunkSize
- chunkSize the amount of data that will be read fromsrc
on each read attempt.- Returns:
- the actual total number of bytes read in from
src
.-1
if no bytes were read because the specified InputStream was closed when this method was called.
-
readBoolean
public boolean readBoolean()
Description copied from interface:Buffer
Gets a boolean at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.- Specified by:
readBoolean
in interfaceBuffer
- Returns:
- a boolean.
-
readByte
public byte readByte()
Description copied from interface:Buffer
Gets a byte at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.
-
readUnsignedByte
public short readUnsignedByte()
Description copied from interface:Buffer
Gets an unsigned byte at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.- Specified by:
readUnsignedByte
in interfaceBuffer
- Returns:
- a byte.
-
readShort
public short readShort()
Description copied from interface:Buffer
Gets a 16-bit short integer at the currentreaderIndex
and increases thereaderIndex
by2
in this buffer.
-
readShortLE
public short readShortLE()
Description copied from interface:Buffer
Gets a 16-bit short integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by2
in this buffer.- Specified by:
readShortLE
in interfaceBuffer
- Returns:
- a short.
-
readUnsignedShort
public int readUnsignedShort()
Description copied from interface:Buffer
Gets an unsigned 16-bit short integer at the currentreaderIndex
and increases thereaderIndex
by2
in this buffer.- Specified by:
readUnsignedShort
in interfaceBuffer
- Returns:
- a short.
-
readUnsignedShortLE
public int readUnsignedShortLE()
Description copied from interface:Buffer
Gets an unsigned 16-bit short integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by2
in this buffer.- Specified by:
readUnsignedShortLE
in interfaceBuffer
- Returns:
- a short.
-
readMedium
public int readMedium()
Description copied from interface:Buffer
Gets a 24-bit medium integer at the currentreaderIndex
and increases thereaderIndex
by3
in this buffer.- Specified by:
readMedium
in interfaceBuffer
- Returns:
- a medium int.
-
readMediumLE
public int readMediumLE()
Description copied from interface:Buffer
Gets a 24-bit medium integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by3
in this buffer.- Specified by:
readMediumLE
in interfaceBuffer
- Returns:
- a medium int.
-
readUnsignedMedium
public int readUnsignedMedium()
Description copied from interface:Buffer
Gets an unsigned 24-bit medium integer at the currentreaderIndex
and increases thereaderIndex
by3
in this buffer.- Specified by:
readUnsignedMedium
in interfaceBuffer
- Returns:
- a medium int.
-
readUnsignedMediumLE
public int readUnsignedMediumLE()
Description copied from interface:Buffer
Gets an unsigned 24-bit medium integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by3
in this buffer.- Specified by:
readUnsignedMediumLE
in interfaceBuffer
- Returns:
- a medium int.
-
readInt
public int readInt()
Description copied from interface:Buffer
Gets a 32-bit integer at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.
-
readIntLE
public int readIntLE()
Description copied from interface:Buffer
Gets a 32-bit integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by4
in this buffer.
-
readUnsignedInt
public long readUnsignedInt()
Description copied from interface:Buffer
Gets an unsigned 32-bit integer at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.- Specified by:
readUnsignedInt
in interfaceBuffer
- Returns:
- a int.
-
readUnsignedIntLE
public long readUnsignedIntLE()
Description copied from interface:Buffer
Gets an unsigned 32-bit integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by4
in this buffer.- Specified by:
readUnsignedIntLE
in interfaceBuffer
- Returns:
- a int.
-
readLong
public long readLong()
Description copied from interface:Buffer
Gets a 64-bit integer at the currentreaderIndex
and increases thereaderIndex
by8
in this buffer.
-
readLongLE
public long readLongLE()
Description copied from interface:Buffer
Gets a 64-bit integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by8
in this buffer.- Specified by:
readLongLE
in interfaceBuffer
- Returns:
- a long.
-
readChar
public char readChar()
Description copied from interface:Buffer
Gets a 2-byte UTF-16 character at the currentreaderIndex
and increases thereaderIndex
by2
in this buffer.
-
readFloat
public float readFloat()
Description copied from interface:Buffer
Gets a 32-bit floating point number at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.
-
readDouble
public double readDouble()
Description copied from interface:Buffer
Gets a 64-bit floating point number at the currentreaderIndex
and increases thereaderIndex
by8
in this buffer.- Specified by:
readDouble
in interfaceBuffer
- Returns:
- a double.
-
readSlice
public Buffer readSlice(int length)
Description copied from interface:Buffer
Returns a new slice of this buffer's sub-region starting at the currentreaderIndex
and increases thereaderIndex
by the size of the new slice (=length
).
-
readBytes
public Buffer readBytes(int length)
Description copied from interface:Buffer
Transfers this buffer's data to a newly created buffer starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
). The returned buffer'sreaderIndex
andwriterIndex
are0
andlength
respectively.
-
readBytes
public Buffer readBytes(Buffer dst)
Description copied from interface:Buffer
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
until the destination becomes non-writable, and increases thereaderIndex
by the number of the transferred bytes. This method is basically same withBuffer.readBytes(Buffer, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes whileBuffer.readBytes(Buffer, int, int)
does not.
-
readBytes
public Buffer readBytes(Buffer dst, int length)
Description copied from interface:Buffer
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
). This method is basically same withBuffer.readBytes(Buffer, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes (=length
) whileBuffer.readBytes(Buffer, int, int)
does not.
-
readBytes
public Buffer readBytes(Buffer dst, int dstIndex, int length)
Description copied from interface:Buffer
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).
-
readBytes
public Buffer readBytes(byte[] dst)
Description copied from interface:Buffer
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=dst.length
).
-
readBytes
public Buffer readBytes(byte[] dst, int dstIndex, int length)
Description copied from interface:Buffer
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).
-
readBytes
public Buffer readBytes(java.nio.ByteBuffer dst)
Description copied from interface:Buffer
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
until the destination's position reaches its limit, and increases thereaderIndex
by the number of the transferred bytes.
-
skipBytes
public Buffer skipBytes(int length)
Description copied from interface:Buffer
Increases the currentreaderIndex
by the specifiedlength
in this buffer.
-
writeBoolean
public Buffer writeBoolean(boolean value)
Description copied from interface:Buffer
Sets the specified boolean at the currentwriterIndex
and increases thewriterIndex
by1
in this buffer. Ifthis.writableBytes
is less than1
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Specified by:
writeBoolean
in interfaceBuffer
- Parameters:
value
- the value to write.- Returns:
- self.
-
writeByte
public Buffer writeByte(int value)
Description copied from interface:Buffer
Sets the specified byte at the currentwriterIndex
and increases thewriterIndex
by1
in this buffer. The 24 high-order bits of the specified value are ignored. Ifthis.writableBytes
is less than1
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.
-
writeShort
public Buffer writeShort(int value)
Description copied from interface:Buffer
Sets the specified 16-bit short integer at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer. The 16 high-order bits of the specified value are ignored. Ifthis.writableBytes
is less than2
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Specified by:
writeShort
in interfaceBuffer
- Parameters:
value
- the value to write.- Returns:
- self.
-
writeShortLE
public Buffer writeShortLE(int value)
Description copied from interface:Buffer
Sets the specified 16-bit short integer in the Little Endian Byte Order at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer. The 16 high-order bits of the specified value are ignored. Ifthis.writableBytes
is less than2
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Specified by:
writeShortLE
in interfaceBuffer
- Parameters:
value
- the value to write.- Returns:
- self.
-
writeMedium
public Buffer writeMedium(int value)
Description copied from interface:Buffer
Sets the specified 24-bit medium integer at the currentwriterIndex
and increases thewriterIndex
by3
in this buffer. Ifthis.writableBytes
is less than3
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Specified by:
writeMedium
in interfaceBuffer
- Parameters:
value
- the value to write.- Returns:
- self.
-
writeMediumLE
public Buffer writeMediumLE(int value)
Description copied from interface:Buffer
Sets the specified 24-bit medium integer at the currentwriterIndex
in the Little Endian Byte Order and increases thewriterIndex
by3
in this buffer. Ifthis.writableBytes
is less than3
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Specified by:
writeMediumLE
in interfaceBuffer
- Parameters:
value
- the value to write.- Returns:
- self.
-
writeInt
public Buffer writeInt(int value)
Description copied from interface:Buffer
Sets the specified 32-bit integer at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer. Ifthis.writableBytes
is less than4
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.
-
writeIntLE
public Buffer writeIntLE(int value)
Description copied from interface:Buffer
Sets the specified 32-bit integer at the currentwriterIndex
in the Little Endian Byte Order and increases thewriterIndex
by4
in this buffer. Ifthis.writableBytes
is less than4
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Specified by:
writeIntLE
in interfaceBuffer
- Parameters:
value
- the value to write.- Returns:
- self.
-
writeLong
public Buffer writeLong(long value)
Description copied from interface:Buffer
Sets the specified 64-bit long integer at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer. Ifthis.writableBytes
is less than8
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.
-
writeLongLE
public Buffer writeLongLE(long value)
Description copied from interface:Buffer
Sets the specified 64-bit long integer at the currentwriterIndex
in the Little Endian Byte Order and increases thewriterIndex
by8
in this buffer. Ifthis.writableBytes
is less than8
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Specified by:
writeLongLE
in interfaceBuffer
- Parameters:
value
- the value to write.- Returns:
- self.
-
writeChar
public Buffer writeChar(int value)
Description copied from interface:Buffer
Sets the specified 2-byte UTF-16 character at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer. The 16 high-order bits of the specified value are ignored. Ifthis.writableBytes
is less than2
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.
-
writeFloat
public Buffer writeFloat(float value)
Description copied from interface:Buffer
Sets the specified 32-bit floating point number at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer. Ifthis.writableBytes
is less than4
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Specified by:
writeFloat
in interfaceBuffer
- Parameters:
value
- the value to write.- Returns:
- self.
-
writeDouble
public Buffer writeDouble(double value)
Description copied from interface:Buffer
Sets the specified 64-bit floating point number at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer. Ifthis.writableBytes
is less than8
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Specified by:
writeDouble
in interfaceBuffer
- Parameters:
value
- the value to write.- Returns:
- self.
-
writeBytes
public Buffer writeBytes(Buffer src)
Description copied from interface:Buffer
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
until the source buffer becomes unreadable, and increases thewriterIndex
by the number of the transferred bytes. This method is basically same withBuffer.writeBytes(Buffer, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes whileBuffer.writeBytes(Buffer, int, int)
does not. Ifthis.writableBytes
is less thansrc.readableBytes
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Specified by:
writeBytes
in interfaceBuffer
- Parameters:
src
- the buffer to write.- Returns:
- self.
-
writeBytes
public Buffer writeBytes(Buffer src, int length)
Description copied from interface:Buffer
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
). This method is basically same withBuffer.writeBytes(Buffer, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes (=length
) whileBuffer.writeBytes(Buffer, int, int)
does not. Ifthis.writableBytes
is less thanlength
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Specified by:
writeBytes
in interfaceBuffer
- Parameters:
src
- the buffer to write.length
- the number of bytes to transfer- Returns:
- self.
-
writeBytes
public Buffer writeBytes(Buffer src, int srcIndex, int length)
Description copied from interface:Buffer
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
). Ifthis.writableBytes
is less thanlength
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Specified by:
writeBytes
in interfaceBuffer
- Parameters:
src
- the buffer to write.srcIndex
- the first index of the sourcelength
- the number of bytes to transfer- Returns:
- self.
-
writeBytes
public Buffer writeBytes(byte[] src)
Description copied from interface:Buffer
Transfers the specified source array's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=src.length
). Ifthis.writableBytes
is less thansrc.length
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Specified by:
writeBytes
in interfaceBuffer
- Parameters:
src
- the array to write.- Returns:
- self.
-
writeBytes
public Buffer writeBytes(byte[] src, int srcIndex, int length)
Description copied from interface:Buffer
Transfers the specified source array's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
). Ifthis.writableBytes
is less thanlength
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Specified by:
writeBytes
in interfaceBuffer
- Parameters:
src
- the array to write.srcIndex
- the first index of the sourcelength
- the number of bytes to transfer- Returns:
- self.
-
writeBytes
public Buffer writeBytes(java.nio.ByteBuffer src)
Description copied from interface:Buffer
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
until the source buffer's position reaches its limit, and increases thewriterIndex
by the number of the transferred bytes. Ifthis.writableBytes
is less thansrc.remaining()
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Specified by:
writeBytes
in interfaceBuffer
- Parameters:
src
- the source buffer to write.- Returns:
- self.
-
writeBytes
public int writeBytes(java.io.InputStream src, int length)
Description copied from interface:Buffer
Transfers ta fixed amount from the specified sourceInputStream
's data to this buffer starting at the currentwriterIndex
untillength
bytes have been read, the end of stream is reached, or an exception is thrown. Ifthis.writableBytes
is less thanlength
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.This method will increase the
writerIndex
by the number of the transferred bytes if the write operation was successful.- Specified by:
writeBytes
in interfaceBuffer
- Parameters:
src
- the sourceInputStream
to write.length
- the maximum number of bytes to transfer. The buffer may be resized to accommodate this amount of data.- Returns:
- the actual number of bytes read in from
src
.-1
if the specified channel is closed.
-
writeBytesUntilEndStream
public int writeBytesUntilEndStream(java.io.InputStream src, int chunkSize)
Description copied from interface:Buffer
Transfers all the specified sourceInputStream
's data to this buffer starting at the currentwriterIndex
until the end of stream is reached or an exception is thrown. Ifthis.writableBytes
is less than the number of bytes in theInputStream
,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate. Note that becauseInputStream
does not provide a reliable way to get the remaining bytes, this method may over allocate by a factor ofchunkSize
.This method will increase the
writerIndex
by the number of the transferred bytes if the write operation was successful.- Specified by:
writeBytesUntilEndStream
in interfaceBuffer
- Parameters:
src
- the sourceInputStream
to write.chunkSize
- the amount of data that will be read fromsrc
on each read attempt.- Returns:
- the actual total number of bytes read in from
src
.-1
if no bytes were read because the specifiedInputStream
was closed when this method was called.
-
writeAscii
public Buffer writeAscii(java.lang.CharSequence seq)
Description copied from interface:Buffer
Encode aCharSequence
in ASCII and write it to this buffer starting atwriterIndex
and increases thewriterIndex
by the number of the transferred bytes. Ifthis.writableBytes
is not large enough to write the whole sequence,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Specified by:
writeAscii
in interfaceBuffer
- Parameters:
seq
- the source of the data.- Returns:
- self.
-
writeUtf8
public Buffer writeUtf8(java.lang.CharSequence seq)
Description copied from interface:Buffer
Encode aCharSequence
in UTF-8 and write it to this buffer starting atwriterIndex
and increases thewriterIndex
by the number of the transferred bytes. Ifthis.writableBytes
is not large enough to write the whole sequence,Buffer.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.
-
writeUtf8
public Buffer writeUtf8(java.lang.CharSequence seq, int ensureWritable)
Description copied from interface:Buffer
Encode aCharSequence
in UTF-8 and write it to this buffer starting atwriterIndex
and increases thewriterIndex
by the number of the transferred bytes.
-
indexOf
public int indexOf(int fromIndex, int toIndex, byte value)
Description copied from interface:Buffer
Locates the first occurrence of the specifiedvalue
in this buffer. The search takes place from the specifiedfromIndex
(inclusive) to the specifiedtoIndex
(exclusive).If
fromIndex
is greater thantoIndex
, the search is performed in a reversed order.This method does not modify
readerIndex
orwriterIndex
of this buffer.
-
bytesBefore
public int bytesBefore(byte value)
Description copied from interface:Buffer
Locates the first occurrence of the specifiedvalue
in this buffer. The search takes place from the currentreaderIndex
(inclusive) to the currentwriterIndex
(exclusive).This method does not modify
readerIndex
orwriterIndex
of this buffer.- Specified by:
bytesBefore
in interfaceBuffer
- Parameters:
value
- the value to search.- Returns:
- the number of bytes between the current
readerIndex
and the first occurrence if found.-1
otherwise.
-
bytesBefore
public int bytesBefore(int length, byte value)
Description copied from interface:Buffer
Locates the first occurrence of the specifiedvalue
in this buffer. The search starts from the currentreaderIndex
(inclusive) and lasts for the specifiedlength
.This method does not modify
readerIndex
orwriterIndex
of this buffer.- Specified by:
bytesBefore
in interfaceBuffer
- Parameters:
length
- the length.value
- the value to search.- Returns:
- the number of bytes between the current
readerIndex
and the first occurrence if found.-1
otherwise.
-
bytesBefore
public int bytesBefore(int index, int length, byte value)
Description copied from interface:Buffer
Locates the first occurrence of the specifiedvalue
in this buffer. The search starts from the specifiedindex
(inclusive) and lasts for the specifiedlength
.This method does not modify
readerIndex
orwriterIndex
of this buffer.- Specified by:
bytesBefore
in interfaceBuffer
- Parameters:
index
- the index.length
- the length.value
- the value to search.- Returns:
- the number of bytes between the specified
index
and the first occurrence if found.-1
otherwise.
-
copy
public Buffer copy()
Description copied from interface:Buffer
Returns a copy of this buffer's readable bytes. Modifying the content of the returned buffer or this buffer does not affect each other at all. This method is identical tobuf.copy(buf.readerIndex(), buf.readableBytes())
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
copy
public Buffer copy(int index, int length)
Description copied from interface:Buffer
Returns a copy of this buffer's sub-region. Modifying the content of the returned buffer or this buffer does not affect each other at all. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
slice
public Buffer slice()
Description copied from interface:Buffer
Returns a slice of this buffer's readable bytes. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes. This method is identical tobuf.slice(buf.readerIndex(), buf.readableBytes())
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
slice
public Buffer slice(int index, int length)
Description copied from interface:Buffer
Returns a slice of this buffer's sub-region. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
duplicate
public Buffer duplicate()
Description copied from interface:Buffer
Returns a buffer which shares the whole region of this buffer. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes. This method is identical tobuf.slice(0, buf.capacity())
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
nioBufferCount
public int nioBufferCount()
Description copied from interface:Buffer
Returns the maximum number of NIOByteBuffer
s that consist this buffer. Note thatBuffer.toNioBuffers()
orBuffer.toNioBuffers(int, int)
might return a less number ofByteBuffer
s.- Specified by:
nioBufferCount
in interfaceBuffer
- Returns:
-1
if this buffer has no underlyingByteBuffer
. the number of the underlyingByteBuffer
s if this buffer has at least one underlyingByteBuffer
. Note that this method does not return0
to avoid confusion.- See Also:
Buffer.toNioBuffer()
,Buffer.toNioBuffer(int, int)
,Buffer.toNioBuffers()
,Buffer.toNioBuffers(int, int)
-
toNioBuffer
public java.nio.ByteBuffer toNioBuffer()
Description copied from interface:Buffer
Exposes this buffer's readable bytes as an NIOByteBuffer
. The returned buffer shares the content with this buffer, while changing the position and limit of the returned NIO buffer does not affect the indexes of this buffer. This method is identical tobuf.nioBuffer(buf.readerIndex(), buf.readableBytes())
. This method does not modifyreaderIndex
orwriterIndex
of this buffer. Please note that the returned NIO buffer will not see the changes of this buffer if this buffer is a dynamic buffer and it adjusted its capacity.- Specified by:
toNioBuffer
in interfaceBuffer
- Returns:
- the nio buffer.
- See Also:
Buffer.nioBufferCount()
,Buffer.toNioBuffers()
,Buffer.toNioBuffers(int, int)
-
toNioBuffer
public java.nio.ByteBuffer toNioBuffer(int index, int length)
Description copied from interface:Buffer
Exposes this buffer's sub-region as an NIOByteBuffer
. The returned buffer shares the content with this buffer, while changing the position and limit of the returned NIO buffer does not affect the indexes of this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer. Please note that the returned NIO buffer will not see the changes of this buffer if this buffer is a dynamic buffer and it adjusted its capacity.- Specified by:
toNioBuffer
in interfaceBuffer
- Parameters:
index
- the start index.length
- the length.- Returns:
- the nio buffer.
- See Also:
Buffer.nioBufferCount()
,Buffer.toNioBuffers()
,Buffer.toNioBuffers(int, int)
-
toNioBuffers
public java.nio.ByteBuffer[] toNioBuffers()
Description copied from interface:Buffer
Exposes this buffer's readable bytes as an NIOByteBuffer
's. The returned buffer shares the content with this buffer, while changing the position and limit of the returned NIO buffer does not affect the indexes of this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer. Please note that the returned NIO buffer will not see the changes of this buffer if this buffer is a dynamic buffer and it adjusted its capacity.- Specified by:
toNioBuffers
in interfaceBuffer
- Returns:
- the nio buffers.
- See Also:
Buffer.nioBufferCount()
,Buffer.toNioBuffer()
,Buffer.toNioBuffer(int, int)
-
toNioBuffers
public java.nio.ByteBuffer[] toNioBuffers(int index, int length)
Description copied from interface:Buffer
Exposes this buffer's bytes as an NIOByteBuffer
's for the specified index and length The returned buffer shares the content with this buffer, while changing the position and limit of the returned NIO buffer does not affect the indexes of this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer. Please note that the returned NIO buffer will not see the changes of this buffer if this buffer is a dynamic buffer and it adjusted its capacity.- Specified by:
toNioBuffers
in interfaceBuffer
- Parameters:
index
- the start index.length
- the length.- Returns:
- the nio buffers.
- See Also:
Buffer.nioBufferCount()
,Buffer.toNioBuffer()
,Buffer.toNioBuffer(int, int)
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:Buffer
Determine if this buffer is read-only.- Specified by:
isReadOnly
in interfaceBuffer
- Returns:
true
if and only if this buffer is read-only.
-
asReadOnly
public Buffer asReadOnly()
Description copied from interface:Buffer
Create a read-only view for this buffer.The returned read-only view shares indexes and content with the original
Buffer
. All methods that try to change the content will throwReadOnlyBufferException
. Modifications for indexes are allowed and will be propagated to the originalBuffer
. To prevent changes of indexes for the originalBuffer
useBuffer.duplicate()
before converting to a read-only view.- Specified by:
asReadOnly
in interfaceBuffer
- Returns:
- a buffer whose contents cannot be modified.
-
isDirect
public boolean isDirect()
Description copied from interface:Buffer
Returnstrue
if the buffer is direct and so not allocated on the heap.
-
hasArray
public boolean hasArray()
Description copied from interface:Buffer
Returnstrue
if and only if this buffer has a backing byte array. If this method returns true, you can safely callBuffer.array()
andBuffer.arrayOffset()
.
-
array
public byte[] array()
Description copied from interface:Buffer
Returns the backing byte array of this buffer.
-
arrayOffset
public int arrayOffset()
Description copied from interface:Buffer
Returns the offset of the first byte within the backing byte array of this buffer.- Specified by:
arrayOffset
in interfaceBuffer
- Returns:
- the offset in the array.
-
toString
public java.lang.String toString(java.nio.charset.Charset charset)
Description copied from interface:Buffer
Decodes this buffer's readable bytes into a string with the specified character set name. This method is identical tobuf.toString(buf.readerIndex(), buf.readableBytes(), charsetName)
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
toString
public java.lang.String toString(int index, int length, java.nio.charset.Charset charset)
Description copied from interface:Buffer
Decodes this buffer's sub-region into a string with the specified character set. This method does not modifyreaderIndex
orwriterIndex
of this buffer.
-
forEachByte
public int forEachByte(ByteProcessor processor)
Description copied from interface:Buffer
Iterates over the readable bytes of this buffer with the specifiedprocessor
in ascending order.- Specified by:
forEachByte
in interfaceBuffer
- Parameters:
processor
- theByteProcessor
to use.- Returns:
-1
if the processor iterated to or beyond the end of the readable bytes. The last-visited index If theByteProcessor.process(byte)
returnedfalse
.
-
forEachByte
public int forEachByte(int index, int length, ByteProcessor processor)
Description copied from interface:Buffer
Iterates over the specified area of this buffer with the specifiedprocessor
in ascending order. (i.e.index
,(index + 1)
, ..(index + length - 1)
)- Specified by:
forEachByte
in interfaceBuffer
- Parameters:
index
- The index to start iterating from.length
- The amount of bytes to iterate over.processor
- theByteProcessor
to use.- Returns:
-1
if the processor iterated to or beyond the end of the specified area. The last-visited index If theByteProcessor.process(byte)
returnedfalse
.
-
forEachByteDesc
public int forEachByteDesc(ByteProcessor processor)
Description copied from interface:Buffer
Iterates over the readable bytes of this buffer with the specifiedprocessor
in descending order.- Specified by:
forEachByteDesc
in interfaceBuffer
- Parameters:
processor
- theByteProcessor
to use.- Returns:
-1
if the processor iterated to or beyond the beginning of the readable bytes. The last-visited index If theByteProcessor.process(byte)
returnedfalse
.
-
forEachByteDesc
public int forEachByteDesc(int index, int length, ByteProcessor processor)
Description copied from interface:Buffer
Iterates over the specified area of this buffer with the specifiedprocessor
in descending order. (i.e.(index + length - 1)
,(index + length - 2)
, ...index
)- Specified by:
forEachByteDesc
in interfaceBuffer
- Parameters:
index
- The index to start iterating from.length
- The amount of bytes to iterate over.processor
- theByteProcessor
to use.- Returns:
-1
if the processor iterated to or beyond the beginning of the specified area. The last-visited index If theByteProcessor.process(byte)
returnedfalse
.
-
-