Class StandardEXTDTAReaderInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    final class StandardEXTDTAReaderInputStream
    extends EXTDTAReaderInputStream
    Implementation of InputStream which get EXTDTA from the DDMReader. This class can be used to stream LOBs from Network client to the Network server.
    • Field Detail

      • length

        private final long length
        Length of stream
      • reader

        private final DDMReader reader
        DDMReader. Used to get more data.
      • remainingBytes

        private long remainingBytes
        Remaining bytes in stream
      • currentBuffer

        private java.io.ByteArrayInputStream currentBuffer
        Current data buffer
    • Constructor Detail

      • StandardEXTDTAReaderInputStream

        StandardEXTDTAReaderInputStream​(DDMReader reader,
                                        boolean readStatusByte)
                                 throws DRDAProtocolException
        Constructor.
        Parameters:
        reader - The reader to get data from
        readStatusByte - whether or not to read the trailing Derby-specific EXTDTA stream status byte
        Throws:
        DRDAProtocolException - if thrown while initializing current buffer.
    • Method Detail

      • read

        public final int read()
                       throws java.io.IOException
        Reads the next byte of data from the input stream.

        This subclass of InputStream implements this method by reading the next byte from the current buffer. If there is more data, it will be requested a new buffer from the DDMReader.

        Specified by:
        read in class java.io.InputStream
        Returns:
        the next byte of data, or -1 if the end of the stream is reached.
        Throws:
        java.io.IOException - if an I/O error occurs.
        See Also:
        InputStream.read()
      • read

        public final int read​(byte[] b,
                              int off,
                              int len)
                       throws java.io.IOException
        Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read, possibly zero. The number of bytes actually read is returned as an integer. This subclass implements this method by calling this method on the current buffer, which is an instance of ByteArrayInputStream. If the current buffer does not have any data, it will be requested a new buffer from the DDMReader.
        Overrides:
        read in class java.io.InputStream
        Parameters:
        b - the buffer into which the data is read.
        off - the start offset in array b at which the data is written.
        len - the maximum number of bytes to 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 an I/O error occurs.
        java.lang.NullPointerException - if b is null.
        See Also:
        InputStream.read(byte[], int, int)
      • available

        public final int available()
        Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.

        This subclass implements this method by calling available on the current buffer, which is a ByteInputStreamReader.

        Overrides:
        available in class java.io.InputStream
        Returns:
        the number of bytes that can be read from this input stream without blocking.
      • getLength

        final long getLength()
        Returns the number of bytes returned by this stream.

        The length includes data which has been already read at the invocation time, but doesn't include any meta data (like the Derby-specific EXTDTA status byte).

        Returns:
        The number of bytes that will be returned by this stream.
      • nextBuffer

        private void nextBuffer()
                         throws java.io.IOException
        Fetches the next buffer.
        Throws:
        java.io.IOException - if fetching the buffer fails