Class InputConnection

  • All Implemented Interfaces:
    IConnection, IInputConnection

    public class InputConnection
    extends AbstractConnection
    implements IInputConnection
    Input connection implementation for byte streams. Must synchronized its internal data because the connection handler and the connection user (i.e. a component) are using the connection concurrently. - the handler uses addData to forward received data to the connection. - the connection user calls interface methods to read data.
    • Field Detail

      • data

        protected java.util.List<byte[]> data
        The data.
      • offset

        protected int offset
        The offset (startvalue of current first row).
      • position

        protected int position
        The position.
      • size

        protected int size
        The size.
      • ofuture

        protected Future<java.lang.Byte> ofuture
    • Method Detail

      • read

        public int read()
        Non-blocking read. Tries to read the next byte.
        Specified by:
        read in interface IInputConnection
        Returns:
        The next byte or -1 if the end of the stream has been reached.
      • read

        public int read​(byte[] buffer)
        Non-blocking read. Tries to fill the buffer from the stream.
        Specified by:
        read in interface IInputConnection
        Parameters:
        buffer - The buffer to read in.
        Returns:
        The number of bytes that could be read into the buffer.
      • internalRead

        protected int internalRead()
        Non-blocking read. Tries to read the next byte.
        Returns:
        The next byte or -1 if none is currently available.
        Throws:
        exception - if end of stream has been reached.
      • getNextByteArray

        public byte[] getNextByteArray()
        Get the next data byte array.
      • areadNext

        public IFuture<java.lang.Byte> areadNext()
        Asynchronous read.
        Returns:
        Bytes one by one till end of stream or closed.
      • available

        public int available()
        Get the number of available bytes.
        Specified by:
        available in interface IInputConnection
        Returns:
        The number of available bytes.
      • addData

        public void addData​(byte[] data)
        Add data to the internal data buffer.
        Parameters:
        data - The data to add. If stream is closed adding data is not allowed.
      • getStoredDataSize

        public int getStoredDataSize()
        Get the size of the stored data.
      • dataRead

        protected void dataRead()
      • writeToOutputStream

        public ISubscriptionIntermediateFuture<java.lang.Long> writeToOutputStream​(java.io.OutputStream os,
                                                                                   IExternalAccess component)
        Read all data from output stream to the connection. The result is an intermediate future that reports back the size that was read. It can also be used to terminate reading.
        Specified by:
        writeToOutputStream in interface IInputConnection
        Parameters:
        is - The input stream.
        component - The component.