info.informatica.data
Class ResultsetDataset

java.lang.Object
  extended by info.informatica.data.AbstractDataset
      extended by info.informatica.data.ResultsetDataset
All Implemented Interfaces:
Dataset

public final class ResultsetDataset
extends AbstractDataset

Encapsulates a Resultset within a Dataset interface.

Author:
amengual at informatica dot info

Constructor Summary
ResultsetDataset()
           
 
Method Summary
 void close()
          Closes the Dataset.
 int findColumn(FieldName name)
          Finds the index of the given column name of the dataset.
 String getCatalogName(int i)
          Gets the designated data item's catalog name.
 int getColumnCount()
           
 FieldName getColumnName(int i)
          Gets the designated data item's column name.
 List<String> getColumnNames()
           
 Date getDate(FieldName id)
          Returns Date of name id.
 Date getDate(int i)
          Returns Date of index i.
 double getDouble(FieldName id)
          Returns double of name id
 double getDouble(int i)
          Returns int of index i
 int getInt(FieldName id)
          Returns int of name id
 int getInt(int i)
          Returns int of index i
 long getLong(FieldName id)
          Returns long of name id
 long getLong(int i)
          Returns long of index i
 Map<FieldName,Object> getMap()
          Gets a name-> values map containing the current data row.
 MetaData getMetaData()
          Gets the meta data for this data set.
 Object getObject(FieldName id)
          Returns Object of name id
 Object getObject(int i)
          Returns Object of index i
 String getString(FieldName id)
          Returns String of name id.
 String getString(int i)
          Returns String of index i.
 Map<String,Object> getStringMap()
          Gets a name-> values map containing the current data row.
 boolean isAfterLast()
          Retrieves wether the dataset is after its last row.
 boolean isEmpty()
          Tests if the ResultsetDataset is empty.
 boolean isLast()
          Retrieves wether the dataset is on its last row.
 boolean next()
          Positions the Dataset at the next row of data.
 void reset()
          Puts the Dataset cursor in the initial state, regardless of the current cursor state.
 void set(ResultSet rs)
           
 
Methods inherited from class info.informatica.data.AbstractDataset
evaluate, getEnviron, getLabel, getNestedSet, setEnviron, setLabel
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResultsetDataset

public ResultsetDataset()
Method Detail

set

public void set(ResultSet rs)

getColumnCount

public int getColumnCount()
                   throws DatasetException
Specified by:
getColumnCount in interface Dataset
Overrides:
getColumnCount in class AbstractDataset
Returns:
the number of columns of this Dataset.
Throws:
DatasetException - if the data repository produced an error.

getDate

public Date getDate(int i)
             throws DatasetException
Description copied from interface: Dataset
Returns Date of index i.

Returns:
the Date value of index i.
Throws:
DatasetException - if the data repository produced an error.

getDate

public Date getDate(FieldName id)
             throws DatasetException
Description copied from interface: Dataset
Returns Date of name id.

Returns:
the Date value of name id.
Throws:
DatasetException - if the data repository produced an error.

getDouble

public double getDouble(int i)
                 throws DatasetException
Description copied from interface: Dataset
Returns int of index i

Throws:
DatasetException - if the data repository produced an error.

getDouble

public double getDouble(FieldName id)
                 throws DatasetException
Description copied from interface: Dataset
Returns double of name id

Throws:
DatasetException - if the data repository produced an error.

getInt

public int getInt(int i)
           throws DatasetException
Description copied from interface: Dataset
Returns int of index i

Throws:
DatasetException - if the data repository produced an error.

getInt

public int getInt(FieldName id)
           throws DatasetException
Description copied from interface: Dataset
Returns int of name id

Throws:
DatasetException - if the data repository produced an error.

getLong

public long getLong(int i)
             throws DatasetException
Description copied from interface: Dataset
Returns long of index i

Throws:
DatasetException - if the data repository produced an error.

getLong

public long getLong(FieldName id)
             throws DatasetException
Description copied from interface: Dataset
Returns long of name id

Throws:
DatasetException - if the data repository produced an error.

getObject

public Object getObject(int i)
                 throws DatasetException
Description copied from interface: Dataset
Returns Object of index i

Throws:
DatasetException - if the data repository produced an error.

getObject

public Object getObject(FieldName id)
                 throws DatasetException
Description copied from interface: Dataset
Returns Object of name id

Throws:
DatasetException - if the data repository produced an error.

getString

public String getString(int i)
                 throws DatasetException
Description copied from interface: Dataset
Returns String of index i.

Throws:
DatasetException - if the data repository produced an error.

getString

public String getString(FieldName id)
                 throws DatasetException
Description copied from interface: Dataset
Returns String of name id.

Throws:
DatasetException - if the data repository produced an error.

next

public boolean next()
             throws DatasetException
Description copied from interface: Dataset
Positions the Dataset at the next row of data.

Specified by:
next in interface Dataset
Overrides:
next in class AbstractDataset
Returns:
false if there were no more rows, true otherwise.
Throws:
DatasetException - if the data repository produced an error.

getMetaData

public MetaData getMetaData()
                     throws DataException
Description copied from interface: Dataset
Gets the meta data for this data set.

Specified by:
getMetaData in interface Dataset
Overrides:
getMetaData in class AbstractDataset
Returns:
the meta data for this data set, or null if not available.
Throws:
DataException - if the data repository produced an error.

getCatalogName

public String getCatalogName(int i)
                      throws DatasetException
Gets the designated data item's catalog name.

Specified by:
getCatalogName in interface Dataset
Overrides:
getCatalogName in class AbstractDataset
Returns:
the catalog name.
Throws:
DatasetException - if the data repository produced an error.

getColumnName

public FieldName getColumnName(int i)
                        throws DatasetException
Gets the designated data item's column name.

Specified by:
getColumnName in interface Dataset
Overrides:
getColumnName in class AbstractDataset
Returns:
the column name.
Throws:
DatasetException

getColumnNames

public List<String> getColumnNames()
                            throws DatasetException
Throws:
DatasetException

isEmpty

public boolean isEmpty()
                throws DatasetException
Tests if the ResultsetDataset is empty.

If the recordset is null, it is considered empty. If the recordset can be moved backwards, will try to determine if there are data available. If it is of type FORWARD_ONLY will return true if the recordset is not null.

Returns:
true if contains a recordset, false otherwise
Throws:
DatasetException

isLast

public boolean isLast()
               throws DatasetException
Description copied from interface: Dataset
Retrieves wether the dataset is on its last row.

Evaluation of this method could be expensive.

Returns:
true if the dataset is on its last row, false otherwise.
Throws:
DatasetException - if the data repository produced an error.

isAfterLast

public boolean isAfterLast()
                    throws DatasetException
Description copied from interface: Dataset
Retrieves wether the dataset is after its last row.

Returns:
true if the dataset is after its last row, false otherwise.
Throws:
DatasetException - if the data repository produced an error.

reset

public void reset()
           throws DatasetException
Description copied from interface: Dataset
Puts the Dataset cursor in the initial state, regardless of the current cursor state.

This method allows the reuse of a Dataset object after all rows have been extracted by the use of the next() function.

This method is optional. Implementations are required to throw an UnsupportedOperationException in case they do not implement it.

Throws:
DatasetException - if an error happened when resetting the data.

close

public void close()
           throws DatasetException
Description copied from interface: Dataset
Closes the Dataset.

No further work is possible with the Dataset after closing it.

Specified by:
close in interface Dataset
Overrides:
close in class AbstractDataset
Throws:
DatasetException - if an error happens when closing the Dataset.

findColumn

public int findColumn(FieldName name)
               throws DatasetException
Finds the index of the given column name of the dataset.

Beware that this class will handle any SQL error as an indication that the requested column does not exist.

Specified by:
findColumn in interface Dataset
Overrides:
findColumn in class AbstractDataset
Returns:
the index of the given column name of the dataset, or -1 if the column name is not known.
Throws:
DatasetException - if an error happens when accessing the data.

getMap

public Map<FieldName,Object> getMap()
                             throws DatasetException
Gets a name-> values map containing the current data row.

Returns:
a Map with the current data row. Cannot return null.
Throws:
DatasetException - if an error happens when creating the Map.

getStringMap

public Map<String,Object> getStringMap()
                                throws DatasetException
Gets a name-> values map containing the current data row.

Throws:
DatasetException