com.davisor.data.stream
Class ResultSetDataStream

java.lang.Object
  extended bycom.davisor.data.VoidData
      extended bycom.davisor.data.stream.ResultSetDataStream
All Implemented Interfaces:
Data, DataStream

public class ResultSetDataStream
extends VoidData
implements DataStream

A ResultSetDataStream makes a data stream out of a SQL result set.

Since:
JDK1.1
See Also:
Type

Field Summary
protected  java.lang.Object M_metaData
          Stream meta data (may be null).
protected  boolean M_next
          Next element precense indicator.
protected  java.sql.ResultSet M_resultSet
          Source result set.
 
Fields inherited from class com.davisor.data.VoidData
M_type
 
Fields inherited from interface com.davisor.data.stream.DataStream
INITIAL_INDEX
 
Constructor Summary
ResultSetDataStream(java.sql.ResultSet resultSet)
          Creates a new result set data stream.
ResultSetDataStream(java.sql.ResultSet resultSet, java.util.Map typeNames)
          Creates a new result set data stream.
ResultSetDataStream(java.sql.ResultSet resultSet, java.lang.String[] typeNames)
          Creates a new result set data stream.
 
Method Summary
 boolean close()
          Closes also result set.
 long getIndex()
          Retrieves the index number of the element returned by the latest next() call.
 boolean hasNext()
          Tests if the stream still contains data.
 DataValue next()
          Gets the next data from the stream.
 
Methods inherited from class com.davisor.data.VoidData
equals, getDataValue, getType, hashCode, setType, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.davisor.data.Data
getType
 

Field Detail

M_metaData

protected java.lang.Object M_metaData
Stream meta data (may be null).


M_next

protected boolean M_next
Next element precense indicator.


M_resultSet

protected java.sql.ResultSet M_resultSet
Source result set.

Constructor Detail

ResultSetDataStream

public ResultSetDataStream(java.sql.ResultSet resultSet)
                    throws java.sql.SQLException
Creates a new result set data stream. Each result set column contributes one data stream. Result set column types, names, and type names will be mapped to data types and channel names as described in the TupleType class documentation. In particular, (unique) channel names and (non-unique) type names are both taken from the result set column names.

Parameters:
resultSet - the result set data source
See Also:
ResultSetDataStream(ResultSet,String[])

ResultSetDataStream

public ResultSetDataStream(java.sql.ResultSet resultSet,
                           java.lang.String[] typeNames)
                    throws java.sql.SQLException
Creates a new result set data stream. Each result set column contributes one data stream. Result set column types, names, and type names will be mapped to data types and channel names as described in the TupleType class documentation. In particular, (unique) channel names are taken from result set column names, while (non-unique) type names are taken from the given array of type names.

Parameters:
resultSet - the result set data source
typeNames - type names for each result set column
See Also:
TupleType.TupleType(ResultSet,String[])

ResultSetDataStream

public ResultSetDataStream(java.sql.ResultSet resultSet,
                           java.util.Map typeNames)
                    throws java.sql.SQLException
Creates a new result set data stream. Each result set column contributes one data stream. Result set column types, names, and type names will be mapped to data types and channel names as described in the TupleType class documentation. In particular, (unique) channel names are taken from result set column names, while (non-unique) type names are taken from the given array of type names.

Parameters:
resultSet - the result set data source
typeNames - type names for each result set column
See Also:
TupleType.TupleType(ResultSetMetaData,String[])
Method Detail

close

public boolean close()
Closes also result set.

Specified by:
close in interface DataStream
Returns:
false if freeing result set fails
See Also:
DataStream.hasNext()

getIndex

public long getIndex()
Retrieves the index number of the element returned by the latest next() call. The index represents the position of the element within this stream. The stream index may or may not be equal to any other indexes the element itself thinks it posesses.

The index value is initially -1, indicating no element. After first next() call, index becomes 0, then 1, and so on. This functionality resembles java.sql.resultSet#getRow method functionality, but with the difference that the index counter starts from 0, not 1.

Specified by:
getIndex in interface DataStream
Returns:
element index

hasNext

public boolean hasNext()
Tests if the stream still contains data.

Specified by:
hasNext in interface DataStream
Returns:
true if it does.

next

public DataValue next()
               throws InvalidDataException
Gets the next data from the stream.

Specified by:
next in interface DataStream
Throws:
InvalidDataException - if the stream content does not satisfy the stream type.


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.