Class ResultSetTableModelFactory
- java.lang.Object
-
- org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.ResultSetTableModelFactory
-
public final class ResultSetTableModelFactory extends Object
Creates aTableModel
which is backed up by aResultSet
. If theResultSet
is scrollable, aScrollableResultSetTableModel
is created, otherwise all data is copied from theResultSet
into aDefaultTableModel
. The creation of aDefaultTableModel
can be forced if the system property"org.pentaho.reporting.engine.classic.core.modules.misc.tablemodel.TableFactoryMode"
is set to"simple"
.- Author:
- Thomas Morgner
-
-
Field Summary
Fields Modifier and Type Field Description static String
COLUMN_NAME_MAPPING_KEY
The configuration key defining how to map column names to column indices.static String
RESULTSET_FACTORY_MODE
The 'ResultSet factory mode'.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static org.pentaho.reporting.libraries.xmlns.common.AttributeMap<Object>
collectData(ResultSetMetaData rsmd, int column, String name)
CloseableTableModel
createTableModel(ResultSet rs, boolean columnNameMapping, boolean closeStatement)
Creates a table model by using the givenResultSet
as the backend.CloseableTableModel
generateDefaultTableModel(ResultSet rs, boolean columnNameMapping)
Generates aTableModel
that gets its contents filled from aResultSet
.static ResultSetTableModelFactory
getInstance()
Returns the singleton instance of the factory.static ImmutableDataAttributes[]
map(org.pentaho.reporting.libraries.xmlns.common.AttributeMap[] data)
protected Object[][]
produceData(ResultSet rs, int colcount)
static void
updateMetaData(ResultSetMetaData rsmd, DefaultTableMetaData metaData, int column)
Deprecated.
-
-
-
Field Detail
-
COLUMN_NAME_MAPPING_KEY
public static final String COLUMN_NAME_MAPPING_KEY
The configuration key defining how to map column names to column indices.- See Also:
- Constant Field Values
-
RESULTSET_FACTORY_MODE
public static final String RESULTSET_FACTORY_MODE
The 'ResultSet factory mode'.- See Also:
- Constant Field Values
-
-
Method Detail
-
createTableModel
public CloseableTableModel createTableModel(ResultSet rs, boolean columnNameMapping, boolean closeStatement) throws SQLException
Creates a table model by using the givenResultSet
as the backend. If theResultSet
is scrollable (the type is notTYPE_FORWARD_ONLY
), an instance ofScrollableResultSetTableModel
is returned. This model uses the extended capabilities of scrollable result sets to directly read data from the database without caching or the need of copying the completeResultSet
into the programs memory. If theResultSet
lacks the scrollable features, the data will be copied into aDefaultTableModel
and theResultSet
gets closed.- Parameters:
rs
- the result set.columnNameMapping
- defines, whether to use column names or column labels to compute the column index. If true, then we map the Name. If false, then we map the LabelcloseStatement
- a flag indicating whether closing the resultset should also close the statement.- Returns:
- a closeable table model.
- Throws:
SQLException
- if there is a problem with the result set.
-
generateDefaultTableModel
public CloseableTableModel generateDefaultTableModel(ResultSet rs, boolean columnNameMapping) throws SQLException
Generates aTableModel
that gets its contents filled from aResultSet
. The column names of theResultSet
will form the column names of the table model. Hint: To customize the names of the columns, use the SQL column aliasing (done withSELECT nativecolumnname AS "JavaColumnName" FROM ....
- Parameters:
rs
- the result set.columnNameMapping
- defines, whether to use column names or column labels to compute the column index. If true, then we map the Name. If false, then we map the Label- Returns:
- a closeable table model.
- Throws:
SQLException
- if there is a problem with the result set.
-
map
public static ImmutableDataAttributes[] map(org.pentaho.reporting.libraries.xmlns.common.AttributeMap[] data)
-
produceData
protected Object[][] produceData(ResultSet rs, int colcount) throws SQLException
- Throws:
SQLException
-
collectData
public static org.pentaho.reporting.libraries.xmlns.common.AttributeMap<Object> collectData(ResultSetMetaData rsmd, int column, String name) throws SQLException
- Throws:
SQLException
-
updateMetaData
@Deprecated public static void updateMetaData(ResultSetMetaData rsmd, DefaultTableMetaData metaData, int column)
Deprecated.No longer used.- Parameters:
rsmd
-metaData
-column
-
-
getInstance
public static ResultSetTableModelFactory getInstance()
Returns the singleton instance of the factory.- Returns:
- an instance of this factory.
-
-