org.mariadb.jdbc.internal.util.buffer

## Class Buffer

- java.lang.Object
- - org.mariadb.jdbc.internal.util.buffer.Buffer

    public class Buffer
    extends Object

### Field Summary

Fields
`byte[]` `buf`
`int` `limit`
`int` `position`

### Constructor Summary

Constructors
Constructor and Description
`Buffer(byte[] buf)`
`Buffer(byte[] buf, int limit)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `appendPacket(Buffer otherBuffer)` Add stream to bytebuffer.
`byte` `getByteAt(int position)`
`long` `getLengthEncodedBinary()` Get next binary data length.
`byte[]` `getLengthEncodedBytes()` Get next data bytes with unknown length.
`byte[]` `getLengthEncodedBytesWithLength(long length)` Get next data bytes with known length.
`long` `getSilentLengthEncodedBinary()` Return next binary field length without moving cursor position.
`int` `read24bitword()` Read 24 bit integer.
`byte` `readByte()` Reads a byte from the buffer.
`int` `readInt()` Read a int (4 bytes) from the buffer.
`long` `readLong()` Read a long (8 bytes) from the buffer.
`byte[]` `readRawBytes(int numberOfBytes)` Read raw data.
`short` `readShort()` Read a short (2 bytes) from the buffer.
`String` `readString(Charset charset)` Reads a string from the buffer, looks for a 0 to end the string.
`int` `remaining()`
`void` `skipByte()`
`void` `skipBytes(int bytesToSkip)`
`void` `skipLengthEncodedBytes()` Skip next length encode binary data.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### buf

    public byte[] buf

#### position

    public int position

#### limit

    public int limit

### Constructor Detail

#### Buffer

    public Buffer(byte[] buf,
                  int limit)

#### Buffer

    public Buffer(byte[] buf)

### Method Detail

#### remaining

    public int remaining()

#### readString

    public String readString(Charset charset)

Reads a string from the buffer, looks for a 0 to end the string.

Parameters:
  `charset` - the charset to use, for example ASCII
Returns:
  the read string

#### readShort

    public short readShort()

Read a short (2 bytes) from the buffer.

Returns:
  an short

#### read24bitword

    public int read24bitword()

Read 24 bit integer.

Returns:
  length

#### readInt

    public int readInt()

Read a int (4 bytes) from the buffer.

Returns:
  a int

#### readLong

    public long readLong()

Read a long (8 bytes) from the buffer.

Returns:
  a long

#### readByte

    public byte readByte()

Reads a byte from the buffer.

Returns:
  the byte

#### readRawBytes

    public byte[] readRawBytes(int numberOfBytes)

Read raw data.

Parameters:
  `numberOfBytes` - raw data length.
Returns:
  raw data

#### skipByte

    public void skipByte()

#### skipBytes

    public void skipBytes(int bytesToSkip)

#### skipLengthEncodedBytes

    public void skipLengthEncodedBytes()

Skip next length encode binary data.

#### getLengthEncodedBinary

    public long getLengthEncodedBinary()

Get next binary data length.

Returns:
  length of next binary data

#### getLengthEncodedBytes

    public byte[] getLengthEncodedBytes()
                                 throws IOException

Get next data bytes with unknown length.

Returns:
  the raw binary data
Throws:
  `IOException` - if connection problem occur

#### getLengthEncodedBytesWithLength

    public byte[] getLengthEncodedBytesWithLength(long length)

Get next data bytes with known length.

Parameters:
  `length` - binary data length
Returns:
  the raw binary data

#### getByteAt

    public byte getByteAt(int position)

#### appendPacket

    public void appendPacket(Buffer otherBuffer)

Add stream to bytebuffer.

Parameters:
  `otherBuffer` - stream to add if needed

#### getSilentLengthEncodedBinary

    public long getSilentLengthEncodedBinary()

Return next binary field length without moving cursor position.

Returns:
  next binary field length