org.geotools.data.jdbc.fidmapper
Interface FIDMapper

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
AbstractFIDMapper

public interface FIDMapper
extends java.io.Serializable

The FIDMapper interface manages the mapping of feature id to the identifiers provided in a database.

Basically a FIDMapper must:

Concrete instances of this class should provide support for the most common primary key mapping and generation strategis, such as pk with business meaning, serials, sequences, and so on

Classes that implement this interface should ovveride equals to provide a state based comparison.

Author:
Dani Daniele Franzoni, aaime Andrea Aime

Method Summary
 java.lang.String createID(java.sql.Connection conn, Feature feature, java.sql.Statement statement)
          Creates a new ID for a feature.
 int getColumnCount()
          Returns the number of columns in the primary keys handled by this mapper
 int getColumnDecimalDigits(int colIndex)
          Provides the number of decimal digits for this column.
 java.lang.String getColumnName(int colIndex)
          Returns the name of the specified column in the primary key
 int getColumnSize(int colIndex)
          Returns the size of a primary key column as it would be provided by the database metadata.
 int getColumnType(int colIndex)
          Returns the column type by using a constant available in the java.sql.Types interface
 java.lang.String getID(java.lang.Object[] attributes)
          Returns the FID given the values of the prymary key attributes
 java.lang.Object[] getPKAttributes(java.lang.String FID)
          Creates the value for the PK attributes given the feature.
 boolean hasAutoIncrementColumns()
          Returns true if at least one column is of auto-increment type
 void initSupportStructures()
          This method will be called by JDBCDataStore when creating new tables to give the FID mapper an opportunity to initialize needed data structures, such as support tables, sequences, and so on.
 boolean isAutoIncrement(int colIndex)
          Returns true if the column is of serial type, that is, its value is automatically generated by the database if the user does not provide one
 boolean isVolatile()
          Returns true it the FID generated by this mapper are volatile, that is, if asking twice for the same Feature will not provide the same FID.
 boolean returnFIDColumnsAsAttributes()
          If true the primary key columns will be returned as attributes.
 

Method Detail

initSupportStructures

public void initSupportStructures()
This method will be called by JDBCDataStore when creating new tables to give the FID mapper an opportunity to initialize needed data structures, such as support tables, sequences, and so on.


getID

public java.lang.String getID(java.lang.Object[] attributes)
Returns the FID given the values of the prymary key attributes

Parameters:
attributes - DOCUMENT ME!
Returns:

getPKAttributes

public java.lang.Object[] getPKAttributes(java.lang.String FID)
                                   throws java.io.IOException
Creates the value for the PK attributes given the feature. If the FID is null, will throw an IOException if not possible. If null is returned, no primary key value needs to be specified, which is what we want for auto-increment fields.

Parameters:
FID - The feature ID is going to be parsed
Returns:
Throws:
java.io.IOException

createID

public java.lang.String createID(java.sql.Connection conn,
                                 Feature feature,
                                 java.sql.Statement statement)
                          throws java.io.IOException
Creates a new ID for a feature.
This is done either by querying the database (for auto-increment like types, for example sequences) or by inspecting the Feature (for example, for primary keys with business meaning that whose attributes are included in the Feature ones).

Parameters:
conn - - the database connection
feature - - the feature that needs the new FID
statement - - the statement used to insert the feature into the database
Returns:
Throws:
java.io.IOException

returnFIDColumnsAsAttributes

public boolean returnFIDColumnsAsAttributes()
If true the primary key columns will be returned as attributes. This is fundamental for primary key with businnes meaning.

Returns:

getColumnCount

public int getColumnCount()
Returns the number of columns in the primary keys handled by this mapper

Returns:

getColumnName

public java.lang.String getColumnName(int colIndex)
Returns the name of the specified column in the primary key

Parameters:
colIndex -
Returns:

getColumnType

public int getColumnType(int colIndex)
Returns the column type by using a constant available in the java.sql.Types interface

Parameters:
colIndex -
Returns:

getColumnSize

public int getColumnSize(int colIndex)
Returns the size of a primary key column as it would be provided by the database metadata. Some fields requires a size specification, such as VARCHAR or NUMBER, whilst other don't have or don't need it (for example, an INTEGER or a TEXT field).

Parameters:
colIndex -
Returns:

getColumnDecimalDigits

public int getColumnDecimalDigits(int colIndex)
Provides the number of decimal digits for this column. This is relevant in particular when the column is a scaled integer such as a NUMBER column

Parameters:
colIndex -
Returns:

isAutoIncrement

public boolean isAutoIncrement(int colIndex)
Returns true if the column is of serial type, that is, its value is automatically generated by the database if the user does not provide one

Parameters:
colIndex -
Returns:

hasAutoIncrementColumns

public boolean hasAutoIncrementColumns()
Returns true if at least one column is of auto-increment type

Returns:

isVolatile

public boolean isVolatile()
Returns true it the FID generated by this mapper are volatile, that is, if asking twice for the same Feature will not provide the same FID.

This is usually true for mappers that try to generate a FID for tables without primary keys.

When this method returns true, it's up to the datastore to decide what to do, but a sane policy may be to prevent Feature writing

Returns:


Copyright © GeoTools. All Rights Reserved.