Package org.mariadb.jdbc.client.impl
Class StandardReadableByteBuf
- java.lang.Object
-
- org.mariadb.jdbc.client.impl.StandardReadableByteBuf
-
- All Implemented Interfaces:
ReadableByteBuf
public final class StandardReadableByteBuf extends java.lang.Object implements ReadableByteBuf
Packet buffer
-
-
Constructor Summary
Constructors Constructor Description StandardReadableByteBuf(byte[] buf)Packet buffer constructor, limit being the buffer lengthStandardReadableByteBuf(byte[] buf, int limit)Packet buffer constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longatoll(int length)Fast signed long parsinglongatoull(int length)Fast unsigned long 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 bytesjava.lang.StringreadAscii(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 nulljava.lang.IntegerreadLength()Read encoded length valueStandardReadableByteBufreadLengthBuffer()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 nullintreadMedium()Read signed 3 bytes value (little endian) at current positionshortreadShort()Read signed 2 bytes value (little endian) at current positionjava.lang.StringreadString(int length)Read utf-8 encoded string from length bytesjava.lang.StringreadStringEof()Return the utf-8 string represented by current position to the limit of bufferjava.lang.StringreadStringNullEnd()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
-
-
-
Constructor Detail
-
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 Detail
-
readableBytes
public int readableBytes()
Description copied from interface:ReadableByteBufbuffer number of unread bytes- Specified by:
readableBytesin interfaceReadableByteBuf- Returns:
- remaining bytes number
-
pos
public int pos()
Description copied from interface:ReadableByteBufCurrent buffer position- Specified by:
posin interfaceReadableByteBuf- Returns:
- position
-
buf
public byte[] buf()
Description copied from interface:ReadableByteBufbuffer- Specified by:
bufin interfaceReadableByteBuf- Returns:
- buffer
-
buf
public void buf(byte[] buf, int limit, int pos)Description copied from interface:ReadableByteBufReset buffer- Specified by:
bufin interfaceReadableByteBuf- Parameters:
buf- new bufferlimit- buffer limitpos- initial position
-
pos
public void pos(int pos)
Description copied from interface:ReadableByteBufSet position- Specified by:
posin interfaceReadableByteBuf- Parameters:
pos- new position
-
skip
public void skip()
Description copied from interface:ReadableByteBufSkip one byte- Specified by:
skipin interfaceReadableByteBuf
-
skip
public void skip(int length)
Description copied from interface:ReadableByteBufSkip length value of bytes- Specified by:
skipin interfaceReadableByteBuf- Parameters:
length- number of position to skip
-
skipLengthEncoded
public void skipLengthEncoded()
Description copied from interface:ReadableByteBufSkip length encoded value- Specified by:
skipLengthEncodedin interfaceReadableByteBuf
-
readBlob
public MariaDbBlob readBlob(int length)
Description copied from interface:ReadableByteBufRead Blob at current position- Specified by:
readBlobin interfaceReadableByteBuf- Parameters:
length- blob length- Returns:
- Blob
-
atoll
public long atoll(int length)
Description copied from interface:ReadableByteBufFast signed long parsing- Specified by:
atollin interfaceReadableByteBuf- Parameters:
length- data length- Returns:
- long value
-
atoull
public long atoull(int length)
Description copied from interface:ReadableByteBufFast unsigned long parsing- Specified by:
atoullin interfaceReadableByteBuf- Parameters:
length- data length- Returns:
- long value
-
getByte
public byte getByte()
Description copied from interface:ReadableByteBufRead byte from buffer at current position, without changing position- Specified by:
getBytein interfaceReadableByteBuf- Returns:
- byte value
-
getByte
public byte getByte(int index)
Description copied from interface:ReadableByteBufRead byte from buffer at indicated index, without changing position- Specified by:
getBytein interfaceReadableByteBuf- Parameters:
index- index- Returns:
- byte value
-
getUnsignedByte
public short getUnsignedByte()
Description copied from interface:ReadableByteBufRead unsigned byte value at current position, without changing position- Specified by:
getUnsignedBytein interfaceReadableByteBuf- Returns:
- short value
-
readLongLengthEncodedNotNull
public long readLongLengthEncodedNotNull()
Description copied from interface:ReadableByteBufRead encoded length value that cannot be null- Specified by:
readLongLengthEncodedNotNullin interfaceReadableByteBuf- Returns:
- encoded length
- See Also:
- length encoded integer
-
readIntLengthEncodedNotNull
public int readIntLengthEncodedNotNull()
Description copied from interface:ReadableByteBufRead encoded length value that cannot be null- Specified by:
readIntLengthEncodedNotNullin interfaceReadableByteBuf- Returns:
- encoded length
- See Also:
- length
encoded integer
this is readLongLengthEncodedNotNull limited to 32 bits
-
skipIdentifier
public int skipIdentifier()
Identifier can have a max length of 256 (alias) So no need to check whole length encoding.- Specified by:
skipIdentifierin interfaceReadableByteBuf- Returns:
- current pos
-
readLength
public java.lang.Integer readLength()
Description copied from interface:ReadableByteBufRead encoded length value- Specified by:
readLengthin interfaceReadableByteBuf- Returns:
- encoded length
- See Also:
- length encoded integer
-
readByte
public byte readByte()
Description copied from interface:ReadableByteBufRead byte at current position, incrementing position- Specified by:
readBytein interfaceReadableByteBuf- Returns:
- byte at current position
-
readUnsignedByte
public short readUnsignedByte()
Description copied from interface:ReadableByteBufRead unsigned byte value at current position- Specified by:
readUnsignedBytein interfaceReadableByteBuf- Returns:
- short value
-
readShort
public short readShort()
Description copied from interface:ReadableByteBufRead signed 2 bytes value (little endian) at current position- Specified by:
readShortin interfaceReadableByteBuf- Returns:
- short value
-
readUnsignedShort
public int readUnsignedShort()
Description copied from interface:ReadableByteBufRead unsigned 2 bytes value (little endian) at current position- Specified by:
readUnsignedShortin interfaceReadableByteBuf- Returns:
- short value
-
readMedium
public int readMedium()
Description copied from interface:ReadableByteBufRead signed 3 bytes value (little endian) at current position- Specified by:
readMediumin interfaceReadableByteBuf- Returns:
- int value
-
readUnsignedMedium
public int readUnsignedMedium()
Description copied from interface:ReadableByteBufRead unsigned 3 bytes value (little endian) at current position- Specified by:
readUnsignedMediumin interfaceReadableByteBuf- Returns:
- int value
-
readInt
public int readInt()
Description copied from interface:ReadableByteBufRead signed 4 bytes value (little endian) at current position- Specified by:
readIntin interfaceReadableByteBuf- Returns:
- int value
-
readIntBE
public int readIntBE()
Description copied from interface:ReadableByteBufRead signed 4 bytes value (big endian) at current position- Specified by:
readIntBEin interfaceReadableByteBuf- Returns:
- int value
-
readUnsignedInt
public long readUnsignedInt()
Description copied from interface:ReadableByteBufRead unsigned 4 bytes value (little endian) at current position- Specified by:
readUnsignedIntin interfaceReadableByteBuf- Returns:
- long value
-
readLong
public long readLong()
Description copied from interface:ReadableByteBufRead signed 8 bytes value (little endian) at current position- Specified by:
readLongin interfaceReadableByteBuf- Returns:
- long value
-
readLongBE
public long readLongBE()
Description copied from interface:ReadableByteBufRead unsigned 4 bytes value (big endian) at current position- Specified by:
readLongBEin interfaceReadableByteBuf- Returns:
- long value
-
readBytes
public void readBytes(byte[] dst)
Description copied from interface:ReadableByteBufRead as many bytes to fill destination array- Specified by:
readBytesin interfaceReadableByteBuf- Parameters:
dst- destination array
-
readBytesNullEnd
public byte[] readBytesNullEnd()
Description copied from interface: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 interfaceReadableByteBuf- Returns:
- byte array
-
readLengthBuffer
public StandardReadableByteBuf readLengthBuffer()
Description copied from interface:ReadableByteBufReturn a length encoded buffer- Specified by:
readLengthBufferin interfaceReadableByteBuf- Returns:
- new buffer
-
readString
public java.lang.String readString(int length)
Description copied from interface:ReadableByteBufRead utf-8 encoded string from length bytes- Specified by:
readStringin interfaceReadableByteBuf- Parameters:
length- length byte to read- Returns:
- string value
-
readAscii
public java.lang.String readAscii(int length)
Description copied from interface:ReadableByteBufRead ascii encoded string from length bytes- Specified by:
readAsciiin interfaceReadableByteBuf- Parameters:
length- length byte to read- Returns:
- string value
-
readStringNullEnd
public java.lang.String readStringNullEnd()
Description copied from interface:ReadableByteBufRead null-ended utf-8 encoded string. 0x00 = null represent string ending. Position is incremented to returned string corresponding bytes + 1- Specified by:
readStringNullEndin interfaceReadableByteBuf- Returns:
- corresponding string
-
readStringEof
public java.lang.String readStringEof()
Description copied from interface:ReadableByteBufReturn the utf-8 string represented by current position to the limit of buffer- Specified by:
readStringEofin interfaceReadableByteBuf- Returns:
- string value
-
readFloat
public float readFloat()
Description copied from interface:ReadableByteBufRead float encoded on 4 bytes value at current position- Specified by:
readFloatin interfaceReadableByteBuf- Returns:
- float value
-
readDouble
public double readDouble()
Description copied from interface:ReadableByteBufRead double encoded on 8 bytes value at current position- Specified by:
readDoublein interfaceReadableByteBuf- Returns:
- double value
-
readDoubleBE
public double readDoubleBE()
Description copied from interface:ReadableByteBufRead double encoded on 8 bytes (big endian) value at current position- Specified by:
readDoubleBEin interfaceReadableByteBuf- Returns:
- double value
-
-