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 an output stream exposed by a data service resource exposed by a data service using the service's get operations.

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
private  int mBlocksToFetch
          The number of blocks to fetch from a service at once.
private  java.lang.Object mNextBlock
          The block which will be returned the next time the next method is called.
private  DataTransport mService
          Object that handles get operations on a service.
 
Constructor Summary
DataTransportBlockReader(DataTransport service)
           
DataTransportBlockReader(DataTransport service, int blocksToFetch)
          Default constructor.
 
Method Summary
 java.lang.Object fetchBlock()
          Obtain a block from the output stream exposed by a data service resource of the service or return null if all the data has been read.
 boolean hasNext()
          Indicates whether or not there are any more blocks of data to be read from the block reader.
 java.lang.Object next()
          Gets the next block of data contained in the block reader.
 
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
Copyright statement

See Also:
Constant Field Values

mNextBlock

private java.lang.Object mNextBlock
The block which will be returned the next time the next method is called. (We employ a one-block buffer to enable hasNext() to work.)


mBlocksToFetch

private final int mBlocksToFetch
The number of blocks to fetch from a service at once.


mService

private final DataTransport mService
Object that handles get operations on a service.

Constructor Detail

DataTransportBlockReader

public DataTransportBlockReader(DataTransport service)
                         throws StreamDataException

DataTransportBlockReader

public DataTransportBlockReader(DataTransport service,
                                int blocksToFetch)
                         throws StreamDataException
Default constructor. Fetches the first block of data from an output stream exposed by a data service resource exposed by a data service and buffers this locally.

Parameters:
service - Object handling access to the service's output stream.
blocksToFetch - The number of blocks to fetch from the service at once. These are aggregated into a single block service-side.
Throws:
StreamDataException - If there is a problem when streaming the data from the service.
Method Detail

hasNext

public boolean hasNext()
Description copied from interface: BlockReader
Indicates whether or not there are any more blocks of data to be read from the block reader.

Specified by:
hasNext in interface BlockReader
Returns:
true if there are more blocks to be read or false otherwise

next

public java.lang.Object next()
Description copied from interface: BlockReader
Gets the next block of data contained in the block reader.

Specified by:
next in interface BlockReader
Returns:
an Object

fetchBlock

public java.lang.Object fetchBlock()
                            throws StreamDataException
Obtain a block from the output stream exposed by a data service resource of the service or return null if all the data has been read.

Returns:
block
Throws:
StreamDataException - If there is a problem when streaming the data from the service.