Class StandardReadableByteBuf

  • All Implemented Interfaces:
    ReadableByteBuf

    public final class StandardReadableByteBuf
    extends java.lang.Object
    implements ReadableByteBuf
    Packet buffer
    • Field Summary

      Fields 
      Modifier and Type Field Description
      byte[] buf
      buffer
      private int limit
      row data limit
      int pos
      current position reading buffer
    • Constructor Summary

      Constructors 
      Constructor Description
      StandardReadableByteBuf​(byte[] buf)
      Packet buffer constructor, limit being the buffer length
      StandardReadableByteBuf​(byte[] buf, int limit)
      Packet buffer constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long atoll​(int length)
      Fast signed long parsing
      long atoull​(int length)
      Fast unsigned long parsing
      byte[] buf()
      buffer
      void buf​(byte[] buf, int limit, int pos)
      Reset buffer
      byte getByte()
      Read byte from buffer at current position, without changing position
      byte getByte​(int index)
      Read byte from buffer at indicated index, without changing position
      short getUnsignedByte()
      Read unsigned byte value at current position, without changing position
      int pos()
      Current buffer position
      void pos​(int pos)
      Set position
      int readableBytes()
      buffer number of unread bytes
      java.lang.String readAscii​(int length)
      Read ascii encoded string from length bytes
      MariaDbBlob readBlob​(int length)
      Read Blob at current position
      byte readByte()
      Read byte at current position, incrementing position
      void readBytes​(byte[] dst)
      Read as many bytes to fill destination array
      byte[] readBytesNullEnd()
      Read null-ended encoded bytes.
      double readDouble()
      Read double encoded on 8 bytes value at current position
      double readDoubleBE()
      Read double encoded on 8 bytes (big endian) value at current position
      float readFloat()
      Read float encoded on 4 bytes value at current position
      int readInt()
      Read signed 4 bytes value (little endian) at current position
      int readIntBE()
      Read signed 4 bytes value (big endian) at current position
      int readIntLengthEncodedNotNull()
      Read encoded length value that cannot be null
      java.lang.Integer readLength()
      Read encoded length value
      StandardReadableByteBuf readLengthBuffer()
      Return a length encoded buffer
      long readLong()
      Read signed 8 bytes value (little endian) at current position
      long readLongBE()
      Read unsigned 4 bytes value (big endian) at current position
      long readLongLengthEncodedNotNull()
      Read encoded length value that cannot be null
      int readMedium()
      Read signed 3 bytes value (little endian) at current position
      short readShort()
      Read signed 2 bytes value (little endian) at current position
      java.lang.String readString​(int length)
      Read utf-8 encoded string from length bytes
      java.lang.String readStringEof()
      Return the utf-8 string represented by current position to the limit of buffer
      java.lang.String readStringNullEnd()
      Read null-ended utf-8 encoded string.
      short readUnsignedByte()
      Read unsigned byte value at current position
      long readUnsignedInt()
      Read unsigned 4 bytes value (little endian) at current position
      int readUnsignedMedium()
      Read unsigned 3 bytes value (little endian) at current position
      int readUnsignedShort()
      Read unsigned 2 bytes value (little endian) at current position
      void skip()
      Skip one byte
      void skip​(int length)
      Skip length value of bytes
      int skipIdentifier()
      Identifier can have a max length of 256 (alias) So no need to check whole length encoding.
      void skipLengthEncoded()
      Skip length encoded value
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • buf

        public byte[] buf
        buffer
      • pos

        public int pos
        current position reading buffer
      • limit

        private int limit
        row data limit
    • Constructor Detail

      • StandardReadableByteBuf

        public StandardReadableByteBuf​(byte[] buf,
                                       int limit)
        Packet buffer constructor
        Parameters:
        buf - buffer
        limit - 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: ReadableByteBuf
        buffer number of unread bytes
        Specified by:
        readableBytes in interface ReadableByteBuf
        Returns:
        remaining bytes number
      • pos

        public int pos()
        Description copied from interface: ReadableByteBuf
        Current buffer position
        Specified by:
        pos in interface ReadableByteBuf
        Returns:
        position
      • buf

        public void buf​(byte[] buf,
                        int limit,
                        int pos)
        Description copied from interface: ReadableByteBuf
        Reset buffer
        Specified by:
        buf in interface ReadableByteBuf
        Parameters:
        buf - new buffer
        limit - buffer limit
        pos - initial position
      • pos

        public void pos​(int pos)
        Description copied from interface: ReadableByteBuf
        Set position
        Specified by:
        pos in interface ReadableByteBuf
        Parameters:
        pos - new position
      • skip

        public void skip​(int length)
        Description copied from interface: ReadableByteBuf
        Skip length value of bytes
        Specified by:
        skip in interface ReadableByteBuf
        Parameters:
        length - number of position to skip
      • atoll

        public long atoll​(int length)
        Description copied from interface: ReadableByteBuf
        Fast signed long parsing
        Specified by:
        atoll in interface ReadableByteBuf
        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 interface ReadableByteBuf
        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 interface ReadableByteBuf
        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 interface ReadableByteBuf
        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 interface ReadableByteBuf
        Returns:
        short value
      • 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 interface ReadableByteBuf
        Returns:
        current pos
      • readByte

        public byte readByte()
        Description copied from interface: ReadableByteBuf
        Read byte at current position, incrementing position
        Specified by:
        readByte in interface ReadableByteBuf
        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 interface ReadableByteBuf
        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 interface ReadableByteBuf
        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 interface ReadableByteBuf
        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 interface ReadableByteBuf
        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 interface ReadableByteBuf
        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 interface ReadableByteBuf
        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 interface ReadableByteBuf
        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 interface ReadableByteBuf
        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 interface ReadableByteBuf
        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 interface ReadableByteBuf
        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 interface ReadableByteBuf
        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 interface ReadableByteBuf
        Returns:
        byte array
      • readString

        public java.lang.String readString​(int length)
        Description copied from interface: ReadableByteBuf
        Read utf-8 encoded string from length bytes
        Specified by:
        readString in interface ReadableByteBuf
        Parameters:
        length - length byte to read
        Returns:
        string value
      • readAscii

        public java.lang.String readAscii​(int length)
        Description copied from interface: ReadableByteBuf
        Read ascii encoded string from length bytes
        Specified by:
        readAscii in interface ReadableByteBuf
        Parameters:
        length - length byte to read
        Returns:
        string value
      • readStringNullEnd

        public java.lang.String 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 interface ReadableByteBuf
        Returns:
        corresponding string
      • readStringEof

        public java.lang.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 interface ReadableByteBuf
        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 interface ReadableByteBuf
        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 interface ReadableByteBuf
        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 interface ReadableByteBuf
        Returns:
        double value