org.opcfoundation.ua.utils.bytebuffer
Class OrderedByteBufferInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.opcfoundation.ua.utils.bytebuffer.OrderedByteBufferInputStream
All Implemented Interfaces:
Closeable

public class OrderedByteBufferInputStream
extends InputStream

Input stream with a sequence of ByteBuffers as backend. ByteBuffers can be submitted in random order. Input stream sleeps until data becomes available. Sequence number determines the order of how the data becomes visible to the input stream.

Author:
Toni Kalajainen (toni.kalajainen@vtt.fi)

Constructor Summary
OrderedByteBufferInputStream()
          Constructor for OrderedByteBufferInputStream.
 
Method Summary
 int available()
          
 void close()
          close.
 void close(int sequenceNumber)
          close.
 void forceClose()
          forceClose.
 void offer(ByteBuffer buf)
          Submits a byte buffer for the input stream to use
 void offer(int sequenceNumber, ByteBuffer buf)
          Submits a byte buffer to the use of input stream
 int read()
          
 int read(byte[] b, int off, int len)
          
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrderedByteBufferInputStream

public OrderedByteBufferInputStream()

Constructor for OrderedByteBufferInputStream.

Method Detail

offer

public void offer(int sequenceNumber,
                  ByteBuffer buf)
Submits a byte buffer to the use of input stream

Parameters:
sequenceNumber - a int.
buf - a ByteBuffer object.

offer

public void offer(ByteBuffer buf)
Submits a byte buffer for the input stream to use

Parameters:
buf - a ByteBuffer object.

close

public void close()

close.

Specified by:
close in interface Closeable
Overrides:
close in class InputStream

close

public void close(int sequenceNumber)

close.

Parameters:
sequenceNumber - a int.

forceClose

public void forceClose()

forceClose.


read

public int read()
         throws IOException

Specified by:
read in class InputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException

Overrides:
read in class InputStream
Throws:
IOException

available

public int available()
              throws IOException

Overrides:
available in class InputStream
Throws:
IOException


Copyright © 2018. All rights reserved.