Package org.mariadb.jdbc.internal.com.read

## Class Buffer

- java.lang.Object
- - org.mariadb.jdbc.internal.com.read.Buffer

    public class Buffer
    extends Object

### Field Summary

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

### Constructor Summary

Constructors
`Buffer​(byte[] buf)` Constructor with default limit and offset.
`Buffer​(byte[] buf, int limit)`

### Method Summary

All Methods Instance Methods Concrete Methods
`byte` `getByte()` Read current buffer byte without incrementing position.
`byte` `getByteAt​(int position)`
`Buffer` `getLengthEncodedBuffer()` Get next data bytes from length encoded prefix.
`byte[]` `getLengthEncodedBytes()` Get next data bytes with length encoded prefix.
`long` `getLengthEncodedNumeric()` Get next binary data length.
`int` `read24bitword()` Read 24 bit integer.
`byte` `readByte()` Reads a byte from the buffer.
`byte[]` `readBytesNullEnd()` Reads a byte array from the buffer, looks for a 0 to end the array.
`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​(int numberOfBytes)` Read String with defined length.
`String` `readStringLengthEncoded​(Charset charset)` Reads length-encoded string.
`String` `readStringNullEnd​(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.
`void` `skipLengthEncodedNumeric()` Skip length encoded numeric
`void` `writeBytes​(byte header, byte[] bytes)` Write bytes.
`void` `writeLength​(long length)` Write length.
`void` `writeStringLength​(byte[] bytes)` Write value with length encoded prefix.
`void` `writeStringLength​(String value)` Write value with length encoded prefix.
`void` `writeStringSmallLength​(byte[] value)` Write value with length encoded prefix.

### 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)

Constructor with default limit and offset.

Parameters:
  `buf` - byte array

### Method Detail

#### remaining

    public int remaining()

#### readStringNullEnd

    public String readStringNullEnd​(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

#### readBytesNullEnd

    public byte[] readBytesNullEnd()

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

Returns:
  the read array

#### readStringLengthEncoded

    public String readStringLengthEncoded​(Charset charset)

Reads length-encoded string.

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

#### readString

    public String readString​(int numberOfBytes)

Read String with defined length.

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

#### 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

#### getByte

    public byte getByte()

Read current buffer byte without incrementing position.

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.

#### getLengthEncodedNumeric

    public long getLengthEncodedNumeric()

Get next binary data length.

Returns:
  length of next binary data

#### skipLengthEncodedNumeric

    public void skipLengthEncodedNumeric()

Skip length encoded numeric

#### getLengthEncodedBuffer

    public Buffer getLengthEncodedBuffer()

Get next data bytes from length encoded prefix.

Returns:
  buffer

#### getLengthEncodedBytes

    public byte[] getLengthEncodedBytes()

Get next data bytes with length encoded prefix.

Returns:
  the raw binary data

#### getByteAt

    public byte getByteAt​(int position)

#### writeStringLength

    public void writeStringLength​(String value)

Write value with length encoded prefix.

Parameters:
  `value` - value to write

#### writeStringLength

    public void writeStringLength​(byte[] bytes)

Write value with length encoded prefix.

Parameters:
  `bytes` - value to write

#### writeStringSmallLength

    public void writeStringSmallLength​(byte[] value)

Write value with length encoded prefix. value length MUST be less than 251 char

Parameters:
  `value` - value to write

#### writeBytes

    public void writeBytes​(byte header,
                           byte[] bytes)

Write bytes.

Parameters:
  `header` - header byte
  `bytes` - command bytes

#### writeLength

    public void writeLength​(long length)

Write length.

Parameters:
  `length` - length