Package org.mariadb.jdbc.client.impl
Class StandardReadableByteBuf
- java.lang.Object
-
- org.mariadb.jdbc.client.impl.StandardReadableByteBuf
-
- All Implemented Interfaces:
org.mariadb.jdbc.client.ReadableByteBuf
public final class StandardReadableByteBuf extends Object implements org.mariadb.jdbc.client.ReadableByteBuf
Packet buffer
-
-
Field Summary
Fields Modifier and Type Field Description byte[]buf
-
Constructor Summary
Constructors Constructor Description StandardReadableByteBuf(byte[] buf, int limit)Packet buffer constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longatoi(int length)Fast long from text parsingbyte[]buf()buffervoidbuf(byte[] buf, int limit, int pos)Reset bufferbytegetByte()Read byte from buffer at current position, without changing positionbytegetByte(int index)Read byte from buffer at indicated index, without changing positionshortgetUnsignedByte()Read unsigned byte value at current position, without changing positionintpos()Current buffer positionvoidpos(int pos)Set positionintreadableBytes()buffer number of unread bytesStringreadAscii(int length)Read ascii encoded string from length bytesMariaDbBlobreadBlob(int length)Read Blob at current positionbytereadByte()Read byte at current position, incrementing positionvoidreadBytes(byte[] dst)Read as many bytes to fill destination arraybyte[]readBytesNullEnd()Read null-ended encoded bytes.doublereadDouble()Read double encoded on 8 bytes value at current positiondoublereadDoubleBE()Read double encoded on 8 bytes (big endian) value at current positionfloatreadFloat()Read float encoded on 4 bytes value at current positionintreadInt()Read signed 4 bytes value (little endian) at current positionintreadIntBE()Read signed 4 bytes value (big endian) at current positionintreadIntLengthEncodedNotNull()Read encoded length value that cannot be null see https://mariadb.com/kb/en/protocol-data-types/#length-encoded-integersIntegerreadLength()Read encoded length value see https://mariadb.com/kb/en/protocol-data-types/#length-encoded-integersStandardReadableByteBufreadLengthBuffer()Return a length encoded bufferlongreadLong()Read signed 8 bytes value (little endian) at current positionlongreadLongBE()Read unsigned 4 bytes value (big endian) at current positionlongreadLongLengthEncodedNotNull()Read encoded length value that cannot be null see https://mariadb.com/kb/en/protocol-data-types/#length-encoded-integersintreadMedium()Read signed 3 bytes value (little endian) at current positionshortreadShort()Read signed 2 bytes value (little endian) at current positionStringreadString(int length)Read utf-8 encoded string from length bytesStringreadStringEof()Return the utf-8 string represented by current position to the limit of bufferStringreadStringNullEnd()Read null-ended utf-8 encoded string.shortreadUnsignedByte()Read unsigned byte value at current positionlongreadUnsignedInt()Read unsigned 4 bytes value (little endian) at current positionintreadUnsignedMedium()Read unsigned 3 bytes value (little endian) at current positionintreadUnsignedShort()Read unsigned 2 bytes value (little endian) at current positionvoidskip()Skip one bytevoidskip(int length)Skip length value of bytesintskipIdentifier()Identifier can have a max length of 256 (alias) So no need to check whole length encoding.voidskipLengthEncoded()Skip length encoded value
-
-
-
Method Detail
-
readableBytes
public int readableBytes()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufbuffer number of unread bytes- Specified by:
readableBytesin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- remaining bytes number
-
pos
public int pos()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufCurrent buffer position- Specified by:
posin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- position
-
buf
public byte[] buf()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufbuffer- Specified by:
bufin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- buffer
-
buf
public void buf(byte[] buf, int limit, int pos)Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufReset buffer- Specified by:
bufin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Parameters:
buf- new bufferlimit- buffer limitpos- initial position
-
pos
public void pos(int pos)
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufSet position- Specified by:
posin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Parameters:
pos- new position
-
skip
public void skip()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufSkip one byte- Specified by:
skipin interfaceorg.mariadb.jdbc.client.ReadableByteBuf
-
skip
public void skip(int length)
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufSkip length value of bytes- Specified by:
skipin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Parameters:
length- number of position to skip
-
skipLengthEncoded
public void skipLengthEncoded()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufSkip length encoded value- Specified by:
skipLengthEncodedin interfaceorg.mariadb.jdbc.client.ReadableByteBuf
-
readBlob
public MariaDbBlob readBlob(int length)
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead Blob at current position- Specified by:
readBlobin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Parameters:
length- blob length- Returns:
- Blob
-
atoi
public long atoi(int length)
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufFast long from text parsing- Specified by:
atoiin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Parameters:
length- data length- Returns:
- long value
-
getByte
public byte getByte()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead byte from buffer at current position, without changing position- Specified by:
getBytein interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- byte value
-
getByte
public byte getByte(int index)
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead byte from buffer at indicated index, without changing position- Specified by:
getBytein interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Parameters:
index- index- Returns:
- byte value
-
getUnsignedByte
public short getUnsignedByte()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead unsigned byte value at current position, without changing position- Specified by:
getUnsignedBytein interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- short value
-
readLongLengthEncodedNotNull
public long readLongLengthEncodedNotNull()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead encoded length value that cannot be null see https://mariadb.com/kb/en/protocol-data-types/#length-encoded-integers- Specified by:
readLongLengthEncodedNotNullin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- encoded length
-
readIntLengthEncodedNotNull
public int readIntLengthEncodedNotNull()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead encoded length value that cannot be null see https://mariadb.com/kb/en/protocol-data-types/#length-encoded-integersthis is readLongLengthEncodedNotNull limited to 32 bits
- Specified by:
readIntLengthEncodedNotNullin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- encoded length
-
skipIdentifier
public int skipIdentifier()
Identifier can have a max length of 256 (alias) So no need to check whole length encoding.- Specified by:
skipIdentifierin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- current pos
-
readLength
public Integer readLength()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead encoded length value see https://mariadb.com/kb/en/protocol-data-types/#length-encoded-integers- Specified by:
readLengthin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- encoded length
-
readByte
public byte readByte()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead byte at current position, incrementing position- Specified by:
readBytein interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- byte at current position
-
readUnsignedByte
public short readUnsignedByte()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead unsigned byte value at current position- Specified by:
readUnsignedBytein interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- short value
-
readShort
public short readShort()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead signed 2 bytes value (little endian) at current position- Specified by:
readShortin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- short value
-
readUnsignedShort
public int readUnsignedShort()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead unsigned 2 bytes value (little endian) at current position- Specified by:
readUnsignedShortin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- short value
-
readMedium
public int readMedium()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead signed 3 bytes value (little endian) at current position- Specified by:
readMediumin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- int value
-
readUnsignedMedium
public int readUnsignedMedium()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead unsigned 3 bytes value (little endian) at current position- Specified by:
readUnsignedMediumin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- int value
-
readInt
public int readInt()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead signed 4 bytes value (little endian) at current position- Specified by:
readIntin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- int value
-
readIntBE
public int readIntBE()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead signed 4 bytes value (big endian) at current position- Specified by:
readIntBEin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- int value
-
readUnsignedInt
public long readUnsignedInt()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead unsigned 4 bytes value (little endian) at current position- Specified by:
readUnsignedIntin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- long value
-
readLong
public long readLong()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead signed 8 bytes value (little endian) at current position- Specified by:
readLongin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- long value
-
readLongBE
public long readLongBE()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead unsigned 4 bytes value (big endian) at current position- Specified by:
readLongBEin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- long value
-
readBytes
public void readBytes(byte[] dst)
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead as many bytes to fill destination array- Specified by:
readBytesin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Parameters:
dst- destination array
-
readBytesNullEnd
public byte[] readBytesNullEnd()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead 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:
readBytesNullEndin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- byte array
-
readLengthBuffer
public StandardReadableByteBuf readLengthBuffer()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufReturn a length encoded buffer- Specified by:
readLengthBufferin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- new buffer
-
readString
public String readString(int length)
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead utf-8 encoded string from length bytes- Specified by:
readStringin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Parameters:
length- length byte to read- Returns:
- string value
-
readAscii
public String readAscii(int length)
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead ascii encoded string from length bytes- Specified by:
readAsciiin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Parameters:
length- length byte to read- Returns:
- string value
-
readStringNullEnd
public String readStringNullEnd()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead null-ended utf-8 encoded string. 0x00 = null represent string ending. Position is incremented to returned string corresponding bytes + 1- Specified by:
readStringNullEndin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- corresponding string
-
readStringEof
public String readStringEof()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufReturn the utf-8 string represented by current position to the limit of buffer- Specified by:
readStringEofin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- string value
-
readFloat
public float readFloat()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead float encoded on 4 bytes value at current position- Specified by:
readFloatin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- float value
-
readDouble
public double readDouble()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead double encoded on 8 bytes value at current position- Specified by:
readDoublein interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- double value
-
readDoubleBE
public double readDoubleBE()
Description copied from interface:org.mariadb.jdbc.client.ReadableByteBufRead double encoded on 8 bytes (big endian) value at current position- Specified by:
readDoubleBEin interfaceorg.mariadb.jdbc.client.ReadableByteBuf- Returns:
- double value
-
-