com.github.shyiko.mysql.binlog.io
Class ByteArrayInputStream

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

public class ByteArrayInputStream
extends InputStream

Author:
Stanley Shyiko

Constructor Summary
ByteArrayInputStream(byte[] bytes)
           
ByteArrayInputStream(InputStream inputStream)
           
 
Method Summary
 int available()
           
 void close()
           
 void enterBlock(int length)
           
 int peek()
           
 int read()
           
 byte[] read(int length)
          Alias for read(result, 0, length).
 BitSet readBitSet(int length, boolean bigEndian)
           
 int readInteger(int length)
          Read int written in little-endian format.
 String readLengthEncodedString()
          Read variable-length string.
 long readLong(int length)
          Read long written in little-endian format.
 int readPackedInteger()
           
 Number readPackedNumber()
          Format (first-byte-based):
0-250 - The first byte is the number (in the range 0-250).
 String readString(int length)
          Read fixed length string.
 String readZeroTerminatedString()
          Read variable-length string.
 void skipToTheEndOfTheBlock()
           
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteArrayInputStream

public ByteArrayInputStream(InputStream inputStream)

ByteArrayInputStream

public ByteArrayInputStream(byte[] bytes)
Method Detail

readInteger

public int readInteger(int length)
                throws IOException
Read int written in little-endian format.

Throws:
IOException

readLong

public long readLong(int length)
              throws IOException
Read long written in little-endian format.

Throws:
IOException

readString

public String readString(int length)
                  throws IOException
Read fixed length string.

Throws:
IOException

readLengthEncodedString

public String readLengthEncodedString()
                               throws IOException
Read variable-length string. Preceding packed integer indicates the length of the string.

Throws:
IOException

readZeroTerminatedString

public String readZeroTerminatedString()
                                throws IOException
Read variable-length string. End is indicated by 0x00 byte.

Throws:
IOException

read

public byte[] read(int length)
            throws IOException
Alias for read(result, 0, length).

Throws:
IOException

readBitSet

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

readPackedInteger

public int readPackedInteger()
                      throws IOException
Throws:
IOException
See Also:
readPackedNumber()

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.

Throws:
IOException

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

close

public void close()
           throws IOException
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


Copyright © 2014. All Rights Reserved.