Class ByteArrayInputStream

java.lang.Object
java.io.InputStream
com.github.shyiko.mysql.binlog.io.ByteArrayInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class ByteArrayInputStream extends InputStream
Author:
Stanley Shyiko
  • Constructor Details

    • ByteArrayInputStream

      public ByteArrayInputStream(InputStream inputStream)
    • ByteArrayInputStream

      public ByteArrayInputStream(byte[] bytes)
  • Method Details

    • readInteger

      public int readInteger(int length) throws IOException
      Read int written in little-endian format.
      Parameters:
      length - length of the integer to read
      Returns:
      the integer from the binlog
      Throws:
      IOException - in case of EOF
    • readLong

      public long readLong(int length) throws IOException
      Read long written in little-endian format.
      Parameters:
      length - length of the long to read
      Returns:
      the long from the binlog
      Throws:
      IOException - in case of EOF
    • readString

      public String readString(int length) throws IOException
      Read fixed length string.
      Parameters:
      length - length of string to read
      Returns:
      string
      Throws:
      IOException - in case of EOF
    • readLengthEncodedString

      public String readLengthEncodedString() throws IOException
      Read variable-length string. Preceding packed integer indicates the length of the string.
      Returns:
      string
      Throws:
      IOException - in case of EOF
    • readZeroTerminatedString

      public String readZeroTerminatedString() throws IOException
      Read variable-length string. End is indicated by 0x00 byte.
      Returns:
      string
      Throws:
      IOException - in case of EOF
    • read

      public byte[] read(int length) throws IOException
      Throws:
      IOException
    • fill

      public void fill(byte[] bytes, int offset, int length) throws IOException
      Throws:
      IOException
    • readBitSet

      public BitSet readBitSet(int length, boolean bigEndian) throws IOException
      Throws:
      IOException
    • readPackedInteger

      public int readPackedInteger() throws IOException
      Returns:
      integer
      Throws:
      IOException - in case of malformed number, eof, null, or long
      See Also:
    • readPackedLong

      public long readPackedLong() throws IOException
      Returns:
      long
      Throws:
      IOException - in case of malformed number, eof, null
      See Also:
    • readPackedNumber

      public Number readPackedNumber() throws IOException
      Format (first-byte-based):
      0-250 - The first byte is the number (in the range 0-250). No additional bytes are used.
      251 - SQL NULL value
      252 - Two more bytes are used. The number is in the range 251-0xffff.
      253 - Three more bytes are used. The number is in the range 0xffff-0xffffff.
      254 - Eight more bytes are used. The number is in the range 0xffffff-0xffffffffffffffff.
      Returns:
      long or null
      Throws:
      IOException - in case of malformed number or EOF
    • available

      public int available() throws IOException
      Overrides:
      available in class InputStream
      Throws:
      IOException
    • peek

      public int peek() throws IOException
      Throws:
      IOException
    • read

      public int read() throws IOException
      Specified by:
      read in class InputStream
      Throws:
      IOException
    • read

      public int read(byte[] b, int off, int len) throws IOException
      Overrides:
      read in class InputStream
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
      Throws:
      IOException
    • enterBlock

      public void enterBlock(int length)
    • skipToTheEndOfTheBlock

      public void skipToTheEndOfTheBlock() throws IOException
      Throws:
      IOException
    • getPosition

      public int getPosition()
    • mark

      public void mark(int readlimit)
      Overrides:
      mark in class InputStream
    • markSupported

      public boolean markSupported()
      Overrides:
      markSupported in class InputStream
    • reset

      public void reset() throws IOException
      Overrides:
      reset in class InputStream
      Throws:
      IOException
    • fastSkip

      public long fastSkip(long n) throws IOException
      This method implements fast-forward skipping in the stream. It can be used if and only if the underlying stream is fully available till its end. In other cases the regular InputStream.skip(long) method must be used.
      Parameters:
      n - - number of bytes to skip
      Returns:
      number of bytes skipped
      Throws:
      IOException