Class TIOStreamTransport

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable
    Direct Known Subclasses:
    TSocket, TZlibTransport

    public class TIOStreamTransport
    extends TEndpointTransport
    This is the most commonly used base transport. It takes an InputStream or an OutputStream or both and uses it/them to perform transport operations. This allows for compatibility with all the nice constructs Java already has to provide a variety of types of streams.
    • Field Detail

      • inputStream_

        protected java.io.InputStream inputStream_
        Underlying inputStream
      • outputStream_

        protected java.io.OutputStream outputStream_
        Underlying outputStream
    • Constructor Detail

      • TIOStreamTransport

        protected TIOStreamTransport()
                              throws TTransportException
        Subclasses can invoke the default constructor and then assign the input streams in the open method.
        Throws:
        TTransportException
      • TIOStreamTransport

        public TIOStreamTransport​(TConfiguration config,
                                  java.io.InputStream is)
                           throws TTransportException
        Input stream constructor, constructs an input only transport.
        Parameters:
        config -
        is - Input stream to read from
        Throws:
        TTransportException
      • TIOStreamTransport

        public TIOStreamTransport​(java.io.InputStream is)
                           throws TTransportException
        Input stream constructor, constructs an input only transport.
        Parameters:
        is - Input stream to read from
        Throws:
        TTransportException
      • TIOStreamTransport

        public TIOStreamTransport​(TConfiguration config,
                                  java.io.OutputStream os)
                           throws TTransportException
        Output stream constructor, constructs an output only transport.
        Parameters:
        config -
        os - Output stream to write to
        Throws:
        TTransportException
      • TIOStreamTransport

        public TIOStreamTransport​(java.io.OutputStream os)
                           throws TTransportException
        Output stream constructor, constructs an output only transport.
        Parameters:
        os - Output stream to write to
        Throws:
        TTransportException
      • TIOStreamTransport

        public TIOStreamTransport​(TConfiguration config,
                                  java.io.InputStream is,
                                  java.io.OutputStream os)
                           throws TTransportException
        Two-way stream constructor.
        Parameters:
        config -
        is - Input stream to read from
        os - Output stream to read from
        Throws:
        TTransportException
      • TIOStreamTransport

        public TIOStreamTransport​(java.io.InputStream is,
                                  java.io.OutputStream os)
                           throws TTransportException
        Two-way stream constructor.
        Parameters:
        is - Input stream to read from
        os - Output stream to read from
        Throws:
        TTransportException
    • Method Detail

      • isOpen

        public boolean isOpen()
        Description copied from class: TTransport
        Queries whether the transport is open.
        Specified by:
        isOpen in class TTransport
        Returns:
        false after close is called.
      • close

        public void close()
        Closes both the input and output streams.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class TTransport
      • read

        public int read​(byte[] buf,
                        int off,
                        int len)
                 throws TTransportException
        Reads from the underlying input stream if not null.
        Specified by:
        read in class TTransport
        Parameters:
        buf - Array to read into
        off - Index to start reading at
        len - Maximum number of bytes to read
        Returns:
        The number of bytes actually read
        Throws:
        TTransportException - if there was an error reading data
      • write

        public void write​(byte[] buf,
                          int off,
                          int len)
                   throws TTransportException
        Writes to the underlying output stream if not null.
        Specified by:
        write in class TTransport
        Parameters:
        buf - The output data buffer
        off - The offset to start writing from
        len - The number of bytes to write
        Throws:
        TTransportException - if there was an error writing data