com.fdsapi
Class ResultSetConverter

java.lang.Object
  |
  +--com.fdsapi.ResultSetConverter

public class ResultSetConverter
extends java.lang.Object

Class that converts a Java ResultSet to an Object[][] array. Some advantages of doing this are:


1) The data can be manipulated after the database connection is closed
2) The data can be cached
3) Array functions such as sort may be used on the data
4) Data Can be serialized
5) Data can be iterated over many times in any direction
6) You can get the number of rows within a ResultSetConverter (you can't do this with ResultSets)


View Code


Constructor Summary
ResultSetConverter(java.sql.ResultSet rs)
          Convert the ResultSet to a ResultSetConverter.
ResultSetConverter(java.lang.String[] metaData, java.lang.Object[][] resultSet)
          A constructor that supports converting header and body arrays to a ResultSetConverter
 
Method Summary
 java.lang.Object getCellData(int row, int col)
          Returns the data at the specified row, col location.
 java.lang.Object getCellData(int row, java.lang.String colName)
          Returns the data at the specified row, col location with the col location corresponding to the position of the passed in column name.
 int getColumnCount()
          Returns the number of columns in the ResultSet
 java.lang.String[] getMetaData()
          Returns at 1 dimensional array of column names from the ResultSet.
 java.lang.Object[][] getResultSet()
          Returns a 2 dimensional array containing the data in the ResultSet
 int getRowCount()
          Returns the number of rows in the ResultSet
 boolean isEmpty()
          Returns true if the ResultSet has no rows
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResultSetConverter

public ResultSetConverter(java.sql.ResultSet rs)
                   throws java.sql.SQLException
Convert the ResultSet to a ResultSetConverter. Note the ResultSet will be iterated through in this constructor and so if the ResultSet only supports one iteration an exception will be thrown if the calling code attempts iteration a second time.


ResultSetConverter

public ResultSetConverter(java.lang.String[] metaData,
                          java.lang.Object[][] resultSet)
A constructor that supports converting header and body arrays to a ResultSetConverter

Method Detail

getMetaData

public java.lang.String[] getMetaData()
Returns at 1 dimensional array of column names from the ResultSet.


getResultSet

public java.lang.Object[][] getResultSet()
Returns a 2 dimensional array containing the data in the ResultSet


isEmpty

public boolean isEmpty()
Returns true if the ResultSet has no rows


getRowCount

public int getRowCount()
Returns the number of rows in the ResultSet


getColumnCount

public int getColumnCount()
Returns the number of columns in the ResultSet


getCellData

public java.lang.Object getCellData(int row,
                                    int col)
Returns the data at the specified row, col location. Being as the data is an array the row and column indices start at 0 and not 1.


getCellData

public java.lang.Object getCellData(int row,
                                    java.lang.String colName)
Returns the data at the specified row, col location with the col location corresponding to the position of the passed in column name. Being as the data is an array the row index starts at 0 and not 1.