Class EmptyBuffer
- java.lang.Object
-
- io.servicetalk.buffer.api.EmptyBuffer
-
-
Field Summary
Fields Modifier and Type Field Description static EmptyBufferEMPTY_BUFFERAn instance ofEmptyBufferthat 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.intarrayOffset()Returns the offset of the first byte within the backing byte array of this buffer.BufferasReadOnly()Create a read-only view for this buffer.intbytesBefore(byte value)Locates the first occurrence of the specifiedvaluein this buffer.intbytesBefore(int length, byte value)Locates the first occurrence of the specifiedvaluein this buffer.intbytesBefore(int index, int length, byte value)Locates the first occurrence of the specifiedvaluein this buffer.intcapacity()Returns the number of bytes (octets) this buffer can contain.Buffercapacity(int newCapacity)Sets the capacity of this buffer.Bufferclear()Sets thereaderIndexandwriterIndexof this buffer to0.Buffercopy()Returns a copy of this buffer's readable bytes.Buffercopy(int index, int length)Returns a copy of this buffer's sub-region.Bufferduplicate()Returns a buffer which shares the whole region of this buffer.BufferensureWritable(int minWritableBytes)Expands the bufferBuffer.capacity()to make sure the number of writable bytes is equal to or greater than the specified value.intensureWritable(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.intforEachByte(int index, int length, ByteProcessor processor)Iterates over the specified area of this buffer with the specifiedprocessorin ascending order.intforEachByte(ByteProcessor processor)Iterates over the readable bytes of this buffer with the specifiedprocessorin ascending order.intforEachByteDesc(int index, int length, ByteProcessor processor)Iterates over the specified area of this buffer with the specifiedprocessorin descending order.intforEachByteDesc(ByteProcessor processor)Iterates over the readable bytes of this buffer with the specifiedprocessorin descending order.booleangetBoolean(int index)Gets a boolean at the specified absolute (@code index) in this buffer.bytegetByte(int index)Gets a byte at the specified absoluteindexin this buffer.BuffergetBytes(int index, byte[] dst)Transfers this buffer's data to the specified destination starting at the specified absoluteindex.BuffergetBytes(int index, byte[] dst, int dstIndex, int length)Transfers this buffer's data to the specified destination starting at the specified absoluteindex.BuffergetBytes(int index, Buffer dst)Transfers this buffer's data to the specified destination starting at the specified absoluteindexuntil the destination becomes non-writable.BuffergetBytes(int index, Buffer dst, int length)Transfers this buffer's data to the specified destination starting at the specified absoluteindex.BuffergetBytes(int index, Buffer dst, int dstIndex, int length)Transfers this buffer's data to the specified destination starting at the specified absoluteindex.BuffergetBytes(int index, java.nio.ByteBuffer dst)Transfers this buffer's data to the specified destination starting at the specified absoluteindexuntil the destination's position reaches its limit.chargetChar(int index)Gets a 2-byte UTF-16 character at the specified absoluteindexin this buffer.doublegetDouble(int index)Gets a 64-bit floating point number at the specified absoluteindexin this buffer.floatgetFloat(int index)Gets a 32-bit floating point number at the specified absoluteindexin this buffer.intgetInt(int index)Gets a 32-bit integer at the specified absoluteindexin this buffer.intgetIntLE(int index)Gets a 32-bit integer at the specified absoluteindexin this buffer with Little Endian Byte Order.longgetLong(int index)Gets a 64-bit long integer at the specified absoluteindexin this buffer.longgetLongLE(int index)Gets a 64-bit long integer at the specified absoluteindexin this buffer in Little Endian Byte Order.intgetMedium(int index)Gets a 24-bit medium integer at the specified absoluteindexin this buffer.intgetMediumLE(int index)Gets a 24-bit medium integer at the specified absoluteindexin this buffer in the Little Endian Byte Order.shortgetShort(int index)Gets a 16-bit short integer at the specified absoluteindexin this buffer.shortgetShortLE(int index)Gets a 16-bit short integer at the specified absoluteindexin this buffer in Little Endian Byte Order.shortgetUnsignedByte(int index)Gets an unsigned byte at the specified absoluteindexin this buffer.longgetUnsignedInt(int index)Gets an unsigned 32-bit integer at the specified absoluteindexin this buffer.longgetUnsignedIntLE(int index)Gets an unsigned 32-bit integer at the specified absoluteindexin this buffer in Little Endian Byte Order.intgetUnsignedMedium(int index)Gets an unsigned 24-bit medium integer at the specified absoluteindexin this buffer.intgetUnsignedMediumLE(int index)Gets an unsigned 24-bit medium integer at the specified absoluteindexin this buffer in Little Endian Byte Order.intgetUnsignedShort(int index)Gets an unsigned 16-bit short integer at the specified absoluteindexin this buffer.intgetUnsignedShortLE(int index)Gets an unsigned 16-bit short integer at the specified absoluteindexin this buffer in Little Endian Byte Order.booleanhasArray()Returnstrueif and only if this buffer has a backing byte array.intindexOf(int fromIndex, int toIndex, byte value)Locates the first occurrence of the specifiedvaluein this buffer.booleanisDirect()Returnstrueif the buffer is direct and so not allocated on the heap.booleanisReadOnly()Determine if this buffer is read-only.intmaxCapacity()Returns the maximum allowed capacity of this buffer.intmaxWritableBytes()Returns the maximum possible number of writable bytes, which is equal to(this.maxCapacity - this.writerIndex).intnioBufferCount()Returns the maximum number of NIOByteBuffers that consist this buffer.intreadableBytes()Returns the number of readable bytes which is equal to(this.writerIndex - this.readerIndex).booleanreadBoolean()Gets a boolean at the currentreaderIndexand increases thereaderIndexby1in this buffer.bytereadByte()Gets a byte at the currentreaderIndexand increases thereaderIndexby1in this buffer.BufferreadBytes(byte[] dst)Transfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=dst.length).BufferreadBytes(byte[] dst, int dstIndex, int length)Transfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length).BufferreadBytes(int length)Transfers this buffer's data to a newly created buffer starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length).BufferreadBytes(Buffer dst)Transfers this buffer's data to the specified destination starting at the currentreaderIndexuntil the destination becomes non-writable, and increases thereaderIndexby the number of the transferred bytes.BufferreadBytes(Buffer dst, int length)Transfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length).BufferreadBytes(Buffer dst, int dstIndex, int length)Transfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length).BufferreadBytes(java.nio.ByteBuffer dst)Transfers this buffer's data to the specified destination starting at the currentreaderIndexuntil the destination's position reaches its limit, and increases thereaderIndexby the number of the transferred bytes.charreadChar()Gets a 2-byte UTF-16 character at the currentreaderIndexand increases thereaderIndexby2in this buffer.doublereadDouble()Gets a 64-bit floating point number at the currentreaderIndexand increases thereaderIndexby8in this buffer.intreaderIndex()Returns thereaderIndexof this buffer.BufferreaderIndex(int readerIndex)Sets thereaderIndexof this buffer.floatreadFloat()Gets a 32-bit floating point number at the currentreaderIndexand increases thereaderIndexby4in this buffer.intreadInt()Gets a 32-bit integer at the currentreaderIndexand increases thereaderIndexby4in this buffer.intreadIntLE()Gets a 32-bit integer at the currentreaderIndexin the Little Endian Byte Order and increases thereaderIndexby4in this buffer.longreadLong()Gets a 64-bit integer at the currentreaderIndexand increases thereaderIndexby8in this buffer.longreadLongLE()Gets a 64-bit integer at the currentreaderIndexin the Little Endian Byte Order and increases thereaderIndexby8in this buffer.intreadMedium()Gets a 24-bit medium integer at the currentreaderIndexand increases thereaderIndexby3in this buffer.intreadMediumLE()Gets a 24-bit medium integer at the currentreaderIndexin the Little Endian Byte Order and increases thereaderIndexby3in this buffer.shortreadShort()Gets a 16-bit short integer at the currentreaderIndexand increases thereaderIndexby2in this buffer.shortreadShortLE()Gets a 16-bit short integer at the currentreaderIndexin the Little Endian Byte Order and increases thereaderIndexby2in this buffer.BufferreadSlice(int length)Returns a new slice of this buffer's sub-region starting at the currentreaderIndexand increases thereaderIndexby the size of the new slice (=length).shortreadUnsignedByte()Gets an unsigned byte at the currentreaderIndexand increases thereaderIndexby1in this buffer.longreadUnsignedInt()Gets an unsigned 32-bit integer at the currentreaderIndexand increases thereaderIndexby4in this buffer.longreadUnsignedIntLE()Gets an unsigned 32-bit integer at the currentreaderIndexin the Little Endian Byte Order and increases thereaderIndexby4in this buffer.intreadUnsignedMedium()Gets an unsigned 24-bit medium integer at the currentreaderIndexand increases thereaderIndexby3in this buffer.intreadUnsignedMediumLE()Gets an unsigned 24-bit medium integer at the currentreaderIndexin the Little Endian Byte Order and increases thereaderIndexby3in this buffer.intreadUnsignedShort()Gets an unsigned 16-bit short integer at the currentreaderIndexand increases thereaderIndexby2in this buffer.intreadUnsignedShortLE()Gets an unsigned 16-bit short integer at the currentreaderIndexin the Little Endian Byte Order and increases thereaderIndexby2in this buffer.BuffersetBoolean(int index, boolean value)Sets the specified boolean at the specified absoluteindexin this buffer.BuffersetByte(int index, int value)Sets the specified byte at the specified absoluteindexin this buffer.BuffersetBytes(int index, byte[] src)Transfers the specified source array's data to this buffer starting at the specified absoluteindex.BuffersetBytes(int index, byte[] src, int srcIndex, int length)Transfers the specified source array's data to this buffer starting at the specified absoluteindex.BuffersetBytes(int index, Buffer src)Transfers the specified source buffer's data to this buffer starting at the specified absoluteindexuntil the source buffer becomes unreadable.BuffersetBytes(int index, Buffer src, int length)Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex.BuffersetBytes(int index, Buffer src, int srcIndex, int length)Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex.intsetBytes(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 absoluteindexuntillengthbytes have been read, the end of stream is reached, or an exception is thrown.BuffersetBytes(int index, java.nio.ByteBuffer src)Transfers the specified source buffer's data to this buffer starting at the specified absoluteindexuntil the source buffer's position reaches its limit.intsetBytesUntilEndStream(int index, java.io.InputStream src, int chunkSize)Transfers all the specified source InputStream's data to this buffer starting at the specified absoluteindexuntil the end of stream is reached or an exception is thrown.BuffersetChar(int index, int value)Sets the specified 2-byte UTF-16 character at the specified absoluteindexin this buffer.BuffersetDouble(int index, double value)Sets the specified 64-bit floating-point number at the specified absoluteindexin this buffer.BuffersetFloat(int index, float value)Sets the specified 32-bit floating-point number at the specified absoluteindexin this buffer.BuffersetInt(int index, int value)Sets the specified 32-bit integer at the specified absoluteindexin this buffer.BuffersetIntLE(int index, int value)Sets the specified 32-bit integer at the specified absoluteindexin this buffer with Little Endian byte order .BuffersetLong(int index, long value)Sets the specified 64-bit long integer at the specified absoluteindexin this buffer.BuffersetLongLE(int index, long value)Sets the specified 64-bit long integer at the specified absoluteindexin this buffer in Little Endian Byte Order.BuffersetMedium(int index, int value)Sets the specified 24-bit medium integer at the specified absoluteindexin this buffer.BuffersetMediumLE(int index, int value)Sets the specified 24-bit medium integer at the specified absoluteindexin this buffer in the Little Endian Byte Order.BuffersetShort(int index, int value)Sets the specified 16-bit short integer at the specified absoluteindexin this buffer.BuffersetShortLE(int index, int value)Sets the specified 16-bit short integer at the specified absoluteindexin this buffer with the Little Endian Byte Order.BufferskipBytes(int length)Increases the currentreaderIndexby the specifiedlengthin this buffer.Bufferslice()Returns a slice of this buffer's readable bytes.Bufferslice(int index, int length)Returns a slice of this buffer's sub-region.java.nio.ByteBuffertoNioBuffer()Exposes this buffer's readable bytes as an NIOByteBuffer.java.nio.ByteBuffertoNioBuffer(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.StringtoString(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.StringtoString(java.nio.charset.Charset charset)Decodes this buffer's readable bytes into a string with the specified character set name.intwritableBytes()Returns the number of writable bytes which is equal to(this.capacity - this.writerIndex).BufferwriteAscii(java.lang.CharSequence seq)Encode aCharSequencein ASCII and write it to this buffer starting atwriterIndexand increases thewriterIndexby the number of the transferred bytes.BufferwriteBoolean(boolean value)Sets the specified boolean at the currentwriterIndexand increases thewriterIndexby1in this buffer.BufferwriteByte(int value)Sets the specified byte at the currentwriterIndexand increases thewriterIndexby1in this buffer.BufferwriteBytes(byte[] src)Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=src.length).BufferwriteBytes(byte[] src, int srcIndex, int length)Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).BufferwriteBytes(Buffer src)Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexuntil the source buffer becomes unreadable, and increases thewriterIndexby the number of the transferred bytes.BufferwriteBytes(Buffer src, int length)Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).BufferwriteBytes(Buffer src, int srcIndex, int length)Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).intwriteBytes(java.io.InputStream src, int length)Transfers ta fixed amount from the specified sourceInputStream's data to this buffer starting at the currentwriterIndexuntillengthbytes have been read, the end of stream is reached, or an exception is thrown.BufferwriteBytes(java.nio.ByteBuffer src)Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexuntil the source buffer's position reaches its limit, and increases thewriterIndexby the number of the transferred bytes.intwriteBytesUntilEndStream(java.io.InputStream src, int chunkSize)Transfers all the specified sourceInputStream's data to this buffer starting at the currentwriterIndexuntil the end of stream is reached or an exception is thrown.BufferwriteChar(int value)Sets the specified 2-byte UTF-16 character at the currentwriterIndexand increases thewriterIndexby2in this buffer.BufferwriteDouble(double value)Sets the specified 64-bit floating point number at the currentwriterIndexand increases thewriterIndexby8in this buffer.BufferwriteFloat(float value)Sets the specified 32-bit floating point number at the currentwriterIndexand increases thewriterIndexby4in this buffer.BufferwriteInt(int value)Sets the specified 32-bit integer at the currentwriterIndexand increases thewriterIndexby4in this buffer.BufferwriteIntLE(int value)Sets the specified 32-bit integer at the currentwriterIndexin the Little Endian Byte Order and increases thewriterIndexby4in this buffer.BufferwriteLong(long value)Sets the specified 64-bit long integer at the currentwriterIndexand increases thewriterIndexby8in this buffer.BufferwriteLongLE(long value)Sets the specified 64-bit long integer at the currentwriterIndexin the Little Endian Byte Order and increases thewriterIndexby8in this buffer.BufferwriteMedium(int value)Sets the specified 24-bit medium integer at the currentwriterIndexand increases thewriterIndexby3in this buffer.BufferwriteMediumLE(int value)Sets the specified 24-bit medium integer at the currentwriterIndexin the Little Endian Byte Order and increases thewriterIndexby3in this buffer.intwriterIndex()Returns thewriterIndexof this buffer.BufferwriterIndex(int writerIndex)Sets thewriterIndexof this buffer.BufferwriteShort(int value)Sets the specified 16-bit short integer at the currentwriterIndexand increases thewriterIndexby2in this buffer.BufferwriteShortLE(int value)Sets the specified 16-bit short integer in the Little Endian Byte Order at the currentwriterIndexand increases thewriterIndexby2in this buffer.BufferwriteUtf8(java.lang.CharSequence seq)Encode aCharSequencein UTF-8 and write it to this buffer starting atwriterIndexand increases thewriterIndexby the number of the transferred bytes.BufferwriteUtf8(java.lang.CharSequence seq, int ensureWritable)Encode aCharSequencein UTF-8 and write it to this buffer starting atwriterIndexand increases thewriterIndexby 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 ofEmptyBufferthat can be shared.
-
-
Method Detail
-
capacity
public int capacity()
Description copied from interface:BufferReturns the number of bytes (octets) this buffer can contain.
-
capacity
public Buffer capacity(int newCapacity)
Description copied from interface:BufferSets the capacity of this buffer. If thenewCapacityis less than the current capacity, the content of this buffer is truncated. If thenewCapacityis 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:BufferReturns the maximum allowed capacity of this buffer. This value provides an upper bound onBuffer.capacity().- Specified by:
maxCapacityin interfaceBuffer- Returns:
- the max capacity of this buffer.
-
readerIndex
public int readerIndex()
Description copied from interface:BufferReturns thereaderIndexof this buffer.- Specified by:
readerIndexin interfaceBuffer- Returns:
- the
readerIndexof this buffer.
-
readerIndex
public Buffer readerIndex(int readerIndex)
Description copied from interface:BufferSets thereaderIndexof this buffer.- Specified by:
readerIndexin interfaceBuffer- Parameters:
readerIndex- the new readerIndex of this buffer.- Returns:
- itself.
-
writerIndex
public int writerIndex()
Description copied from interface:BufferReturns thewriterIndexof this buffer.- Specified by:
writerIndexin interfaceBuffer- Returns:
- the
writerIndexof this buffer.
-
writerIndex
public Buffer writerIndex(int writerIndex)
Description copied from interface:BufferSets thewriterIndexof this buffer.- Specified by:
writerIndexin interfaceBuffer- Parameters:
writerIndex- the new writerIndex of this buffer.- Returns:
- itself.
-
readableBytes
public int readableBytes()
Description copied from interface:BufferReturns the number of readable bytes which is equal to(this.writerIndex - this.readerIndex).- Specified by:
readableBytesin interfaceBuffer- Returns:
- the number of readables bytes in this buffer.
-
writableBytes
public int writableBytes()
Description copied from interface:BufferReturns the number of writable bytes which is equal to(this.capacity - this.writerIndex).- Specified by:
writableBytesin interfaceBuffer- Returns:
- the number of writable bytes in this buffer.
-
maxWritableBytes
public int maxWritableBytes()
Description copied from interface:BufferReturns the maximum possible number of writable bytes, which is equal to(this.maxCapacity - this.writerIndex).- Specified by:
maxWritableBytesin interfaceBuffer- Returns:
- the maximum possible number of writable bytes in this buffer.
-
ensureWritable
public Buffer ensureWritable(int minWritableBytes)
Description copied from interface:BufferExpands 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:
ensureWritablein 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:BufferExpands 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:
ensureWritablein 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:
0if the buffer has enough writable bytes, and its capacity is unchanged.1if the buffer does not have enough bytes, and its capacity is unchanged.2if the buffer has enough writable bytes, and its capacity has been increased.3if the buffer does not have enough bytes, but its capacity has been increased to its maximum.
-
clear
public Buffer clear()
Description copied from interface:BufferSets thereaderIndexandwriterIndexof this buffer to0.Please note that the behavior of this method is different from that of NIO buffer, which sets the
limitto thecapacityof the buffer.
-
getBoolean
public boolean getBoolean(int index)
Description copied from interface:BufferGets a boolean at the specified absolute (@code index) in this buffer. This method does not modify thereaderIndexorwriterIndexof this buffer.- Specified by:
getBooleanin interfaceBuffer- Parameters:
index- absolute (@code index) in this buffer.- Returns:
- a boolean.
-
getByte
public byte getByte(int index)
Description copied from interface:BufferGets a byte at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
getUnsignedByte
public short getUnsignedByte(int index)
Description copied from interface:BufferGets an unsigned byte at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Specified by:
getUnsignedBytein interfaceBuffer- Parameters:
index- absolute (@code index) in this buffer.- Returns:
- an unsigned byte.
-
getShort
public short getShort(int index)
Description copied from interface:BufferGets a 16-bit short integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
getShortLE
public short getShortLE(int index)
Description copied from interface:BufferGets a 16-bit short integer at the specified absoluteindexin this buffer in Little Endian Byte Order. This method does not modifyreaderIndexorwriterIndexof this buffer.- Specified by:
getShortLEin interfaceBuffer- Parameters:
index- absolute (@code index) in this buffer.- Returns:
- a short.
-
getUnsignedShort
public int getUnsignedShort(int index)
Description copied from interface:BufferGets an unsigned 16-bit short integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Specified by:
getUnsignedShortin interfaceBuffer- Parameters:
index- absolute (@code index) in this buffer.- Returns:
- a short.
-
getUnsignedShortLE
public int getUnsignedShortLE(int index)
Description copied from interface:BufferGets an unsigned 16-bit short integer at the specified absoluteindexin this buffer in Little Endian Byte Order. This method does not modifyreaderIndexorwriterIndexof this buffer.- Specified by:
getUnsignedShortLEin interfaceBuffer- Parameters:
index- absolute (@code index) in this buffer.- Returns:
- a short.
-
getMedium
public int getMedium(int index)
Description copied from interface:BufferGets a 24-bit medium integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
getMediumLE
public int getMediumLE(int index)
Description copied from interface:BufferGets a 24-bit medium integer at the specified absoluteindexin this buffer in the Little Endian Byte Order. This method does not modifyreaderIndexorwriterIndexof this buffer.- Specified by:
getMediumLEin interfaceBuffer- Parameters:
index- absolute (@code index) in this buffer.- Returns:
- a medium int.
-
getUnsignedMedium
public int getUnsignedMedium(int index)
Description copied from interface:BufferGets an unsigned 24-bit medium integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Specified by:
getUnsignedMediumin interfaceBuffer- Parameters:
index- absolute (@code index) in this buffer.- Returns:
- a medium in.
-
getUnsignedMediumLE
public int getUnsignedMediumLE(int index)
Description copied from interface:BufferGets an unsigned 24-bit medium integer at the specified absoluteindexin this buffer in Little Endian Byte Order. This method does not modifyreaderIndexorwriterIndexof this buffer.- Specified by:
getUnsignedMediumLEin interfaceBuffer- Parameters:
index- absolute (@code index) in this buffer.- Returns:
- a medium int.
-
getInt
public int getInt(int index)
Description copied from interface:BufferGets a 32-bit integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
getIntLE
public int getIntLE(int index)
Description copied from interface:BufferGets a 32-bit integer at the specified absoluteindexin this buffer with Little Endian Byte Order. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
getUnsignedInt
public long getUnsignedInt(int index)
Description copied from interface:BufferGets an unsigned 32-bit integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Specified by:
getUnsignedIntin interfaceBuffer- Parameters:
index- absolute (@code index) in this buffer.- Returns:
- a unsigned int.
-
getUnsignedIntLE
public long getUnsignedIntLE(int index)
Description copied from interface:BufferGets an unsigned 32-bit integer at the specified absoluteindexin this buffer in Little Endian Byte Order. This method does not modifyreaderIndexorwriterIndexof this buffer.- Specified by:
getUnsignedIntLEin interfaceBuffer- Parameters:
index- absolute (@code index) in this buffer.- Returns:
- a unsigned int.
-
getLong
public long getLong(int index)
Description copied from interface:BufferGets a 64-bit long integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
getLongLE
public long getLongLE(int index)
Description copied from interface:BufferGets a 64-bit long integer at the specified absoluteindexin this buffer in Little Endian Byte Order. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
getChar
public char getChar(int index)
Description copied from interface:BufferGets a 2-byte UTF-16 character at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
getFloat
public float getFloat(int index)
Description copied from interface:BufferGets a 32-bit floating point number at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
getDouble
public double getDouble(int index)
Description copied from interface:BufferGets a 64-bit floating point number at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
getBytes
public Buffer getBytes(int index, Buffer dst)
Description copied from interface:BufferTransfers this buffer's data to the specified destination starting at the specified absoluteindexuntil the destination becomes non-writable. This method is basically same withBuffer.getBytes(int, Buffer, int, int), except that this method increases thewriterIndexof the destination by the number of the transferred bytes whileBuffer.getBytes(int, Buffer, int, int)does not. This method does not modifyreaderIndexorwriterIndexof the source buffer (i.e.this).
-
getBytes
public Buffer getBytes(int index, Buffer dst, int length)
Description copied from interface:BufferTransfers 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 thewriterIndexof the destination by the number of the transferred bytes whileBuffer.getBytes(int, Buffer, int, int)does not. This method does not modifyreaderIndexorwriterIndexof the source buffer (i.e.this).
-
getBytes
public Buffer getBytes(int index, Buffer dst, int dstIndex, int length)
Description copied from interface:BufferTransfers this buffer's data to the specified destination starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof both the source (i.e.this) and the destination.
-
getBytes
public Buffer getBytes(int index, byte[] dst)
Description copied from interface:BufferTransfers this buffer's data to the specified destination starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer
-
getBytes
public Buffer getBytes(int index, byte[] dst, int dstIndex, int length)
Description copied from interface:BufferTransfers this buffer's data to the specified destination starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
getBytes
public Buffer getBytes(int index, java.nio.ByteBuffer dst)
Description copied from interface:BufferTransfers this buffer's data to the specified destination starting at the specified absoluteindexuntil the destination's position reaches its limit. This method does not modifyreaderIndexorwriterIndexof this buffer while the destination'spositionwill be increased.
-
setBoolean
public Buffer setBoolean(int index, boolean value)
Description copied from interface:BufferSets the specified boolean at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Specified by:
setBooleanin 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:BufferSets the specified byte at the specified absoluteindexin this buffer. The 24 high-order bits of the specified value are ignored. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setShort
public Buffer setShort(int index, int value)
Description copied from interface:BufferSets the specified 16-bit short integer at the specified absoluteindexin this buffer. The 16 high-order bits of the specified value are ignored. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setShortLE
public Buffer setShortLE(int index, int value)
Description copied from interface:BufferSets the specified 16-bit short integer at the specified absoluteindexin this buffer with the Little Endian Byte Order. The 16 high-order bits of the specified value are ignored. This method does not modifyreaderIndexorwriterIndexof this buffer.- Specified by:
setShortLEin 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:BufferSets the specified 24-bit medium integer at the specified absoluteindexin this buffer. Please note that the most significant byte is ignored in the specified value. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setMediumLE
public Buffer setMediumLE(int index, int value)
Description copied from interface:BufferSets the specified 24-bit medium integer at the specified absoluteindexin 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 modifyreaderIndexorwriterIndexof this buffer.- Specified by:
setMediumLEin 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:BufferSets the specified 32-bit integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setIntLE
public Buffer setIntLE(int index, int value)
Description copied from interface:BufferSets the specified 32-bit integer at the specified absoluteindexin this buffer with Little Endian byte order . This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setLong
public Buffer setLong(int index, long value)
Description copied from interface:BufferSets the specified 64-bit long integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setLongLE
public Buffer setLongLE(int index, long value)
Description copied from interface:BufferSets the specified 64-bit long integer at the specified absoluteindexin this buffer in Little Endian Byte Order. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setChar
public Buffer setChar(int index, int value)
Description copied from interface:BufferSets the specified 2-byte UTF-16 character at the specified absoluteindexin this buffer. The 16 high-order bits of the specified value are ignored. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setFloat
public Buffer setFloat(int index, float value)
Description copied from interface:BufferSets the specified 32-bit floating-point number at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setDouble
public Buffer setDouble(int index, double value)
Description copied from interface:BufferSets the specified 64-bit floating-point number at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setBytes
public Buffer setBytes(int index, Buffer src)
Description copied from interface:BufferTransfers the specified source buffer's data to this buffer starting at the specified absoluteindexuntil the source buffer becomes unreadable. This method is basically same withBuffer.setBytes(int, Buffer, int, int), except that this method increases thereaderIndexof the source buffer by the number of the transferred bytes whileBuffer.setBytes(int, Buffer, int, int)does not. This method does not modifyreaderIndexorwriterIndexof the source buffer (i.e.this).
-
setBytes
public Buffer setBytes(int index, Buffer src, int length)
Description copied from interface:BufferTransfers 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 thereaderIndexof the source buffer by the number of the transferred bytes whileBuffer.setBytes(int, Buffer, int, int)does not. This method does not modifyreaderIndexorwriterIndexof the source buffer (i.e.this).
-
setBytes
public Buffer setBytes(int index, Buffer src, int srcIndex, int length)
Description copied from interface:BufferTransfers the specified source buffer's data to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof both the source (i.e.this) and the destination.
-
setBytes
public Buffer setBytes(int index, byte[] src)
Description copied from interface:BufferTransfers the specified source array's data to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setBytes
public Buffer setBytes(int index, byte[] src, int srcIndex, int length)
Description copied from interface:BufferTransfers the specified source array's data to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setBytes
public Buffer setBytes(int index, java.nio.ByteBuffer src)
Description copied from interface:BufferTransfers the specified source buffer's data to this buffer starting at the specified absoluteindexuntil the source buffer's position reaches its limit. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setBytes
public int setBytes(int index, java.io.InputStream src, int length) throws java.io.IOExceptionDescription copied from interface:BufferTransfers a fixed amount from the specified source InputStream's data to this buffer starting at the specified absoluteindexuntillengthbytes have been read, the end of stream is reached, or an exception is thrown.This method does not modify
readerIndexorwriterIndexof this buffer.- Specified by:
setBytesin 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.-1if 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:BufferTransfers all the specified source InputStream's data to this buffer starting at the specified absoluteindexuntil the end of stream is reached or an exception is thrown.This method does not modify
readerIndexorwriterIndexof this buffer.This method may modify the underlying storage size of this array to accomidate for reading data.
- Specified by:
setBytesUntilEndStreamin interfaceBuffer- Parameters:
index- absolute (@code index) in this buffer.src- the source InputStream.chunkSize- chunkSize the amount of data that will be read fromsrcon each read attempt.- Returns:
- the actual total number of bytes read in from
src.-1if no bytes were read because the specified InputStream was closed when this method was called.
-
readBoolean
public boolean readBoolean()
Description copied from interface:BufferGets a boolean at the currentreaderIndexand increases thereaderIndexby1in this buffer.- Specified by:
readBooleanin interfaceBuffer- Returns:
- a boolean.
-
readByte
public byte readByte()
Description copied from interface:BufferGets a byte at the currentreaderIndexand increases thereaderIndexby1in this buffer.
-
readUnsignedByte
public short readUnsignedByte()
Description copied from interface:BufferGets an unsigned byte at the currentreaderIndexand increases thereaderIndexby1in this buffer.- Specified by:
readUnsignedBytein interfaceBuffer- Returns:
- a byte.
-
readShort
public short readShort()
Description copied from interface:BufferGets a 16-bit short integer at the currentreaderIndexand increases thereaderIndexby2in this buffer.
-
readShortLE
public short readShortLE()
Description copied from interface:BufferGets a 16-bit short integer at the currentreaderIndexin the Little Endian Byte Order and increases thereaderIndexby2in this buffer.- Specified by:
readShortLEin interfaceBuffer- Returns:
- a short.
-
readUnsignedShort
public int readUnsignedShort()
Description copied from interface:BufferGets an unsigned 16-bit short integer at the currentreaderIndexand increases thereaderIndexby2in this buffer.- Specified by:
readUnsignedShortin interfaceBuffer- Returns:
- a short.
-
readUnsignedShortLE
public int readUnsignedShortLE()
Description copied from interface:BufferGets an unsigned 16-bit short integer at the currentreaderIndexin the Little Endian Byte Order and increases thereaderIndexby2in this buffer.- Specified by:
readUnsignedShortLEin interfaceBuffer- Returns:
- a short.
-
readMedium
public int readMedium()
Description copied from interface:BufferGets a 24-bit medium integer at the currentreaderIndexand increases thereaderIndexby3in this buffer.- Specified by:
readMediumin interfaceBuffer- Returns:
- a medium int.
-
readMediumLE
public int readMediumLE()
Description copied from interface:BufferGets a 24-bit medium integer at the currentreaderIndexin the Little Endian Byte Order and increases thereaderIndexby3in this buffer.- Specified by:
readMediumLEin interfaceBuffer- Returns:
- a medium int.
-
readUnsignedMedium
public int readUnsignedMedium()
Description copied from interface:BufferGets an unsigned 24-bit medium integer at the currentreaderIndexand increases thereaderIndexby3in this buffer.- Specified by:
readUnsignedMediumin interfaceBuffer- Returns:
- a medium int.
-
readUnsignedMediumLE
public int readUnsignedMediumLE()
Description copied from interface:BufferGets an unsigned 24-bit medium integer at the currentreaderIndexin the Little Endian Byte Order and increases thereaderIndexby3in this buffer.- Specified by:
readUnsignedMediumLEin interfaceBuffer- Returns:
- a medium int.
-
readInt
public int readInt()
Description copied from interface:BufferGets a 32-bit integer at the currentreaderIndexand increases thereaderIndexby4in this buffer.
-
readIntLE
public int readIntLE()
Description copied from interface:BufferGets a 32-bit integer at the currentreaderIndexin the Little Endian Byte Order and increases thereaderIndexby4in this buffer.
-
readUnsignedInt
public long readUnsignedInt()
Description copied from interface:BufferGets an unsigned 32-bit integer at the currentreaderIndexand increases thereaderIndexby4in this buffer.- Specified by:
readUnsignedIntin interfaceBuffer- Returns:
- a int.
-
readUnsignedIntLE
public long readUnsignedIntLE()
Description copied from interface:BufferGets an unsigned 32-bit integer at the currentreaderIndexin the Little Endian Byte Order and increases thereaderIndexby4in this buffer.- Specified by:
readUnsignedIntLEin interfaceBuffer- Returns:
- a int.
-
readLong
public long readLong()
Description copied from interface:BufferGets a 64-bit integer at the currentreaderIndexand increases thereaderIndexby8in this buffer.
-
readLongLE
public long readLongLE()
Description copied from interface:BufferGets a 64-bit integer at the currentreaderIndexin the Little Endian Byte Order and increases thereaderIndexby8in this buffer.- Specified by:
readLongLEin interfaceBuffer- Returns:
- a long.
-
readChar
public char readChar()
Description copied from interface:BufferGets a 2-byte UTF-16 character at the currentreaderIndexand increases thereaderIndexby2in this buffer.
-
readFloat
public float readFloat()
Description copied from interface:BufferGets a 32-bit floating point number at the currentreaderIndexand increases thereaderIndexby4in this buffer.
-
readDouble
public double readDouble()
Description copied from interface:BufferGets a 64-bit floating point number at the currentreaderIndexand increases thereaderIndexby8in this buffer.- Specified by:
readDoublein interfaceBuffer- Returns:
- a double.
-
readSlice
public Buffer readSlice(int length)
Description copied from interface:BufferReturns a new slice of this buffer's sub-region starting at the currentreaderIndexand increases thereaderIndexby the size of the new slice (=length).
-
readBytes
public Buffer readBytes(int length)
Description copied from interface:BufferTransfers this buffer's data to a newly created buffer starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length). The returned buffer'sreaderIndexandwriterIndexare0andlengthrespectively.
-
readBytes
public Buffer readBytes(Buffer dst)
Description copied from interface:BufferTransfers this buffer's data to the specified destination starting at the currentreaderIndexuntil the destination becomes non-writable, and increases thereaderIndexby the number of the transferred bytes. This method is basically same withBuffer.readBytes(Buffer, int, int), except that this method increases thewriterIndexof 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:BufferTransfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length). This method is basically same withBuffer.readBytes(Buffer, int, int), except that this method increases thewriterIndexof 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:BufferTransfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length).
-
readBytes
public Buffer readBytes(byte[] dst)
Description copied from interface:BufferTransfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=dst.length).
-
readBytes
public Buffer readBytes(byte[] dst, int dstIndex, int length)
Description copied from interface:BufferTransfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length).
-
readBytes
public Buffer readBytes(java.nio.ByteBuffer dst)
Description copied from interface:BufferTransfers this buffer's data to the specified destination starting at the currentreaderIndexuntil the destination's position reaches its limit, and increases thereaderIndexby the number of the transferred bytes.
-
skipBytes
public Buffer skipBytes(int length)
Description copied from interface:BufferIncreases the currentreaderIndexby the specifiedlengthin this buffer.
-
writeBoolean
public Buffer writeBoolean(boolean value)
Description copied from interface:BufferSets the specified boolean at the currentwriterIndexand increases thewriterIndexby1in this buffer. Ifthis.writableBytesis less than1,Buffer.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Specified by:
writeBooleanin interfaceBuffer- Parameters:
value- the value to write.- Returns:
- self.
-
writeByte
public Buffer writeByte(int value)
Description copied from interface:BufferSets the specified byte at the currentwriterIndexand increases thewriterIndexby1in this buffer. The 24 high-order bits of the specified value are ignored. Ifthis.writableBytesis 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:BufferSets the specified 16-bit short integer at the currentwriterIndexand increases thewriterIndexby2in this buffer. The 16 high-order bits of the specified value are ignored. Ifthis.writableBytesis less than2,Buffer.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Specified by:
writeShortin interfaceBuffer- Parameters:
value- the value to write.- Returns:
- self.
-
writeShortLE
public Buffer writeShortLE(int value)
Description copied from interface:BufferSets the specified 16-bit short integer in the Little Endian Byte Order at the currentwriterIndexand increases thewriterIndexby2in this buffer. The 16 high-order bits of the specified value are ignored. Ifthis.writableBytesis less than2,Buffer.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Specified by:
writeShortLEin interfaceBuffer- Parameters:
value- the value to write.- Returns:
- self.
-
writeMedium
public Buffer writeMedium(int value)
Description copied from interface:BufferSets the specified 24-bit medium integer at the currentwriterIndexand increases thewriterIndexby3in this buffer. Ifthis.writableBytesis less than3,Buffer.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Specified by:
writeMediumin interfaceBuffer- Parameters:
value- the value to write.- Returns:
- self.
-
writeMediumLE
public Buffer writeMediumLE(int value)
Description copied from interface:BufferSets the specified 24-bit medium integer at the currentwriterIndexin the Little Endian Byte Order and increases thewriterIndexby3in this buffer. Ifthis.writableBytesis less than3,Buffer.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Specified by:
writeMediumLEin interfaceBuffer- Parameters:
value- the value to write.- Returns:
- self.
-
writeInt
public Buffer writeInt(int value)
Description copied from interface:BufferSets the specified 32-bit integer at the currentwriterIndexand increases thewriterIndexby4in this buffer. Ifthis.writableBytesis 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:BufferSets the specified 32-bit integer at the currentwriterIndexin the Little Endian Byte Order and increases thewriterIndexby4in this buffer. Ifthis.writableBytesis less than4,Buffer.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Specified by:
writeIntLEin interfaceBuffer- Parameters:
value- the value to write.- Returns:
- self.
-
writeLong
public Buffer writeLong(long value)
Description copied from interface:BufferSets the specified 64-bit long integer at the currentwriterIndexand increases thewriterIndexby8in this buffer. Ifthis.writableBytesis 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:BufferSets the specified 64-bit long integer at the currentwriterIndexin the Little Endian Byte Order and increases thewriterIndexby8in this buffer. Ifthis.writableBytesis less than8,Buffer.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Specified by:
writeLongLEin interfaceBuffer- Parameters:
value- the value to write.- Returns:
- self.
-
writeChar
public Buffer writeChar(int value)
Description copied from interface:BufferSets the specified 2-byte UTF-16 character at the currentwriterIndexand increases thewriterIndexby2in this buffer. The 16 high-order bits of the specified value are ignored. Ifthis.writableBytesis 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:BufferSets the specified 32-bit floating point number at the currentwriterIndexand increases thewriterIndexby4in this buffer. Ifthis.writableBytesis less than4,Buffer.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Specified by:
writeFloatin interfaceBuffer- Parameters:
value- the value to write.- Returns:
- self.
-
writeDouble
public Buffer writeDouble(double value)
Description copied from interface:BufferSets the specified 64-bit floating point number at the currentwriterIndexand increases thewriterIndexby8in this buffer. Ifthis.writableBytesis less than8,Buffer.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Specified by:
writeDoublein interfaceBuffer- Parameters:
value- the value to write.- Returns:
- self.
-
writeBytes
public Buffer writeBytes(Buffer src)
Description copied from interface:BufferTransfers the specified source buffer's data to this buffer starting at the currentwriterIndexuntil the source buffer becomes unreadable, and increases thewriterIndexby the number of the transferred bytes. This method is basically same withBuffer.writeBytes(Buffer, int, int), except that this method increases thereaderIndexof the source buffer by the number of the transferred bytes whileBuffer.writeBytes(Buffer, int, int)does not. Ifthis.writableBytesis less thansrc.readableBytes,Buffer.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Specified by:
writeBytesin interfaceBuffer- Parameters:
src- the buffer to write.- Returns:
- self.
-
writeBytes
public Buffer writeBytes(Buffer src, int length)
Description copied from interface:BufferTransfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length). This method is basically same withBuffer.writeBytes(Buffer, int, int), except that this method increases thereaderIndexof the source buffer by the number of the transferred bytes (=length) whileBuffer.writeBytes(Buffer, int, int)does not. Ifthis.writableBytesis less thanlength,Buffer.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Specified by:
writeBytesin 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:BufferTransfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length). Ifthis.writableBytesis less thanlength,Buffer.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Specified by:
writeBytesin 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:BufferTransfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=src.length). Ifthis.writableBytesis less thansrc.length,Buffer.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Specified by:
writeBytesin interfaceBuffer- Parameters:
src- the array to write.- Returns:
- self.
-
writeBytes
public Buffer writeBytes(byte[] src, int srcIndex, int length)
Description copied from interface:BufferTransfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length). Ifthis.writableBytesis less thanlength,Buffer.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Specified by:
writeBytesin 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:BufferTransfers the specified source buffer's data to this buffer starting at the currentwriterIndexuntil the source buffer's position reaches its limit, and increases thewriterIndexby the number of the transferred bytes. Ifthis.writableBytesis less thansrc.remaining(),Buffer.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Specified by:
writeBytesin interfaceBuffer- Parameters:
src- the source buffer to write.- Returns:
- self.
-
writeBytes
public int writeBytes(java.io.InputStream src, int length)Description copied from interface:BufferTransfers ta fixed amount from the specified sourceInputStream's data to this buffer starting at the currentwriterIndexuntillengthbytes have been read, the end of stream is reached, or an exception is thrown. Ifthis.writableBytesis less thanlength,Buffer.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.This method will increase the
writerIndexby the number of the transferred bytes if the write operation was successful.- Specified by:
writeBytesin interfaceBuffer- Parameters:
src- the sourceInputStreamto 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.-1if the specified channel is closed.
-
writeBytesUntilEndStream
public int writeBytesUntilEndStream(java.io.InputStream src, int chunkSize)Description copied from interface:BufferTransfers all the specified sourceInputStream's data to this buffer starting at the currentwriterIndexuntil the end of stream is reached or an exception is thrown. Ifthis.writableBytesis less than the number of bytes in theInputStream,Buffer.ensureWritable(int)will be called in an attempt to expand capacity to accommodate. Note that becauseInputStreamdoes not provide a reliable way to get the remaining bytes, this method may over allocate by a factor ofchunkSize.This method will increase the
writerIndexby the number of the transferred bytes if the write operation was successful.- Specified by:
writeBytesUntilEndStreamin interfaceBuffer- Parameters:
src- the sourceInputStreamto write.chunkSize- the amount of data that will be read fromsrcon each read attempt.- Returns:
- the actual total number of bytes read in from
src.-1if no bytes were read because the specifiedInputStreamwas closed when this method was called.
-
writeAscii
public Buffer writeAscii(java.lang.CharSequence seq)
Description copied from interface:BufferEncode aCharSequencein ASCII and write it to this buffer starting atwriterIndexand increases thewriterIndexby the number of the transferred bytes. Ifthis.writableBytesis not large enough to write the whole sequence,Buffer.ensureWritable(int)will be called in an attempt to expand capacity to accommodate.- Specified by:
writeAsciiin interfaceBuffer- Parameters:
seq- the source of the data.- Returns:
- self.
-
writeUtf8
public Buffer writeUtf8(java.lang.CharSequence seq)
Description copied from interface:BufferEncode aCharSequencein UTF-8 and write it to this buffer starting atwriterIndexand increases thewriterIndexby the number of the transferred bytes. Ifthis.writableBytesis 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:BufferEncode aCharSequencein UTF-8 and write it to this buffer starting atwriterIndexand increases thewriterIndexby the number of the transferred bytes.
-
indexOf
public int indexOf(int fromIndex, int toIndex, byte value)Description copied from interface:BufferLocates the first occurrence of the specifiedvaluein this buffer. The search takes place from the specifiedfromIndex(inclusive) to the specifiedtoIndex(exclusive).If
fromIndexis greater thantoIndex, the search is performed in a reversed order.This method does not modify
readerIndexorwriterIndexof this buffer.
-
bytesBefore
public int bytesBefore(byte value)
Description copied from interface:BufferLocates the first occurrence of the specifiedvaluein this buffer. The search takes place from the currentreaderIndex(inclusive) to the currentwriterIndex(exclusive).This method does not modify
readerIndexorwriterIndexof this buffer.- Specified by:
bytesBeforein interfaceBuffer- Parameters:
value- the value to search.- Returns:
- the number of bytes between the current
readerIndexand the first occurrence if found.-1otherwise.
-
bytesBefore
public int bytesBefore(int length, byte value)Description copied from interface:BufferLocates the first occurrence of the specifiedvaluein this buffer. The search starts from the currentreaderIndex(inclusive) and lasts for the specifiedlength.This method does not modify
readerIndexorwriterIndexof this buffer.- Specified by:
bytesBeforein interfaceBuffer- Parameters:
length- the length.value- the value to search.- Returns:
- the number of bytes between the current
readerIndexand the first occurrence if found.-1otherwise.
-
bytesBefore
public int bytesBefore(int index, int length, byte value)Description copied from interface:BufferLocates the first occurrence of the specifiedvaluein this buffer. The search starts from the specifiedindex(inclusive) and lasts for the specifiedlength.This method does not modify
readerIndexorwriterIndexof this buffer.- Specified by:
bytesBeforein interfaceBuffer- Parameters:
index- the index.length- the length.value- the value to search.- Returns:
- the number of bytes between the specified
indexand the first occurrence if found.-1otherwise.
-
copy
public Buffer copy()
Description copied from interface:BufferReturns 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 modifyreaderIndexorwriterIndexof this buffer.
-
copy
public Buffer copy(int index, int length)
Description copied from interface:BufferReturns 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 modifyreaderIndexorwriterIndexof this buffer.
-
slice
public Buffer slice()
Description copied from interface:BufferReturns 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 modifyreaderIndexorwriterIndexof this buffer.
-
slice
public Buffer slice(int index, int length)
Description copied from interface:BufferReturns 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 modifyreaderIndexorwriterIndexof this buffer.
-
duplicate
public Buffer duplicate()
Description copied from interface:BufferReturns 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 modifyreaderIndexorwriterIndexof this buffer.
-
nioBufferCount
public int nioBufferCount()
Description copied from interface:BufferReturns the maximum number of NIOByteBuffers that consist this buffer. Note thatBuffer.toNioBuffers()orBuffer.toNioBuffers(int, int)might return a less number ofByteBuffers.- Specified by:
nioBufferCountin interfaceBuffer- Returns:
-1if this buffer has no underlyingByteBuffer. the number of the underlyingByteBuffers if this buffer has at least one underlyingByteBuffer. Note that this method does not return0to 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:BufferExposes 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 modifyreaderIndexorwriterIndexof 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:
toNioBufferin 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:BufferExposes 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 modifyreaderIndexorwriterIndexof 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:
toNioBufferin 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:BufferExposes 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 modifyreaderIndexorwriterIndexof 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:
toNioBuffersin 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:BufferExposes 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 modifyreaderIndexorwriterIndexof 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:
toNioBuffersin 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:BufferDetermine if this buffer is read-only.- Specified by:
isReadOnlyin interfaceBuffer- Returns:
trueif and only if this buffer is read-only.
-
asReadOnly
public Buffer asReadOnly()
Description copied from interface:BufferCreate 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 originalBufferuseBuffer.duplicate()before converting to a read-only view.- Specified by:
asReadOnlyin interfaceBuffer- Returns:
- a buffer whose contents cannot be modified.
-
isDirect
public boolean isDirect()
Description copied from interface:BufferReturnstrueif the buffer is direct and so not allocated on the heap.
-
hasArray
public boolean hasArray()
Description copied from interface:BufferReturnstrueif 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:BufferReturns the backing byte array of this buffer.
-
arrayOffset
public int arrayOffset()
Description copied from interface:BufferReturns the offset of the first byte within the backing byte array of this buffer.- Specified by:
arrayOffsetin interfaceBuffer- Returns:
- the offset in the array.
-
toString
public java.lang.String toString(java.nio.charset.Charset charset)
Description copied from interface:BufferDecodes 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 modifyreaderIndexorwriterIndexof this buffer.
-
toString
public java.lang.String toString(int index, int length, java.nio.charset.Charset charset)Description copied from interface:BufferDecodes this buffer's sub-region into a string with the specified character set. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
forEachByte
public int forEachByte(ByteProcessor processor)
Description copied from interface:BufferIterates over the readable bytes of this buffer with the specifiedprocessorin ascending order.- Specified by:
forEachBytein interfaceBuffer- Parameters:
processor- theByteProcessorto use.- Returns:
-1if 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:BufferIterates over the specified area of this buffer with the specifiedprocessorin ascending order. (i.e.index,(index + 1), ..(index + length - 1))- Specified by:
forEachBytein interfaceBuffer- Parameters:
index- The index to start iterating from.length- The amount of bytes to iterate over.processor- theByteProcessorto use.- Returns:
-1if 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:BufferIterates over the readable bytes of this buffer with the specifiedprocessorin descending order.- Specified by:
forEachByteDescin interfaceBuffer- Parameters:
processor- theByteProcessorto use.- Returns:
-1if 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:BufferIterates over the specified area of this buffer with the specifiedprocessorin descending order. (i.e.(index + length - 1),(index + length - 2), ...index)- Specified by:
forEachByteDescin interfaceBuffer- Parameters:
index- The index to start iterating from.length- The amount of bytes to iterate over.processor- theByteProcessorto use.- Returns:
-1if the processor iterated to or beyond the beginning of the specified area. The last-visited index If theByteProcessor.process(byte)returnedfalse.
-
-