org.knime.core.data.container
Class BlockableInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.knime.core.data.container.BlockableInputStream
All Implemented Interfaces:
Closeable, KNIMEStreamConstants

final class BlockableInputStream
extends InputStream
implements KNIMEStreamConstants

Input Stream that wraps a given input stream and searches for terminated end blocks. Such a block is typically a serialized DataCell. It will simulate an eof file if it encounters a block end. This class is intended to be used on streams written with the BlockableOutputStream class.

Author:
wiswedel, University of Konstanz
See Also:
BlockableOutputStream

Field Summary
 
Fields inherited from interface org.knime.core.data.container.KNIMEStreamConstants
BYTE_ROW_SEPARATOR, BYTE_TYPE_MISSING, BYTE_TYPE_SERIALIZATION, BYTE_TYPE_START, DUMMY_ROW_KEY, TC_ESCAPE, TC_TERMINATE
 
Constructor Summary
BlockableInputStream(InputStream inStream)
          Inits the Stream.
 
Method Summary
 void close()
          
 void endBlock()
          Finishes the current block, i.e.
 int read()
          Reads next byte from stream and if it is an escape byte, it returns the next following byte.
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockableInputStream

BlockableInputStream(InputStream inStream)
Inits the Stream.

Parameters:
inStream - the stream to wrap; must not be null
Method Detail

read

public int read()
         throws IOException
Reads next byte from stream and if it is an escape byte, it returns the next following byte. If it is a terminate byte, it returns -1, i.e. eof.

Specified by:
read in class InputStream
Throws:
IOException

endBlock

public void endBlock()
              throws IOException
Finishes the current block, i.e. when the block end has already been reached, releases the block and allows further read() operations. Otherwise it will subsequently call read() until the block end is reached.

Throws:
IOException - if read() fails

close

public void close()
           throws IOException

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


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.