org.geotools.data.jdbc.fidmapper
Class MultiColumnFIDMapper

java.lang.Object
  extended byorg.geotools.data.jdbc.fidmapper.AbstractFIDMapper
      extended byorg.geotools.data.jdbc.fidmapper.MultiColumnFIDMapper
All Implemented Interfaces:
FIDMapper, java.io.Serializable

public class MultiColumnFIDMapper
extends AbstractFIDMapper

A simple implementation of FIDMapper for multi column primary keys

Author:
wolf
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.geotools.data.jdbc.fidmapper.AbstractFIDMapper
returnFIDColumnsAsAttributes
 
Constructor Summary
MultiColumnFIDMapper(java.lang.String[] colNames, int[] colTypes, int[] colSizes, int[] colDecimalDigits, boolean[] autoIncrement)
          Builds a new instance of the MultiColumnFIDMapper
 
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.
 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 returnFIDColumnsAsAttributes()
          If true the primary key columns will be returned as attributes.
 
Methods inherited from class org.geotools.data.jdbc.fidmapper.AbstractFIDMapper
hasAutoIncrementColumns, isVolatile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiColumnFIDMapper

public MultiColumnFIDMapper(java.lang.String[] colNames,
                            int[] colTypes,
                            int[] colSizes,
                            int[] colDecimalDigits,
                            boolean[] autoIncrement)
Builds a new instance of the MultiColumnFIDMapper

Parameters:
colNames - - column names
colTypes - - column types, see Types
colSizes - - column sizes
colDecimalDigits - - column decimals
autoIncrement - - flags for auto-increment tests
Throws:
java.lang.IllegalArgumentException
Method Detail

initSupportStructures

public void initSupportStructures()
Description copied from interface: FIDMapper
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.

See Also:
FIDMapper.initSupportStructures()

getID

public java.lang.String getID(java.lang.Object[] attributes)
Description copied from interface: FIDMapper
Returns the FID given the values of the prymary key attributes

Parameters:
attributes - DOCUMENT ME!
Returns:
See Also:
FIDMapper.getID(java.lang.Object[])

getPKAttributes

public java.lang.Object[] getPKAttributes(java.lang.String FID)
                                   throws java.io.IOException
Description copied from interface: FIDMapper
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
See Also:
FIDMapper.getPKAttributes(java.lang.String)

createID

public java.lang.String createID(java.sql.Connection conn,
                                 Feature feature,
                                 java.sql.Statement statement)
                          throws java.io.IOException
Description copied from interface: FIDMapper
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
See Also:
FIDMapper.createID(java.sql.Connection, org.geotools.feature.Feature, Statement)

returnFIDColumnsAsAttributes

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

Specified by:
returnFIDColumnsAsAttributes in interface FIDMapper
Overrides:
returnFIDColumnsAsAttributes in class AbstractFIDMapper
See Also:
FIDMapper.returnFIDColumnsAsAttributes()

getColumnCount

public int getColumnCount()
Description copied from interface: FIDMapper
Returns the number of columns in the primary keys handled by this mapper

Returns:
See Also:
FIDMapper.getColumnCount()

getColumnName

public java.lang.String getColumnName(int colIndex)
Description copied from interface: FIDMapper
Returns the name of the specified column in the primary key

Parameters:
colIndex -
Returns:
See Also:
FIDMapper.getColumnName(int)

getColumnType

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

Parameters:
colIndex -
Returns:
See Also:
FIDMapper.getColumnType(int)

getColumnSize

public int getColumnSize(int colIndex)
Description copied from interface: FIDMapper
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:
See Also:
FIDMapper.getColumnSize(int)

getColumnDecimalDigits

public int getColumnDecimalDigits(int colIndex)
Description copied from interface: FIDMapper
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:
See Also:
FIDMapper.getColumnDecimalDigits(int)

isAutoIncrement

public boolean isAutoIncrement(int colIndex)
Description copied from interface: FIDMapper
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:
See Also:
FIDMapper.isAutoIncrement(int)


Copyright © GeoTools. All Rights Reserved.