weka.gui.sql
Class ResultSetHelper

java.lang.Object
  extended by weka.gui.sql.ResultSetHelper

public class ResultSetHelper
extends java.lang.Object

Represents an extended JTable, containing a table model based on a ResultSet and the corresponding query.

Version:
$Revision: 1.2 $
Author:
FracPete (fracpete at waikato dot ac dot nz)

Constructor Summary
ResultSetHelper(java.sql.ResultSet rs)
          initializes the helper, with unlimited number of rows
ResultSetHelper(java.sql.ResultSet rs, int max)
          initializes the helper, with the given maximum number of rows (less than 1 means unlimited)
 
Method Summary
 java.lang.Object[][] getCells()
          returns an 2-dimensional array with the content of the resultset, the first dimension is the row, the second the column (i.e., getCells()[y][x]).
 java.lang.Class[] getColumnClasses()
          returns the classes for the columns
 int getColumnCount()
          returns the number of columns in the resultset
 java.lang.String[] getColumnNames()
          returns an array with the names of the columns in the resultset
 int getMaxRows()
          the maximum number of rows to retrieve, less than 1 means unlimited
 boolean[] getNumericColumns()
          returns an array that indicates whether a column is numeric or nor
 java.sql.ResultSet getResultSet()
          the underlying resultset
 int getRowCount()
          returns the number of rows in the resultset
 boolean hasMaxRows()
          whether a limit on the rows to retrieve was set
static boolean typeIsNumeric(int type)
          returns whether the SQL type is numeric (and therefore the justification should be right)
static java.lang.Class typeToClass(int type)
          Returns the class associated with a SQL type.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResultSetHelper

public ResultSetHelper(java.sql.ResultSet rs)
initializes the helper, with unlimited number of rows

Parameters:
rs - the resultset to work on

ResultSetHelper

public ResultSetHelper(java.sql.ResultSet rs,
                       int max)
initializes the helper, with the given maximum number of rows (less than 1 means unlimited)

Parameters:
rs - the resultset to work on
max - the maximum number of rows to retrieve
Method Detail

getResultSet

public java.sql.ResultSet getResultSet()
the underlying resultset


getColumnCount

public int getColumnCount()
returns the number of columns in the resultset


getRowCount

public int getRowCount()
returns the number of rows in the resultset


getColumnNames

public java.lang.String[] getColumnNames()
returns an array with the names of the columns in the resultset


getNumericColumns

public boolean[] getNumericColumns()
returns an array that indicates whether a column is numeric or nor


getColumnClasses

public java.lang.Class[] getColumnClasses()
returns the classes for the columns


hasMaxRows

public boolean hasMaxRows()
whether a limit on the rows to retrieve was set


getMaxRows

public int getMaxRows()
the maximum number of rows to retrieve, less than 1 means unlimited


getCells

public java.lang.Object[][] getCells()
returns an 2-dimensional array with the content of the resultset, the first dimension is the row, the second the column (i.e., getCells()[y][x]). Note: the data is not cached! It is always retrieved anew.


typeToClass

public static java.lang.Class typeToClass(int type)
Returns the class associated with a SQL type.

Parameters:
type - the SQL type
Returns:
the Java class corresponding with the type

typeIsNumeric

public static boolean typeIsNumeric(int type)
returns whether the SQL type is numeric (and therefore the justification should be right)

Parameters:
type - the SQL type
Returns:
whether the given type is numeric