com.irisel.oms.guiom.tablemodel
Class ResultSetTableModelFactory

java.lang.Object
  extended by com.irisel.oms.guiom.tablemodel.ResultSetTableModelFactory

public final class ResultSetTableModelFactory
extends java.lang.Object


Field Summary
static java.lang.String RESULTSET_FACTORY_MODE
          The 'ResultSet factory mode'.
 
Method Summary
 CloseableTableModel createTableModel(java.sql.ResultSet rs)
          Creates a table model by using the given ResultSet as the backend.
 CloseableTableModel generateDefaultTableModel(java.sql.ResultSet rs)
          Generates a TableModel that gets its contents filled from a ResultSet.
static ResultSetTableModelFactory getInstance()
          Returns the singleton instance of the factory.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESULTSET_FACTORY_MODE

public static final java.lang.String RESULTSET_FACTORY_MODE
The 'ResultSet factory mode'.

See Also:
Constant Field Values
Method Detail

createTableModel

public CloseableTableModel createTableModel(java.sql.ResultSet rs)
                                     throws java.sql.SQLException
Creates a table model by using the given ResultSet as the backend. If the ResultSet is scrollable (the type is not TYPE_FORWARD_ONLY), an instance of org.jfree.report.modules.misc.tablemodel.ScrollableResultSetTableModel is returned. This model uses the extended capabilities of scrollable resultsets to directly read data from the database without caching or the need of copying the complete ResultSet into the programs memory.

If the ResultSet lacks the scollable features, the data will be copied into a DefaultTableModel and the ResultSet gets closed.

Parameters:
rs - the result set.
Returns:
a closeable table model.
Throws:
java.sql.SQLException - if there is a problem with the result set.

generateDefaultTableModel

public CloseableTableModel generateDefaultTableModel(java.sql.ResultSet rs)
                                              throws java.sql.SQLException
Generates a TableModel that gets its contents filled from a ResultSet. The column names of the ResultSet will form the column names of the table model.

Hint: To customize the names of the columns, use the SQL column aliasing (done with SELECT nativecolumnname AS "JavaColumnName" FROM ....

Parameters:
rs - the result set.
Returns:
a closeable table model.
Throws:
java.sql.SQLException - if there is a problem with the result set.

getInstance

public static ResultSetTableModelFactory getInstance()
Returns the singleton instance of the factory.

Returns:
an instance of this factory.