uk.org.ogsadai.client.toolkit.data
Class BinaryDataStreamDataValueIterator

java.lang.Object
  extended by uk.org.ogsadai.client.toolkit.data.BinaryDataStreamDataValueIterator
All Implemented Interfaces:
DataValueIterator

public class BinaryDataStreamDataValueIterator
extends java.lang.Object
implements DataValueIterator

A data value iterator that reads data values from a binary data stream.

Author:
The OGSA-DAI Project Team.

Constructor Summary
BinaryDataStreamDataValueIterator(java.io.InputStream inputStream)
          Constructor.
 
Method Summary
 boolean hasNext()
          Returns true if the iteration has more data.
 DataValue next()
          Returns the next element in the iteration.
 boolean nextAsBoolean()
          Gets the next data value as a boolean.
 byte[] nextAsByteArray()
          Gets the next data value as a byte array.
 char[] nextAsCharArray()
          Gets the next data value as a char array.
 java.util.Date nextAsDate()
          Gets the next data value as a Date.
 double nextAsDouble()
          Gets the next data value as a double.
 float nextAsFloat()
          Gets the next data value as a float.
 int nextAsInt()
          Gets the next data value as a int.
 long nextAsLong()
          Gets the next data value as a long.
 java.lang.String nextAsString()
          Gets the next data value as a String.
 DataValue readDataValue()
          Reads a data value from the input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryDataStreamDataValueIterator

public BinaryDataStreamDataValueIterator(java.io.InputStream inputStream)
Constructor. Wraps the specified input stream.

Parameters:
inputStream - input stream with binary data
Method Detail

hasNext

public boolean hasNext()
                throws DataStreamErrorException,
                       UnexpectedDataValueException,
                       DataSourceUsageException
Description copied from interface: DataValueIterator
Returns true if the iteration has more data.

Specified by:
hasNext in interface DataValueIterator
Returns:
true if the iteration has more data, false otherwise.
Throws:
DataStreamErrorException - if there is an error on the data stream.
UnexpectedDataValueException - if there is an unexpected data value on the data stream.
DataSourceUsageException - if there is an error reading from a data source.

readDataValue

public DataValue readDataValue()
                        throws java.io.IOException,
                               DataStreamException
Reads a data value from the input stream.

Returns:
next data value or null if there are no more blocks.
Throws:
java.io.IOException - if an error occurred reading the request data stream
DataStreamException - if the data stream ends in an error

next

public DataValue next()
               throws DataStreamErrorException,
                      UnexpectedDataValueException,
                      DataSourceUsageException
Description copied from interface: DataValueIterator
Returns the next element in the iteration.

Specified by:
next in interface DataValueIterator
Returns:
next element in the iteration.
Throws:
DataStreamErrorException - if there is an error on the data stream.
UnexpectedDataValueException - if there is an unexpected data value on the data stream.
DataSourceUsageException - if there is an error reading from a data source.

nextAsBoolean

public boolean nextAsBoolean()
                      throws DataStreamErrorException,
                             UnexpectedDataValueException,
                             DataSourceUsageException
Description copied from interface: DataValueIterator
Gets the next data value as a boolean.

Specified by:
nextAsBoolean in interface DataValueIterator
Returns:
the next data value as a boolean.
Throws:
DataStreamErrorException - if there is an error on the data stream.
UnexpectedDataValueException - if the next data value is not a boolean.
DataSourceUsageException - if there is an error reading from a data source.

nextAsByteArray

public byte[] nextAsByteArray()
                       throws DataStreamErrorException,
                              UnexpectedDataValueException,
                              DataSourceUsageException
Description copied from interface: DataValueIterator
Gets the next data value as a byte array.

Specified by:
nextAsByteArray in interface DataValueIterator
Returns:
the next data value as a byte array.
Throws:
DataStreamErrorException - if there is an error on the data stream.
UnexpectedDataValueException - if the next data value is not an array of bytes.
DataSourceUsageException - if there is an error reading from a data source.

nextAsCharArray

public char[] nextAsCharArray()
                       throws DataStreamErrorException,
                              UnexpectedDataValueException,
                              DataSourceUsageException
Description copied from interface: DataValueIterator
Gets the next data value as a char array.

Specified by:
nextAsCharArray in interface DataValueIterator
Returns:
the next data value as a char array.
Throws:
DataStreamErrorException - if there is an error on the data stream.
UnexpectedDataValueException - if the next data value is not an array of characters.
DataSourceUsageException - if there is an error reading from a data source.

nextAsString

public java.lang.String nextAsString()
                              throws DataStreamErrorException,
                                     UnexpectedDataValueException,
                                     DataSourceUsageException
Description copied from interface: DataValueIterator
Gets the next data value as a String.

Specified by:
nextAsString in interface DataValueIterator
Returns:
the next data value as a String.
Throws:
DataStreamErrorException - if there is an error on the data stream.
UnexpectedDataValueException - if the next data value is not a string.
DataSourceUsageException - if there is an error reading from a data source.

nextAsDate

public java.util.Date nextAsDate()
                          throws DataStreamErrorException,
                                 UnexpectedDataValueException,
                                 DataSourceUsageException
Description copied from interface: DataValueIterator
Gets the next data value as a Date.

Specified by:
nextAsDate in interface DataValueIterator
Returns:
the next data value as a Date.
Throws:
DataStreamErrorException - if there is an error on the data stream.
UnexpectedDataValueException - if the next data value is not a date.
DataSourceUsageException - if there is an error reading from a data source.

nextAsDouble

public double nextAsDouble()
                    throws DataStreamErrorException,
                           UnexpectedDataValueException,
                           DataSourceUsageException
Description copied from interface: DataValueIterator
Gets the next data value as a double.

Specified by:
nextAsDouble in interface DataValueIterator
Returns:
the next data value as a double.
Throws:
DataStreamErrorException - if there is an error on the data stream.
UnexpectedDataValueException - if the next data value is not a double.
DataSourceUsageException - if there is an error reading from a data source.

nextAsFloat

public float nextAsFloat()
                  throws DataStreamErrorException,
                         UnexpectedDataValueException,
                         DataSourceUsageException
Description copied from interface: DataValueIterator
Gets the next data value as a float.

Specified by:
nextAsFloat in interface DataValueIterator
Returns:
the next data value as a float.
Throws:
DataStreamErrorException - if there is an error on the data stream.
UnexpectedDataValueException - if the next data value is not a float.
DataSourceUsageException - if there is an error reading from a data source.

nextAsInt

public int nextAsInt()
              throws DataStreamErrorException,
                     UnexpectedDataValueException,
                     DataSourceUsageException
Description copied from interface: DataValueIterator
Gets the next data value as a int.

Specified by:
nextAsInt in interface DataValueIterator
Returns:
the next data value as a int.
Throws:
DataStreamErrorException - if there is an error on the data stream.
UnexpectedDataValueException - if the next data value is not a integer.
DataSourceUsageException - if there is an error reading from a data source.

nextAsLong

public long nextAsLong()
                throws DataStreamErrorException,
                       UnexpectedDataValueException,
                       DataSourceUsageException
Description copied from interface: DataValueIterator
Gets the next data value as a long.

Specified by:
nextAsLong in interface DataValueIterator
Returns:
the next data value as a long.
Throws:
DataStreamErrorException - if there is an error on the data stream.
UnexpectedDataValueException - if the next data value is not a long.
DataSourceUsageException - if there is an error reading from a data source.