Package org.mariadb.jdbc.client.impl
Class StandardReadableByteBuf
java.lang.Object
org.mariadb.jdbc.client.impl.StandardReadableByteBuf
- All Implemented Interfaces:
ReadableByteBuf
Packet buffer
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStandardReadableByteBuf
(byte[] buf) Packet buffer constructor, limit being the buffer lengthStandardReadableByteBuf
(byte[] buf, int limit) Packet buffer constructor -
Method Summary
Modifier and TypeMethodDescriptionlong
atoll
(int length) Fast signed long parsinglong
atoull
(int length) Fast unsigned long parsingbyte[]
buf()
buffervoid
buf
(byte[] buf, int limit, int pos) Reset bufferbyte
getByte()
Read byte from buffer at current position, without changing positionbyte
getByte
(int index) Read byte from buffer at indicated index, without changing positionshort
Read unsigned byte value at current position, without changing positionint
pos()
Current buffer positionvoid
pos
(int pos) Set positionint
buffer number of unread bytesreadAscii
(int length) Read ascii encoded string from length bytesreadBlob
(int length) Read Blob at current positionbyte
readByte()
Read byte at current position, incrementing positionvoid
readBytes
(byte[] dst) Read as many bytes to fill destination arraybyte[]
Read null-ended encoded bytes.double
Read double encoded on 8 bytes value at current positiondouble
Read double encoded on 8 bytes (big endian) value at current positionfloat
Read float encoded on 4 bytes value at current positionint
readInt()
Read signed 4 bytes value (little endian) at current positionint
Read signed 4 bytes value (big endian) at current positionint
Read encoded length value that cannot be nullRead encoded length valueReturn a length encoded bufferlong
readLong()
Read signed 8 bytes value (little endian) at current positionlong
Read unsigned 4 bytes value (big endian) at current positionlong
Read encoded length value that cannot be nullint
Read signed 3 bytes value (little endian) at current positionshort
Read signed 2 bytes value (little endian) at current positionreadString
(int length) Read utf-8 encoded string from length bytesReturn the utf-8 string represented by current position to the limit of bufferRead null-ended utf-8 encoded string.short
Read unsigned byte value at current positionlong
Read unsigned 4 bytes value (little endian) at current positionint
Read unsigned 3 bytes value (little endian) at current positionint
Read unsigned 2 bytes value (little endian) at current positionvoid
skip()
Skip one bytevoid
skip
(int length) Skip length value of bytesint
Identifier can have a max length of 256 (alias) So no need to check whole length encoding.void
Skip length encoded value
-
Field Details
-
buf
public byte[] bufbuffer -
pos
public int poscurrent position reading buffer -
limit
private int limitrow data limit
-
-
Constructor Details
-
StandardReadableByteBuf
public StandardReadableByteBuf(byte[] buf, int limit) Packet buffer constructor- Parameters:
buf
- bufferlimit
- buffer limit
-
StandardReadableByteBuf
public StandardReadableByteBuf(byte[] buf) Packet buffer constructor, limit being the buffer length- Parameters:
buf
- buffer
-
-
Method Details
-
readableBytes
public int readableBytes()Description copied from interface:ReadableByteBuf
buffer number of unread bytes- Specified by:
readableBytes
in interfaceReadableByteBuf
- Returns:
- remaining bytes number
-
pos
public int pos()Description copied from interface:ReadableByteBuf
Current buffer position- Specified by:
pos
in interfaceReadableByteBuf
- Returns:
- position
-
buf
public byte[] buf()Description copied from interface:ReadableByteBuf
buffer- Specified by:
buf
in interfaceReadableByteBuf
- Returns:
- buffer
-
buf
public void buf(byte[] buf, int limit, int pos) Description copied from interface:ReadableByteBuf
Reset buffer- Specified by:
buf
in interfaceReadableByteBuf
- Parameters:
buf
- new bufferlimit
- buffer limitpos
- initial position
-
pos
public void pos(int pos) Description copied from interface:ReadableByteBuf
Set position- Specified by:
pos
in interfaceReadableByteBuf
- Parameters:
pos
- new position
-
skip
public void skip()Description copied from interface:ReadableByteBuf
Skip one byte- Specified by:
skip
in interfaceReadableByteBuf
-
skip
public void skip(int length) Description copied from interface:ReadableByteBuf
Skip length value of bytes- Specified by:
skip
in interfaceReadableByteBuf
- Parameters:
length
- number of position to skip
-
skipLengthEncoded
public void skipLengthEncoded()Description copied from interface:ReadableByteBuf
Skip length encoded value- Specified by:
skipLengthEncoded
in interfaceReadableByteBuf
-
readBlob
Description copied from interface:ReadableByteBuf
Read Blob at current position- Specified by:
readBlob
in interfaceReadableByteBuf
- Parameters:
length
- blob length- Returns:
- Blob
-
atoll
public long atoll(int length) Description copied from interface:ReadableByteBuf
Fast signed long parsing- Specified by:
atoll
in interfaceReadableByteBuf
- Parameters:
length
- data length- Returns:
- long value
-
atoull
public long atoull(int length) Description copied from interface:ReadableByteBuf
Fast unsigned long parsing- Specified by:
atoull
in interfaceReadableByteBuf
- Parameters:
length
- data length- Returns:
- long value
-
getByte
public byte getByte()Description copied from interface:ReadableByteBuf
Read byte from buffer at current position, without changing position- Specified by:
getByte
in interfaceReadableByteBuf
- Returns:
- byte value
-
getByte
public byte getByte(int index) Description copied from interface:ReadableByteBuf
Read byte from buffer at indicated index, without changing position- Specified by:
getByte
in interfaceReadableByteBuf
- Parameters:
index
- index- Returns:
- byte value
-
getUnsignedByte
public short getUnsignedByte()Description copied from interface:ReadableByteBuf
Read unsigned byte value at current position, without changing position- Specified by:
getUnsignedByte
in interfaceReadableByteBuf
- Returns:
- short value
-
readLongLengthEncodedNotNull
public long readLongLengthEncodedNotNull()Description copied from interface:ReadableByteBuf
Read encoded length value that cannot be null- Specified by:
readLongLengthEncodedNotNull
in interfaceReadableByteBuf
- Returns:
- encoded length
- See Also:
-
readIntLengthEncodedNotNull
public int readIntLengthEncodedNotNull()Description copied from interface:ReadableByteBuf
Read encoded length value that cannot be null- Specified by:
readIntLengthEncodedNotNull
in interfaceReadableByteBuf
- Returns:
- encoded length
- See Also:
-
skipIdentifier
public int skipIdentifier()Identifier can have a max length of 256 (alias) So no need to check whole length encoding.- Specified by:
skipIdentifier
in interfaceReadableByteBuf
- Returns:
- current pos
-
readLength
Description copied from interface:ReadableByteBuf
Read encoded length value- Specified by:
readLength
in interfaceReadableByteBuf
- Returns:
- encoded length
- See Also:
-
readByte
public byte readByte()Description copied from interface:ReadableByteBuf
Read byte at current position, incrementing position- Specified by:
readByte
in interfaceReadableByteBuf
- Returns:
- byte at current position
-
readUnsignedByte
public short readUnsignedByte()Description copied from interface:ReadableByteBuf
Read unsigned byte value at current position- Specified by:
readUnsignedByte
in interfaceReadableByteBuf
- Returns:
- short value
-
readShort
public short readShort()Description copied from interface:ReadableByteBuf
Read signed 2 bytes value (little endian) at current position- Specified by:
readShort
in interfaceReadableByteBuf
- Returns:
- short value
-
readUnsignedShort
public int readUnsignedShort()Description copied from interface:ReadableByteBuf
Read unsigned 2 bytes value (little endian) at current position- Specified by:
readUnsignedShort
in interfaceReadableByteBuf
- Returns:
- short value
-
readMedium
public int readMedium()Description copied from interface:ReadableByteBuf
Read signed 3 bytes value (little endian) at current position- Specified by:
readMedium
in interfaceReadableByteBuf
- Returns:
- int value
-
readUnsignedMedium
public int readUnsignedMedium()Description copied from interface:ReadableByteBuf
Read unsigned 3 bytes value (little endian) at current position- Specified by:
readUnsignedMedium
in interfaceReadableByteBuf
- Returns:
- int value
-
readInt
public int readInt()Description copied from interface:ReadableByteBuf
Read signed 4 bytes value (little endian) at current position- Specified by:
readInt
in interfaceReadableByteBuf
- Returns:
- int value
-
readIntBE
public int readIntBE()Description copied from interface:ReadableByteBuf
Read signed 4 bytes value (big endian) at current position- Specified by:
readIntBE
in interfaceReadableByteBuf
- Returns:
- int value
-
readUnsignedInt
public long readUnsignedInt()Description copied from interface:ReadableByteBuf
Read unsigned 4 bytes value (little endian) at current position- Specified by:
readUnsignedInt
in interfaceReadableByteBuf
- Returns:
- long value
-
readLong
public long readLong()Description copied from interface:ReadableByteBuf
Read signed 8 bytes value (little endian) at current position- Specified by:
readLong
in interfaceReadableByteBuf
- Returns:
- long value
-
readLongBE
public long readLongBE()Description copied from interface:ReadableByteBuf
Read unsigned 4 bytes value (big endian) at current position- Specified by:
readLongBE
in interfaceReadableByteBuf
- Returns:
- long value
-
readBytes
public void readBytes(byte[] dst) Description copied from interface:ReadableByteBuf
Read as many bytes to fill destination array- Specified by:
readBytes
in interfaceReadableByteBuf
- Parameters:
dst
- destination array
-
readBytesNullEnd
public byte[] readBytesNullEnd()Description copied from interface:ReadableByteBuf
Read null-ended encoded bytes. 0x00 null value won't be in return byte, so position is incremented to returned byte array length + 1- Specified by:
readBytesNullEnd
in interfaceReadableByteBuf
- Returns:
- byte array
-
readLengthBuffer
Description copied from interface:ReadableByteBuf
Return a length encoded buffer- Specified by:
readLengthBuffer
in interfaceReadableByteBuf
- Returns:
- new buffer
-
readString
Description copied from interface:ReadableByteBuf
Read utf-8 encoded string from length bytes- Specified by:
readString
in interfaceReadableByteBuf
- Parameters:
length
- length byte to read- Returns:
- string value
-
readAscii
Description copied from interface:ReadableByteBuf
Read ascii encoded string from length bytes- Specified by:
readAscii
in interfaceReadableByteBuf
- Parameters:
length
- length byte to read- Returns:
- string value
-
readStringNullEnd
Description copied from interface:ReadableByteBuf
Read null-ended utf-8 encoded string. 0x00 = null represent string ending. Position is incremented to returned string corresponding bytes + 1- Specified by:
readStringNullEnd
in interfaceReadableByteBuf
- Returns:
- corresponding string
-
readStringEof
Description copied from interface:ReadableByteBuf
Return the utf-8 string represented by current position to the limit of buffer- Specified by:
readStringEof
in interfaceReadableByteBuf
- Returns:
- string value
-
readFloat
public float readFloat()Description copied from interface:ReadableByteBuf
Read float encoded on 4 bytes value at current position- Specified by:
readFloat
in interfaceReadableByteBuf
- Returns:
- float value
-
readDouble
public double readDouble()Description copied from interface:ReadableByteBuf
Read double encoded on 8 bytes value at current position- Specified by:
readDouble
in interfaceReadableByteBuf
- Returns:
- double value
-
readDoubleBE
public double readDoubleBE()Description copied from interface:ReadableByteBuf
Read double encoded on 8 bytes (big endian) value at current position- Specified by:
readDoubleBE
in interfaceReadableByteBuf
- Returns:
- double value
-