uk.org.ogsadai.client.toolkit.activity.delivery
Class DataTransportBlockReader

java.lang.Object
  |
  +--uk.org.ogsadai.client.toolkit.activity.delivery.DataTransportBlockReader
All Implemented Interfaces:
BlockReader

public class DataTransportBlockReader
extends java.lang.Object
implements BlockReader

A BlockReader implementation which fetches each block from a DataTransport output stream.

Author:
The OGSA-DAI Project Team

Constructor Summary
DataTransportBlockReader(DataTransport service)
          Default constructor.
DataTransportBlockReader(DataTransport service, int blocksToFetch)
          Default constructor.
 
Method Summary
 java.lang.Object fetchBlock()
          Obtain a block from the DataTransport output stream, or return null if the end of the stream has been reached.
 boolean hasNext()
          Returns whether there are any more blocks.
 java.lang.Object next()
          Returns the next block from the buffer and fetches the subsequent block from the DataTransport output stream and sticks this in the buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataTransportBlockReader

public DataTransportBlockReader(DataTransport service)
                         throws ResourceException,
                                DataFormatException,
                                ServiceCommsException
Default constructor. Fetches the first block of data from the DataTransport output stream into the local buffer.

Parameters:
service - the DataTransport object for the DS which is configured with a DT output stream
Throws:
DataFormatException
ServiceCommsException
ResourceException

DataTransportBlockReader

public DataTransportBlockReader(DataTransport service,
                                int blocksToFetch)
                         throws ResourceException,
                                DataFormatException,
                                ServiceCommsException
Default constructor. Fetches the first block of data from the DataTransport output stream into the local buffer.

Parameters:
service - the DataTransport object for the DS which is configured with a DT output stream
blocksToFetch - the number of blocks to fetch from the DataTransport output stream at once. These blocks will be amalgamated into a single block, returned by the next() method.
Throws:
DataFormatException
ServiceCommsException
ResourceException
Method Detail

hasNext

public boolean hasNext()
Returns whether there are any more blocks.

Specified by:
hasNext in interface BlockReader
Returns:
true iff there are any more blocks

next

public java.lang.Object next()
Returns the next block from the buffer and fetches the subsequent block from the DataTransport output stream and sticks this in the buffer.

Specified by:
next in interface BlockReader
Returns:
the next block

fetchBlock

public java.lang.Object fetchBlock()
                            throws ResourceException,
                                   DataFormatException,
                                   ServiceCommsException
Obtain a block from the DataTransport output stream, or return null if the end of the stream has been reached.

Returns:
the next block from the stream, or null
Throws:
DataFormatException
ServiceCommsException
ResourceException