Class TableAnalyzer

java.lang.Object
org.apache.sis.internal.sql.feature.FeatureAnalyzer
org.apache.sis.internal.sql.feature.TableAnalyzer

final class TableAnalyzer extends FeatureAnalyzer
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 Details

    • dependencyOf

      private final TableReference dependencyOf
      If the analyzed table is imported/exported by foreigner keys, the table that "contains" this table. Otherwise null.
    • tableEsc

      private final String tableEsc
      The table/schema name width '_' and '%' characters escaped. These names are intended for use in arguments expecting a LIKE pattern.
    • schemaEsc

      private final String schemaEsc
      The table/schema name width '_' and '%' characters escaped. These names are intended for use in arguments expecting a LIKE 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 by id, 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. Otherwise null.
      Throws:
      SQLException - if an error occurred while fetching information from the database.
  • Method Details

    • escape

      private String escape(String pattern)
      Returns the given pattern with '_' and '%' characters escaped by the database-specific escape characters. This method should be invoked for escaping the values of all
      invalid reference
      DatabaseMetaData
      method arguments with a name ending by "Pattern". Note that not all arguments are pattern; please checks carefully
      invalid reference
      DatabaseMetaData
      javadoc for each method.
      Example: if a method expects an argument named tableNamePattern, then that argument value should be escaped. But if the argument name is only tableName, 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 class FeatureAnalyzer
      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

      final Column[] createAttributes() throws Exception
      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 class FeatureAnalyzer
      Parameters:
      feature - the builder where to add attributes and associations.
      Returns:
      the columns for attribute values (not including associations).
      Throws:
      Exception - for WKB parsing error or other kinds of errors.
    • getRemarks

      public String getRemarks() throws SQLException
      Returns an optional description of the application schema.
      Overrides:
      getRemarks in class FeatureAnalyzer
      Throws:
      SQLException