public interface Buffer
Modifier and Type | Method and Description |
---|---|
int |
capacity()
Returns the number of bytes (octets) this buffer can contain.
|
Buffer |
getBytes(int index,
byte[] dst)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index . |
boolean |
isDirect()
Returns
true if and only if this buffer is backed by an
NIO direct buffer. |
Buffer |
markWriterIndex()
Marks the current writer index in this buffer.
|
ByteBuffer |
nioBuffer()
Exposes this buffer's readable bytes as a NIO
ByteBuffer . |
ByteBuffer |
nioBuffer(int index,
int length)
Exposes this buffer's sub-region as an NIO
ByteBuffer . |
int |
nioBufferCount()
Returns the maximum number of NIO
ByteBuffer s that consist this buffer. |
ByteBuffer[] |
nioBuffers()
Exposes this buffer's readable bytes as NIO ByteBuffer's instances.
|
ByteBuffer[] |
nioBuffers(int index,
int length)
Exposes this buffer's readable bytes as NIO ByteBuffer's instances.
|
int |
readableBytes()
Returns the number of readable bytes.
|
boolean |
readBoolean()
Gets a boolean and advances the reader index.
|
byte |
readByte()
Gets a byte and advances the reader index.
|
Buffer |
readBytes(byte[] destination)
Transfers this buffer's data to the specified destination starting at
the current reader index and advances the reader index.
|
Buffer |
readBytes(byte[] destination,
int dstIndex,
int length)
Transfers this buffer's data to the specified destination starting at
the current reader index and advances the reader index.
|
Buffer |
readBytes(ByteBuffer dst)
Transfers this buffer's data to the specified destination starting at
the current reader index until the destination's position
reaches its limit, and advances the reader index.
|
Buffer |
readBytes(OutputStream out,
int length)
Transfers this buffer's data to the specified stream starting at the
current reader index and advances the index.
|
double |
readDouble()
Gets a 64-bit floating point number and advances the reader index.
|
int |
readerIndex()
Returns the reader index of this buffer.
|
Buffer |
readerIndex(int readerIndex)
Sets the reader index of this buffer.
|
float |
readFloat()
Gets a 32-bit floating point number and advances the reader index.
|
int |
readInt()
Gets a 32-bit integer at the current index and advances the reader index.
|
long |
readLong()
Gets a 64-bit integer and advances the reader index.
|
short |
readShort()
Gets a 16-bit short integer and advances the reader index.
|
int |
referenceCount()
Returns the reference count of this object.
|
boolean |
release()
Decreases the reference count by
1 and deallocates this object if the reference count reaches at
0 . |
Buffer |
resetWriterIndex()
Repositions the current writer index to the marked index in this buffer.
|
Buffer |
retain()
Increases the reference count by
1 . |
Buffer |
writeBoolean(boolean value)
Sets the specified boolean at the current writer index and advances the index.
|
Buffer |
writeByte(int value)
Sets the specified byte at the current writer index and advances the index.
|
Buffer |
writeBytes(byte[] src)
Transfers the specified source array's data to this buffer starting at the current writer index
and advances the index.
|
Buffer |
writeBytes(byte[] src,
int srcIndex,
int length)
Transfers the specified source array's data to this buffer starting at the current writer index
and advances the index.
|
Buffer |
writeBytes(ByteBuffer src)
Transfers the specified source byte data to this buffer starting at the current writer index
and advances the index.
|
Buffer |
writeDouble(double value)
Sets the specified 64-bit floating point number at the current writer index and advances the index.
|
Buffer |
writeFloat(float value)
Sets the specified 32-bit floating point number at the current writer index and advances the index.
|
Buffer |
writeInt(int value)
Sets the specified 32-bit integer at the current writer index and advances the index.
|
Buffer |
writeLong(long value)
Sets the specified 64-bit long integer at the current writer index and advances the index.
|
int |
writerIndex()
Returns the writer index of this buffer.
|
Buffer |
writerIndex(int writerIndex)
Sets the writer index of this buffer.
|
Buffer |
writeShort(int value)
Sets the specified 16-bit short integer at the current writer index and advances the index.
|
int readableBytes()
int readerIndex()
Buffer readerIndex(int readerIndex)
IndexOutOfBoundsException
- if its out of bounds.int writerIndex()
Buffer writerIndex(int writerIndex)
Buffer markWriterIndex()
Buffer resetWriterIndex()
int capacity()
boolean isDirect()
true
if and only if this buffer is backed by an
NIO direct buffer.boolean readBoolean()
byte readByte()
short readShort()
int readInt()
long readLong()
float readFloat()
double readDouble()
Buffer readBytes(byte[] destination)
Buffer readBytes(byte[] destination, int dstIndex, int length)
destination
- The destination bufferdstIndex
- the first index of the destinationlength
- the number of bytes to transferBuffer readBytes(ByteBuffer dst)
Buffer readBytes(OutputStream out, int length) throws IOException
length
- the number of bytes to transferIOException
- if the specified stream threw an exception during I/OBuffer writeBoolean(boolean value)
Buffer writeByte(int value)
Buffer writeShort(int value)
Buffer writeInt(int value)
Buffer writeLong(long value)
Buffer writeFloat(float value)
Buffer writeDouble(double value)
Buffer writeBytes(byte[] src)
Buffer writeBytes(ByteBuffer src)
Buffer writeBytes(byte[] src, int srcIndex, int length)
boolean release()
1
and deallocates this object if the reference count reaches at
0
.Buffer retain()
1
.int referenceCount()
int nioBufferCount()
ByteBuffer
s that consist this buffer.ByteBuffer[] nioBuffers()
ByteBuffer[] nioBuffers(int index, int length)
ByteBuffer nioBuffer()
ByteBuffer
. The returned buffer
either share or contains the copied content of this buffer, while changing the position
and limit of the returned NIO buffer does not affect the indexes and marks of this buffer.ByteBuffer nioBuffer(int index, int length)
ByteBuffer
.Buffer getBytes(int index, byte[] dst)
index
.
This method does not modify reader or writer indexes.Copyright © 2013–2020 Apache Software Foundation. All rights reserved.