uk.org.ogsadai.common
Class BlockReaderInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--uk.org.ogsadai.common.BlockReaderInputStream

public class BlockReaderInputStream
extends java.io.InputStream

An java.io.InputStream that wraps a BlockReader.

The blocks contained in the BlockReader must be Strings, byte[] or implementations of the org.w3c.dom.Node interface.

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
           
private  boolean mActive
           
private  int mAmount
           
private  int mAvailable
           
private  byte[] mBlock
           
private  BlockReader mBlockReader
           
private  byte[] mByte
           
private  int mBytesRead
           
private  int mIndex
           
private  int mNeeded
           
 
Fields inherited from class java.io.InputStream
 
Constructor Summary
BlockReaderInputStream(BlockReader blockReader)
          Constructs a new object that wraps the given BlockReader.
 
Method Summary
private  void getNodeBlock(org.w3c.dom.Node node)
          Converts a block that is a Document Object Model org.w3c.dom.Node into a byte[] and stores this internally.
private  void nextBlock()
          Gets the next block from the BlockReader if there are any blocks still to get.
 int read()
           
 int read(byte[] bytes, int index, int length)
           
 
Methods inherited from class java.io.InputStream
available, close, 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

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
See Also:
Constant Field Values

mBlockReader

private final BlockReader mBlockReader

mBlock

private byte[] mBlock

mIndex

private int mIndex

mAvailable

private int mAvailable

mNeeded

private int mNeeded

mAmount

private int mAmount

mBytesRead

private int mBytesRead

mActive

private boolean mActive

mByte

private byte[] mByte
Constructor Detail

BlockReaderInputStream

public BlockReaderInputStream(BlockReader blockReader)
Constructs a new object that wraps the given BlockReader.

Parameters:
blockReader - The BlockReader to wrap.
Method Detail

read

public int read(byte[] bytes,
                int index,
                int length)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
java.io.IOException

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
java.io.IOException

nextBlock

private void nextBlock()
                throws java.io.IOException
Gets the next block from the BlockReader if there are any blocks still to get.

Throws:
java.io.IOException - if an I/O error occurs caused by an unsupported block type being provided by the wrapped BlockReader. The IOException will have a UnsupportedBlockException as its cause.

getNodeBlock

private void getNodeBlock(org.w3c.dom.Node node)
Converts a block that is a Document Object Model org.w3c.dom.Node into a byte[] and stores this internally.

Parameters:
node - The Node to convert.