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

    Fields inherited from class java.io.FilterInputStream

    in
  • Constructor Summary

    Constructors 
    Constructor Description
    CompressionSplittedInputStream​(java.io.InputStream in, CompressorStreamsFactory streamsFactory)  
  • Method Summary

    Modifier and Type Method Description
    int available()
    Same as InputStream.available(), except that the exact number of bytes that can be read from the underlying InputStream may not be accurate until it is known if the next bytes contain compressed data or not.
    void close()
    Closes this stream.
    int read()
    Forwards the read to read(byte[], int, int).
    int read​(byte[] b)
    Forwards the read to read(byte[], int, int).
    int read​(byte[] b, int off, int len)
    Reads bytes from the underlying InputStream either from the one that gets data directly from the original source InputStream or from a compressorable InputStream, if reading of a compressed X Protocol frame is in progress.
    int readFully​(byte[] b)
    Reads the number of bytes required to fill the given buffer from the underlying InputStream, blocking if needed.

    Methods inherited from class java.io.FilterInputStream

    mark, markSupported, reset, skip

    Methods inherited from class java.io.InputStream

    nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • available

      public int available() throws java.io.IOException
      Same as InputStream.available(), except that the exact number of bytes that can be read from the underlying InputStream may not be accurate until it is known if the next bytes contain compressed data or not.
      Overrides:
      available in class java.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.IOException
      Closes this stream.
      Specified by:
      close in interface java.lang.AutoCloseable
      Specified by:
      close in interface java.io.Closeable
      Overrides:
      close in class java.io.FilterInputStream
      Throws:
      java.io.IOException
      See Also:
      FilterInputStream.close()
    • read

      public int read() throws java.io.IOException
      Forwards the read to read(byte[], int, int).
      Overrides:
      read in class java.io.FilterInputStream
      Throws:
      java.io.IOException
      See Also:
      FilterInputStream.read()
    • read

      public int read​(byte[] b) throws java.io.IOException
      Forwards the read to read(byte[], int, int).
      Overrides:
      read in class java.io.FilterInputStream
      Throws:
      java.io.IOException
      See Also:
      FilterInputStream.read(byte[])
    • read

      public int read​(byte[] b, int off, int len) throws java.io.IOException
      Reads bytes from the underlying InputStream either from the one that gets data directly from the original source InputStream or from a compressorable InputStream, if reading of a compressed X Protocol frame is in progress.
      Overrides:
      read in class java.io.FilterInputStream
      Throws:
      java.io.IOException
      See Also:
      FilterInputStream.read(byte[], int, int)
    • readFully

      public int readFully​(byte[] b) throws java.io.IOException
      Reads the number of bytes required to fill the given buffer from the underlying InputStream, blocking if needed.
      Parameters:
      b - the buffer into which the data is read.
      Returns:
      the total number of bytes read into the buffer, or -1 if 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.