org.opcfoundation.ua.utils.bytebuffer
Class IncubationBuffer

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

public class IncubationBuffer
extends InputStream

Input stream with a sequence of ByteBuffers as backend. The data in ByteBuffers in read in the order they are "incubated" The data becomes available when the ByteBuffers are "hatched" Input stream blocks until data becomes available.

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

Field Summary
protected static ByteBuffer CLOSED_MARKER
          Constant CLOSED_MARKER
protected  ByteBuffer cur
           
protected  IncubationQueue<ByteBuffer> queue
           
 
Constructor Summary
IncubationBuffer()
          Constructor for IncubationBuffer.
 
Method Summary
 int available()
          
 void close()
          close.
 void forceClose()
          forceClose.
 void hatch(ByteBuffer buf)
          Makes the byte buffer available to input stream reader
 void incubate(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
 

Field Detail

CLOSED_MARKER

protected static final ByteBuffer CLOSED_MARKER
Constant CLOSED_MARKER


queue

protected IncubationQueue<ByteBuffer> queue

cur

protected ByteBuffer cur
Constructor Detail

IncubationBuffer

public IncubationBuffer()

Constructor for IncubationBuffer.

Method Detail

incubate

public void incubate(ByteBuffer buf)
Submits a byte buffer to the use of input stream

Parameters:
buf - byte buffer to offer for use

hatch

public void hatch(ByteBuffer buf)
Makes the byte buffer available to input stream reader

Parameters:
buf - a ByteBuffer object.

close

public void close()

close.

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

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.