public class Buffer extends Object
| Modifier and Type | Field and Description |
|---|---|
byte[] |
buf |
static byte[] |
EMPTY_BYTE_ARRAY |
int |
limit |
int |
position |
| Constructor and Description |
|---|
Buffer() |
Buffer(byte[] buf)
Constructor with default limit and offset.
|
Buffer(byte[] buf,
int limit) |
| Modifier and Type | Method and Description |
|---|---|
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() |
int |
read24bitword() |
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() |
int |
readInt2()
Read a int (2 bytes) from the buffer.
|
int |
readInt3()
Read 24 bit integer.
|
int |
readInt4()
Read a int (4 bytes) from the buffer.
|
int |
readIntV1() |
byte[] |
readLenByteArray(int offset) |
long |
readLong() |
long |
readLong4()
Read a long (4 bytes) from the buffer.
|
long |
readLong8()
Read a long (8 bytes) from the buffer.
|
long |
readLongLongV1() |
long |
readLongV1() |
int |
readnBytes() |
byte[] |
readRawBytes(int numberOfBytes) |
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.
|
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 |
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.
|
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 readInt2()
public int readIntV1()
public int readInt3()
public int read24bitword()
public int readInt4()
public int readInt()
public int readnBytes()
public long readLong4()
public long readLongV1()
public long readLong8()
public long readLongLongV1()
public long readLong()
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[] readRawBytes(int numberOfBytes)
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 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 © 2022 oceanbase.com. All rights reserved.