Class ByteArrayInputStream
java.lang.Object
java.io.InputStream
com.github.shyiko.mysql.binlog.io.ByteArrayInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
- Author:
- Stanley Shyiko
-
Constructor Summary
ConstructorsConstructorDescriptionByteArrayInputStream(byte[] bytes) ByteArrayInputStream(InputStream inputStream) -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()voidenterBlock(int length) longfastSkip(long n) This method implements fast-forward skipping in the stream.voidfill(byte[] bytes, int offset, int length) intvoidmark(int readlimit) booleanintpeek()intread()intread(byte[] b, int off, int len) byte[]read(int length) readBitSet(int length, boolean bigEndian) intreadInteger(int length) Read int written in little-endian format.Read variable-length string.longreadLong(int length) Read long written in little-endian format.intlongFormat (first-byte-based):
0-250 - The first byte is the number (in the range 0-250).readString(int length) Read fixed length string.Read variable-length string.voidreset()voidMethods inherited from class java.io.InputStream
nullInputStream, read, readAllBytes, readNBytes, readNBytes, skip, skipNBytes, transferTo
-
Constructor Details
-
ByteArrayInputStream
-
ByteArrayInputStream
public ByteArrayInputStream(byte[] bytes)
-
-
Method Details
-
readInteger
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
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
Read fixed length string.- Parameters:
length- length of string to read- Returns:
- string
- Throws:
IOException- in case of EOF
-
readLengthEncodedString
Read variable-length string. Preceding packed integer indicates the length of the string.- Returns:
- string
- Throws:
IOException- in case of EOF
-
readZeroTerminatedString
Read variable-length string. End is indicated by 0x00 byte.- Returns:
- string
- Throws:
IOException- in case of EOF
-
read
- Throws:
IOException
-
fill
- Throws:
IOException
-
readBitSet
- Throws:
IOException
-
readPackedInteger
- Returns:
- integer
- Throws:
IOException- in case of malformed number, eof, null, or long- See Also:
-
readPackedLong
- Returns:
- long
- Throws:
IOException- in case of malformed number, eof, null- See Also:
-
readPackedNumber
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
- Overrides:
availablein classInputStream- Throws:
IOException
-
peek
- Throws:
IOException
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
enterBlock
public void enterBlock(int length) -
skipToTheEndOfTheBlock
- Throws:
IOException
-
getPosition
public int getPosition() -
mark
public void mark(int readlimit) - Overrides:
markin classInputStream
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-
reset
- Overrides:
resetin classInputStream- Throws:
IOException
-
fastSkip
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 regularInputStream.skip(long)method must be used.- Parameters:
n- - number of bytes to skip- Returns:
- number of bytes skipped
- Throws:
IOException
-