Class AbstractInformationExtractorImpl
- All Implemented Interfaces:
InformationExtractor
- Direct Known Subclasses:
InformationExtractorJdbcDatabaseMetaDataImpl
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceprotected static class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddColumns(TableInformation tableInformation) booleancatalogExists(Identifier catalog) Does the given catalog exist yet?protected ColumnInformationImplcolumnInformation(TableInformation tableInformation, ResultSet resultSet) protected JDBCExceptionconvertSQLException(SQLException sqlException, String message) protected ExtractionContextgetForeignKeys(TableInformation tableInformation) Extract information about foreign keys defined on the given table (targeting or point-at other tables).getIndexes(TableInformation tableInformation) Extract information about indexes defined against the given table.protected JdbcEnvironmentgetPrimaryKey(TableInformationImpl tableInformation) Extract information about the given table's primary key.protected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected abstract Stringprotected StringgetTable(Identifier catalog, Identifier schema, Identifier tableName) Look for a matching table.getTables(Identifier catalog, Identifier schema) Extract all the tables information.protected BooleaninterpretTruthValue(String nullable) protected booleanisPhysicalTableType(String tableType) protected abstract <T> TprocessCatalogsResultSet(ExtractionContext.ResultSetProcessor<T> processor) Must do the following: obtain aResultSetcontaining a column of existing catalog names.protected abstract <T> TprocessColumnsResultSet(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern, ExtractionContext.ResultSetProcessor<T> processor) Must do the following: obtain aResultSetcontaining a row for any existing catalog/schema/table/column combination as specified by thecatalog,schemaPattern,tableNamePattern, andcolumnNamePatternparameters described below.protected abstract <T> TprocessCrossReferenceResultSet(String parentCatalog, String parentSchema, String parentTable, String foreignCatalog, String foreignSchema, String foreignTable, ExtractionContext.ResultSetProcessor<T> processor) Must do the following: obtain aResultSetcontaining a row for each foreign key column making up a foreign key for any existing foreignCatalog/foreignSchema/foreignTable combination as specified by parameters described below.protected abstract <T> TprocessImportedKeysResultSet(String catalog, String schema, String table, ExtractionContext.ResultSetProcessor<T> processor) Must do the following: obtain aResultSetcontaining a row for each foreign key/ primary key column making up a foreign key for any existing catalog/schema/table combination as specified by thecatalog,schema, andtableparameters described below.protected abstract <T> TprocessIndexInfoResultSet(String catalog, String schema, String table, boolean unique, boolean approximate, ExtractionContext.ResultSetProcessor<T> processor) Must do the following: obtain aResultSetcontaining a row for each column defined in an index.protected abstract <T> TprocessPrimaryKeysResultSet(String catalogFilter, String schemaFilter, Identifier tableName, ExtractionContext.ResultSetProcessor<T> processor) protected abstract <T> TprocessSchemaResultSet(String catalog, String schemaPattern, ExtractionContext.ResultSetProcessor<T> processor) Must do the following: obtain aResultSetcontaining a row for any existing catalog/schema combination as specified by thecatalogandschemaPatternparameters described below.protected abstract <T> TprocessTableResultSet(String catalog, String schemaPattern, String tableNamePattern, String[] types, ExtractionContext.ResultSetProcessor<T> processor) Must do the following: obtain aResultSetcontaining a row for any existing catalog/schema/table/table type combination as specified by thecatalogFilter,schemaFilter,tableNameFilter, andtableTypesparameters described below.booleanschemaExists(Identifier catalog, Identifier schema) Does the given schema exist yet?protected StringtoMetaDataObjectName(Identifier identifier)
-
Constructor Details
-
AbstractInformationExtractorImpl
-
-
Method Details
-
convertSQLException
-
toMetaDataObjectName
-
getExtractionContext
-
getJdbcEnvironment
-
getResultSetCatalogLabel
-
getResultSetSchemaLabel
-
getResultSetTableNameLabel
-
getResultSetTableTypeLabel
-
getResultSetRemarksLabel
-
getResultSetPrimaryKeyCatalogLabel
-
getResultSetPrimaryKeySchemaLabel
-
getResultSetPrimaryKeyTableLabel
-
getResultSetColumnNameLabel
-
getResultSetSqlTypeCodeLabel
-
getResultSetTypeNameLabel
-
getResultSetColumnSizeLabel
-
getResultSetDecimalDigitsLabel
-
getResultSetIsNullableLabel
-
getResultSetIndexTypeLabel
-
getResultSetIndexNameLabel
-
getResultSetForeignKeyLabel
-
getResultSetPrimaryKeyNameLabel
-
getResultSetColumnPositionColumn
-
getResultSetPrimaryKeyColumnNameLabel
-
getResultSetForeignKeyColumnNameLabel
-
processCatalogsResultSet
protected abstract <T> T processCatalogsResultSet(ExtractionContext.ResultSetProcessor<T> processor) throws SQLException Must do the following:-
obtain a
ResultSetcontaining a column of existing catalog names. The column label must be the same as returned bygetResultSetCatalogLabel(). - execute
processor.process( resultSet ); -
release resources whether
processor.process( resultSet )executes successfully or not.
- Type Parameters:
T- - defined byprocessor- Parameters:
processor- - the provided ResultSetProcessor.- Returns:
- - defined by
processor - Throws:
SQLException- - if a database error occurs
-
obtain a
-
catalogExists
Description copied from interface:InformationExtractorDoes the given catalog exist yet?- Specified by:
catalogExistsin interfaceInformationExtractor- Parameters:
catalog- The name of the catalog to look for.- Returns:
trueif the catalog does exist;falseotherwise
-
processSchemaResultSet
protected abstract <T> T processSchemaResultSet(String catalog, String schemaPattern, ExtractionContext.ResultSetProcessor<T> processor) throws SQLException Must do the following:-
obtain a
ResultSetcontaining a row for any existing catalog/schema combination as specified by thecatalogandschemaPatternparameters described below. The row contents will not be examined byprocessor.process( resultSet ), so column label names are not specified; - execute
processor.process( resultSet ); -
release resources whether
processor.process( resultSet )executes successfully or not.
The
catalogandschemaPatternparameters are as specified byDatabaseMetaData.getSchemas(String, String), and are copied here:- Type Parameters:
T- - defined byprocessor- Parameters:
catalog- – a catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means catalog name should not be used to narrow down the search.schemaPattern- – a schema name; must match the schema name as it is stored in the database; null means schema name should not be used to narrow down the search.processor- - the provided ResultSetProcessor.- Returns:
- - defined by
processor - Throws:
SQLException- - if a database error occurs
-
obtain a
-
schemaExists
Description copied from interface:InformationExtractorDoes the given schema exist yet?- Specified by:
schemaExistsin interfaceInformationExtractor- Parameters:
catalog- The name of the catalog to look in.schema- The name of the schema to look for.- Returns:
trueif the schema does exist;falseotherwise
-
getTable
Description copied from interface:InformationExtractorLook for a matching table.- Specified by:
getTablein interfaceInformationExtractor- Parameters:
catalog- Can benull, indicating that any catalog may be considered a match. A non-nullvalue indicates that search should be limited to the passed catalog.schema- Can benull, indicating that any schema may be considered a match. A non-nullvalue indicates that search should be limited to the passed schema .tableName- The name of the table to look for.- Returns:
- table info for the matching table
-
getTables
Description copied from interface:InformationExtractorExtract all the tables information.- Specified by:
getTablesin interfaceInformationExtractor- Parameters:
catalog- Can benull, indicating that any catalog may be considered a match. A non-nullvalue indicates that search should be limited to the passed catalog.schema- Can benull, indicating that any schema may be considered a match. A non-nullvalue indicates that search should be limited to the passed schema .- Returns:
- a
NameSpaceTablesInformation
-
processColumnsResultSet
protected abstract <T> T processColumnsResultSet(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern, ExtractionContext.ResultSetProcessor<T> processor) throws SQLException Must do the following:-
obtain a
ResultSetcontaining a row for any existing catalog/schema/table/column combination as specified by thecatalog,schemaPattern,tableNamePattern, andcolumnNamePatternparameters described below. TheResultSetmust contain the following, consistent with the corresponding columns returned byDatabaseMetaData.getColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String)- column label
getResultSetTableNameLabel()for table name - column label
getResultSetColumnNameLabel()for column name - column label
getResultSetSqlTypeCodeLabel()SQL type code from java.sql.Types - column label
getResultSetTypeNameLabel()for database column type name - column label
getResultSetColumnSizeLabel()for column size - column label
getResultSetDecimalDigitsLabel()for number of fractional digits - column label
getResultSetIsNullableLabel()for nullability
- column label
- execute
processor.process( resultSet ); -
release resources whether
processor.process( resultSet )executes successfully or not.
The
catalog,schemaPattern,tableNamePattern, andcolumnNamePatternparameters are as specified byDatabaseMetaData.getColumns(String, String, String, String), and are copied here:- Type Parameters:
T- - defined byprocessor- Parameters:
catalog- – a catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the searchschemaPattern- – a schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the searchtableNamePattern- – a table name pattern; must match the table name as it is stored in the databasecolumnNamePattern- – a column name pattern; must match the column name as it is stored in the databaseprocessor- - the provided ResultSetProcessor.- Returns:
- - defined by
processor - Throws:
SQLException- - if a database error occurs
-
obtain a
-
columnInformation
protected ColumnInformationImpl columnInformation(TableInformation tableInformation, ResultSet resultSet) throws SQLException - Throws:
SQLException
-
processTableResultSet
protected abstract <T> T processTableResultSet(String catalog, String schemaPattern, String tableNamePattern, String[] types, ExtractionContext.ResultSetProcessor<T> processor) throws SQLException Must do the following:-
obtain a
ResultSetcontaining a row for any existing catalog/schema/table/table type combination as specified by thecatalogFilter,schemaFilter,tableNameFilter, andtableTypesparameters described below. TheResultSetmust contain the following, consistent with the corresponding columns returned byDatabaseMetaData.getTables(String, String, String, String[])- column label
getResultSetTableNameLabel()for table name - column label
getResultSetTableTypeLabel()for table type - column label
getResultSetRemarksLabel()for table comment
- column label
- execute
processor.process( resultSet ); -
release resources whether
processor.process( resultSet )executes successfully or not.
The
catalog,schemaPattern,tableNamePattern, andcolumnNamePatternparameters are as specified byDatabaseMetaData.getTables(String, String, String, String[]), and are copied here:- Type Parameters:
T- - defined byprocessor- Parameters:
catalog- - a catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the searchschemaPattern- - a schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the searchtableNamePattern- - a table name pattern; must match the table name as it is stored in the databasetypes- - a list of table typesprocessor- - the provided ResultSetProcessor.- Returns:
- - defined by
processor - Throws:
SQLException- - if a database error occurs
-
obtain a
-
getResultSetTableTypesPhysicalTableConstant
-
isPhysicalTableType
-
addColumns
-
interpretTruthValue
-
processPrimaryKeysResultSet
protected abstract <T> T processPrimaryKeysResultSet(String catalogFilter, String schemaFilter, Identifier tableName, ExtractionContext.ResultSetProcessor<T> processor) throws SQLException - Throws:
SQLException
-
getPrimaryKey
Description copied from interface:InformationExtractorExtract information about the given table's primary key.- Specified by:
getPrimaryKeyin interfaceInformationExtractor- Parameters:
tableInformation- The table for which to locate primary key information,- Returns:
- The extracted primary key information
-
processIndexInfoResultSet
protected abstract <T> T processIndexInfoResultSet(String catalog, String schema, String table, boolean unique, boolean approximate, ExtractionContext.ResultSetProcessor<T> processor) throws SQLException Must do the following:-
obtain a
ResultSetcontaining a row for each column defined in an index. TheResultSetmust contain the following, consistent with the corresponding columns returned byDatabaseMetaData.getIndexInfo(String, String, String, boolean, boolean)- column label
getResultSetIndexNameLabel()for index name; null when TYPE is tableIndexStatistic - column label
getResultSetIndexTypeLabel()index type:-
DatabaseMetaData.tableIndexStatistic- this identifies table statistics that are returned in conjunction with a table's index descriptions -
Any value other than
DatabaseMetaData.tableIndexStatistic- this indicates that a table's index description (not statisics) is being returned.
-
-
column label
getResultSetColumnNameLabel()- column name;nullwhen TYPE isDatabaseMetaData.tableIndexStatistic
- column label
- execute
processor.process( resultSet ); -
release resources whether
processor.process( resultSet )executes successfully or not.
The
catalog,schemaPattern,tableNamePattern, andcolumnNamePatternparameters are as specified byDatabaseMetaData.getIndexInfo(String, String, String, boolean, boolean), and are copied here:- Type Parameters:
T- - defined byprocessor- Parameters:
catalog- – a catalog name; must match the catalog name as it is stored in this database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the searchschema- – a schema name; must match the schema name as it is stored in this database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the searchtable- – a table name; must match the table name as it is stored in this databaseunique- – when true, return only indices for unique values; when false, return indices regardless of whether unique or notapproximate- – when true, result is allowed to reflect approximate or out of data values; when false, results are requested to be accurateprocessor- - the provided ResultSetProcessor.- Returns:
- - defined by
processor - Throws:
SQLException- - if a database error occurs
-
obtain a
-
getIndexes
Description copied from interface:InformationExtractorExtract information about indexes defined against the given table. Typically called from the TableInformation itself as part of on-demand initialization of its state.- Specified by:
getIndexesin interfaceInformationExtractor- Parameters:
tableInformation- The table for which to locate indexes- Returns:
- The extracted index information
-
processImportedKeysResultSet
protected abstract <T> T processImportedKeysResultSet(String catalog, String schema, String table, ExtractionContext.ResultSetProcessor<T> processor) throws SQLException Must do the following:-
obtain a
ResultSetcontaining a row for each foreign key/ primary key column making up a foreign key for any existing catalog/schema/table combination as specified by thecatalog,schema, andtableparameters described below. TheResultSetmust contain the following, consistent with the corresponding columns returned byDatabaseMetaData.getImportedKeys(java.lang.String, java.lang.String, java.lang.String):-
column label
getResultSetForeignKeyLabel()- foreign key name (may be null) -
column label
getResultSetPrimaryKeyCatalogLabel()- primary key table catalog being imported (may be null) -
column label
getResultSetPrimaryKeySchemaLabel()- primary key table schema being imported (may be null) -
column label
getResultSetPrimaryKeyTableLabel()- primary key table name being imported -
column label
getResultSetForeignKeyColumnNameLabel()- foreign key column name -
column label
getResultSetPrimaryKeyColumnNameLabel()- primary key column name being imported
-
column label
- execute
processor.process( resultSet ); -
release resources whether
processor.process( resultSet )executes successfully or not.
The
catalog,schema, andtableparameters are as specified byDatabaseMetaData.getImportedKeys(String, String, String)and are copied here:- Type Parameters:
T- - defined byprocessor- Parameters:
catalog- – a catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the searchschema- – a schema name; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the searchtable- – a table name; must match the table name as it is stored in the databaseprocessor- - the provided ResultSetProcessor.- Returns:
- - defined by
processor - Throws:
SQLException- - if a database error occurs
-
obtain a
-
processCrossReferenceResultSet
protected abstract <T> T processCrossReferenceResultSet(String parentCatalog, String parentSchema, String parentTable, String foreignCatalog, String foreignSchema, String foreignTable, ExtractionContext.ResultSetProcessor<T> processor) throws SQLException Must do the following:-
obtain a
ResultSetcontaining a row for each foreign key column making up a foreign key for any existing foreignCatalog/foreignSchema/foreignTable combination as specified by parameters described below. TheResultSetmust contain the following, consistent with the corresponding columns returned byDatabaseMetaData.getCrossReference(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String):-
column label
getResultSetForeignKeyLabel()- foreign key name (may be null) -
column label
getResultSetPrimaryKeyCatalogLabel()- primary key table catalog being imported (may be null) -
column label
getResultSetPrimaryKeySchemaLabel()- primary key table schema being imported (may be null) -
column label
getResultSetPrimaryKeyTableLabel()- primary key table name being imported -
column label
getResultSetForeignKeyColumnNameLabel()- foreign key column name -
column label
getResultSetPrimaryKeyColumnNameLabel()- primary key column name being imported
-
column label
- execute
processor.process( resultSet ); -
release resources whether
processor.process( resultSet )executes successfully or not.
The
parentCatalog,parentSchema,parentTable,foreignCatalog,foreignSchema,foreignTableparameters are as specified byDatabaseMetaData.getCrossReference(String, String, String, String, String, String)and are copied here:- Type Parameters:
T- - defined byprocessor- Parameters:
parentCatalog- a catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog;nullmeans drop catalog name from the selection criteriaparentSchema- a schema name; must match the schema name as it is stored in the database; "" retrieves those without a schema;nullmeans drop schema name from the selection criteriaparentTable- the name of the table that exports the key; must match the table name as it is stored in the databaseforeignCatalog- a catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog;nullmeans drop catalog name from the selection criteriaforeignSchema- a schema name; must match the schema name as it is stored in the database; "" retrieves those without a schema;nullmeans drop schema name from the selection criteriaforeignTable- the name of the table that imports the key; must match the table name as it is stored in the databaseprocessor- - the provided ResultSetProcessor.- Returns:
- - defined by
processor - Throws:
SQLException- - if a database error occurs- See Also:
-
obtain a
-
getForeignKeys
Description copied from interface:InformationExtractorExtract information about foreign keys defined on the given table (targeting or point-at other tables). Typically called from the TableInformation itself as part of on-demand initialization of its state.- Specified by:
getForeignKeysin interfaceInformationExtractor- Parameters:
tableInformation- The table for which to locate foreign-keys- Returns:
- The extracted foreign-key information
-