public class Buffer extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
byte[] |
buf |
static byte[] |
EMPTY_BYTE_ARRAY |
int |
limit |
int |
position |
| 构造器和说明 |
|---|
Buffer() |
Buffer(byte[] buf)
Constructor with default limit and offset.
|
Buffer(byte[] buf,
int limit) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
checkRemainder(long need) |
int |
fastSkipLenString() |
byte |
getByte()
Read current buffer byte without incrementing position.
|
byte |
getByteAt(int position) |
byte[] |
getByteBuffer()
Returns the array of bytes this Buffer is using to read from.
|
byte[] |
getBytes(int len) |
byte[] |
getBytes(int offset,
int len) |
Buffer |
getLengthEncodedBuffer()
Get next data bytes from length encoded prefix.
|
byte[] |
getLengthEncodedBytes()
Get next data bytes with length encoded prefix.
|
long |
getLengthEncodedNumeric()
Get next binary data length.
|
int |
getLimit() |
int |
getPosition() |
byte |
readByte()
Reads a byte from the buffer.
|
byte[] |
readBytes(int numberOfBytes)
Read raw data.
|
byte[] |
readBytesNullEnd()
Reads a byte array from the buffer, looks for a 0 to end the array.
|
long |
readFieldLength() |
int |
readInt()
Read a int (4 bytes) from the buffer.
|
int |
readInt2Bytes()
Read a int (2 bytes) from the buffer.
|
int |
readInt2BytesV1() |
int |
readInt3Bytes()
Read 24 bit integer.
|
byte[] |
readLenByteArray(int offset) |
long |
readLong()
Read a long (8 bytes) from the buffer.
|
long |
readLong4BytesV1()
Read a long (4 bytes) from the buffer.
|
long |
readLongV1() |
int |
readnBytes() |
short |
readShort()
Read a short (2 bytes) from the buffer.
|
String |
readString(int numberOfBytes)
Read String with defined length.
|
String |
readStringLengthEncoded(Charset charset)
Reads length-encoded string.
|
String |
readStringNullEnd(Charset charset)
Reads a string from the buffer, looks for a 0 to end the string.
|
String |
readStringRestOfPacket(Charset charset)
If a string is the last component of a packet,
its length can be calculated from the overall packet length minus the current position.
|
int |
remaining() |
void |
setPosition(int position) |
void |
skipByte() |
void |
skipBytes(int bytesToSkip) |
void |
skipLengthEncodedBytes()
Skip next length encode binary data.
|
void |
skipLengthEncodedNumeric()
Skip length encoded numeric
|
void |
skipRestOfPacket() |
void |
writeByte(byte b) |
void |
writeBytes(byte[] bytes,
int off,
int length) |
void |
writeBytes(byte header,
byte[] bytes)
Write bytes.
|
void |
writeInt(int num) |
void |
writeIntV2(int num) |
void |
writeLength(long length)
Write length.
|
void |
writeLongFromHighToLow(long num) |
void |
writeLongFromLowToHigh(long num) |
void |
writeLongInt(int num) |
void |
writeNBytes(long num,
int n) |
void |
writeShort(short num) |
void |
writeShortV2(short num) |
void |
writeString(String str) |
void |
writeStringLength(byte[] bytes)
Write value with length encoded prefix.
|
void |
writeStringLength(String value,
Charset charset)
Write value with length encoded prefix.
|
void |
writeStringSmallLength(byte[] value)
Write value with length encoded prefix. value length MUST be less than 251 char
|
public byte[] buf
public int position
public int limit
public static final byte[] EMPTY_BYTE_ARRAY
public Buffer(byte[] buf,
int limit)
public Buffer(byte[] buf)
buf - byte arraypublic Buffer()
public int remaining()
public void checkRemainder(long need)
throws IOException
IOExceptionpublic String readStringNullEnd(Charset charset)
charset - the charset to use, for example ASCIIpublic byte[] readBytesNullEnd()
public String readString(int numberOfBytes)
numberOfBytes - raw data length.public short readShort()
public int readInt2Bytes()
public int readInt2BytesV1()
public int readInt3Bytes()
public int readInt()
public int readnBytes()
public long readLong4BytesV1()
public long readLong()
public long readLongV1()
public byte readByte()
public byte[] readLenByteArray(int offset)
public byte getByte()
public void skipByte()
public byte getByteAt(int position)
public byte[] readBytes(int numberOfBytes)
numberOfBytes - raw data length.public byte[] getBytes(int len)
public byte[] getBytes(int offset,
int len)
public void skipBytes(int bytesToSkip)
public byte[] getLengthEncodedBytes()
public void skipLengthEncodedBytes()
public long getLengthEncodedNumeric()
public void skipLengthEncodedNumeric()
public Buffer getLengthEncodedBuffer()
public String readStringRestOfPacket(Charset charset)
charset - the charset to use, for example ASCIIpublic void skipRestOfPacket()
public String readStringLengthEncoded(Charset charset)
charset - the charset to use, for example ASCIIpublic int fastSkipLenString()
public final long readFieldLength()
public void writeByte(byte b)
public void writeBytes(byte[] bytes,
int off,
int length)
public void writeBytes(byte header,
byte[] bytes)
header - header bytebytes - command bytespublic void writeShort(short num)
public void writeShortV2(short num)
public void writeLongInt(int num)
public void writeInt(int num)
public void writeIntV2(int num)
public void writeNBytes(long num,
int n)
public void writeLongFromLowToHigh(long num)
public void writeLongFromHighToLow(long num)
public void writeString(String str)
public void writeStringLength(String value, Charset charset)
value - value to writepublic void writeStringLength(byte[] bytes)
bytes - value to writepublic void writeStringSmallLength(byte[] value)
value - value to writepublic void writeLength(long length)
length - lengthpublic int getPosition()
public void setPosition(int position)
public int getLimit()
public byte[] getByteBuffer()
Copyright © 2024 oceanbase.com. All rights reserved.