Class TableAnalyzer
java.lang.Object
org.apache.sis.internal.sql.feature.FeatureAnalyzer
org.apache.sis.internal.sql.feature.TableAnalyzer
Constructor for a
Table
based on a "physical" table.
The table is identified by FeatureAnalyzer.id
, which contains a (catalog, schema, name) tuple.- Since:
- 1.1
- Version:
- 1.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final TableReference
If the analyzed table is imported/exported by foreigner keys, the table that "contains" this table.private final String
The table/schema name width'_'
and'%'
characters escaped.private final String
The table/schema name width'_'
and'%'
characters escaped.Fields inherited from class org.apache.sis.internal.sql.feature.FeatureAnalyzer
analyzer, feature, hasGeometry, hasRaster, id, primaryKey
-
Constructor Summary
ConstructorsConstructorDescriptionTableAnalyzer
(Analyzer analyzer, TableReference id, TableReference dependencyOf) Creates an analyzer for the table of the given name. -
Method Summary
Modifier and TypeMethodDescription(package private) final Column[]
Configures the feature builder with attributes and associations inferred from the analyzed table.private String
Returns the given pattern with'_'
and'%'
characters escaped by the database-specific escape characters.(package private) final Relation[]
getForeignerKeys
(Relation.Direction direction) Returns a list of associations between the table read by this method and other tables.Returns an optional description of the application schema.Methods inherited from class org.apache.sis.internal.sql.feature.FeatureAnalyzer
addForeignerKeys, buildFeatureType, createAssociations, createAttribute, duplicatedColumn
-
Field Details
-
dependencyOf
If the analyzed table is imported/exported by foreigner keys, the table that "contains" this table. Otherwisenull
. -
tableEsc
The table/schema name width'_'
and'%'
characters escaped. These names are intended for use in arguments expecting aLIKE
pattern. -
schemaEsc
The table/schema name width'_'
and'%'
characters escaped. These names are intended for use in arguments expecting aLIKE
pattern.
-
-
Constructor Details
-
TableAnalyzer
TableAnalyzer(Analyzer analyzer, TableReference id, TableReference dependencyOf) throws SQLException Creates an analyzer for the table of the given name. The table is identified byid
, which contains a (catalog, schema, name) tuple. The catalog and schema parts are optional and can be null, but the table is mandatory.- Parameters:
id
- the catalog, schema and table name of the table to analyze.dependencyOf
- if the analyzed table is imported/exported by foreigner keys, the table that "contains" this table. Otherwisenull
.- Throws:
SQLException
- if an error occurred while fetching information from the database.
-
-
Method Details
-
escape
Returns the given pattern with'_'
and'%'
characters escaped by the database-specific escape characters. This method should be invoked for escaping the values of allDatabaseMetaData
method arguments with a name ending by"Pattern"
. Note that not all arguments are pattern; please checks carefullyDatabaseMetaData
javadoc for each method.Example: if a method expects an argument namedtableNamePattern
, then that argument value should be escaped. But if the argument name is onlytableName
, then the value should not be escaped. -
getForeignerKeys
final Relation[] getForeignerKeys(Relation.Direction direction) throws SQLException, DataStoreException Returns a list of associations between the table read by this method and other tables. The associations are defined by the foreigner keys referencing primary keys.Side effects
This method shall be invoked exactly once for each direction.Required by this method: none.
Computed by this method:
FeatureAnalyzer.foreignerKeys
.- Specified by:
getForeignerKeys
in classFeatureAnalyzer
- Parameters:
direction
- direction of the foreigner key for which to return components.- Returns:
- components of the foreigner key in the requested direction.
- Throws:
SQLException
- if an error occurred while fetching information from the database.DataStoreException
- if a logical error occurred while analyzing the relations.
-
createAttributes
Configures the feature builder with attributes and associations inferred from the analyzed table. The ordinary attributes and the associations (inferred from foreigner keys) are handled together in order to have properties listed in the same order as the columns in the database table.Side effects
Required by this method:
FeatureAnalyzer.foreignerKeys
.Computed by this method:
FeatureAnalyzer.primaryKey
,FeatureAnalyzer.primaryKeyClass
.- Specified by:
createAttributes
in classFeatureAnalyzer
- Parameters:
feature
- the builder where to add attributes and associations.- Returns:
- the columns for attribute values (not including associations).
- Throws:
SQLException
- if an error occurred while fetching information from the database.DataStoreException
- if a logical error occurred while analyzing the relations.Exception
- for WKB parsing error or other kinds of errors.
-
getRemarks
Returns an optional description of the application schema.- Overrides:
getRemarks
in classFeatureAnalyzer
- Throws:
SQLException
-