Package com.mysql.cj.protocol.x
Class CompressionSplittedInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
com.mysql.cj.protocol.x.CompressionSplittedInputStream
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class CompressionSplittedInputStream
extends java.io.FilterInputStream
An
InputStream wrapper that analyzes X Protocol frames and, if compressed, routes them to a secondary compressor-able InputStream that also
knows how to rebuild uncompressed X Protocol frames from compressed ones.-
Field Summary
-
Constructor Summary
Constructors Constructor Description CompressionSplittedInputStream(java.io.InputStream in, CompressorStreamsFactory streamsFactory) -
Method Summary
Modifier and Type Method Description intavailable()Same asInputStream.available(), except that the exact number of bytes that can be read from the underlyingInputStreammay not be accurate until it is known if the next bytes contain compressed data or not.voidclose()Closes this stream.intread()Forwards the read toread(byte[], int, int).intread(byte[] b)Forwards the read toread(byte[], int, int).intread(byte[] b, int off, int len)Reads bytes from the underlyingInputStreameither from the one that gets data directly from the original sourceInputStreamor from a compressorableInputStream, if reading of a compressed X Protocol frame is in progress.intreadFully(byte[] b)Reads the number of bytes required to fill the given buffer from the underlyingInputStream, blocking if needed.
-
Constructor Details
-
CompressionSplittedInputStream
public CompressionSplittedInputStream(java.io.InputStream in, CompressorStreamsFactory streamsFactory)
-
-
Method Details
-
available
public int available() throws java.io.IOExceptionSame asInputStream.available(), except that the exact number of bytes that can be read from the underlyingInputStreammay not be accurate until it is known if the next bytes contain compressed data or not.- Overrides:
availablein classjava.io.FilterInputStream- Returns:
- an approximate number of available bytes to read.
- Throws:
java.io.IOException- See Also:
FilterInputStream.available()
-
close
public void close() throws java.io.IOExceptionCloses this stream.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.FilterInputStream- Throws:
java.io.IOException- See Also:
FilterInputStream.close()
-
read
public int read() throws java.io.IOExceptionForwards the read toread(byte[], int, int).- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException- See Also:
FilterInputStream.read()
-
read
public int read(byte[] b) throws java.io.IOExceptionForwards the read toread(byte[], int, int).- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException- See Also:
FilterInputStream.read(byte[])
-
read
public int read(byte[] b, int off, int len) throws java.io.IOExceptionReads bytes from the underlyingInputStreameither from the one that gets data directly from the original sourceInputStreamor from a compressorableInputStream, if reading of a compressed X Protocol frame is in progress.- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException- See Also:
FilterInputStream.read(byte[], int, int)
-
readFully
public int readFully(byte[] b) throws java.io.IOExceptionReads the number of bytes required to fill the given buffer from the underlyingInputStream, blocking if needed.- Parameters:
b- the buffer into which the data is read.- Returns:
- the total number of bytes read into the buffer, or
-1if there is no more data because the end of the stream has been reached. - Throws:
java.io.IOException- if any of the underlying I/O operations fail.
-