org.geotools.data.db2
Class DB2SQLBuilder

Object
  extended by GeoAPISQLBuilder
      extended by DB2SQLBuilder
All Implemented Interfaces:
SQLBuilder

public class DB2SQLBuilder
extends GeoAPISQLBuilder

A DB2-specific subclass of DefaultSQLBuilder, which supports DB2 Spatial Extender geometry datatypes.

Author:
David Adler - IBM Corporation
Module:
modules/plugin/db2 (gt-db2.jar)

Field Summary
 
Fields inherited from class GeoAPISQLBuilder
accessor, encoder, ft
 
Constructor Summary
DB2SQLBuilder(FilterToSQL encoder, String tableSchema, SimpleFeatureType featureType, FIDMapper mapper)
          Creates a DB2SQLBuilder that will provide a table schema to qualify table names.
 
Method Summary
 String buildSQLBoundsQuery(String typeName, AttributeDescriptor geomAttr, Filter filter)
          Builds the SQL query to get the bounds (min-max coordinate values) of a geometry column for a given filter.
protected  boolean isTypeNumeric(int columnType)
          Checks if column type is SQL numeric type
 String makeDeleteSql(SimpleFeature feature)
          Generates the SQL delete statement
protected  String makeFIDWhere(SimpleFeature feature)
          Build a DB2 WHERE clause based on the FID column values
protected  String makeInsertSql(List<AttributeDescriptor> attributes, SimpleFeature feature)
          Creates a sql insert statement.
protected  String makeUpdateSql(List<AttributeDescriptor> attributes, SimpleFeature live, SimpleFeature current)
          Generates the SQL UPDATE statement
 void sqlFrom(StringBuffer sql, String typeName)
          Construct the FROM clause for a feature type.
 void sqlGeometryColumn(StringBuffer sql, AttributeDescriptor geomAttribute)
          Generates the select column specification for a DB2 geometry column.
 
Methods inherited from class GeoAPISQLBuilder
buildSQLQuery, buildSQLQuery, encode, encode, getFidValidator, getPostQueryFilter, getPreQueryFilter, isForce2D, setHints, splitFilter, sqlColumns, sqlOrderBy, sqlOrderBy, sqlWhere
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DB2SQLBuilder

public DB2SQLBuilder(FilterToSQL encoder,
                     String tableSchema,
                     SimpleFeatureType featureType,
                     FIDMapper mapper)
Creates a DB2SQLBuilder that will provide a table schema to qualify table names. The table schema is provided by the DB2DataStore which means that a given DataStore can only access tables within a single schema.

It would be better if the table schema was managed by FeatureTypeHandler or FeatureType.

Parameters:
encoder - an SQLEncoder
tableSchema - table schema to qualify table names
featureType - the feature type to be used by this SQL builder
Method Detail

sqlGeometryColumn

public void sqlGeometryColumn(StringBuffer sql,
                              AttributeDescriptor geomAttribute)
Generates the select column specification for a DB2 geometry column.

Overrides sqlGeometryColumn in DefaultSQLBuilder

Overrides:
sqlGeometryColumn in class GeoAPISQLBuilder
Parameters:
sql - A StringBuffer that the column specification can be appended to.
geomAttribute - An AttributeType for a geometry attribute

sqlFrom

public void sqlFrom(StringBuffer sql,
                    String typeName)
Construct the FROM clause for a feature type. Prefixes the typeName with the table schema provided when this class was constructed.

This method could be promoted to DefaultSQLBuilder if the table schema was propagated up.

Overrides sqlFrom in DefaultSQLBuilder

Specified by:
sqlFrom in interface SQLBuilder
Overrides:
sqlFrom in class GeoAPISQLBuilder
Parameters:
sql - StringBuffer to be appended to
typeName - Name of the type (table)

buildSQLBoundsQuery

public String buildSQLBoundsQuery(String typeName,
                                  AttributeDescriptor geomAttr,
                                  Filter filter)
                           throws SQLEncoderException
Builds the SQL query to get the bounds (min-max coordinate values) of a geometry column for a given filter.

Parameters:
typeName - the feature type name.
geomAttr - the geometry attribute.
filter - the filter expression.
Returns:
the string to perform the SQL query.
Throws:
SQLEncoderException

makeInsertSql

protected String makeInsertSql(List<AttributeDescriptor> attributes,
                               SimpleFeature feature)
                        throws IOException
Creates a sql insert statement. Uses each feature's schema, which makes it possible to insert out of order, as well as inserting less than all features.

Parameters:
attributes - the attribute columns to be inserted
feature - the feature to add.
Returns:
an insert sql statement.
Throws:
IOException

makeUpdateSql

protected String makeUpdateSql(List<AttributeDescriptor> attributes,
                               SimpleFeature live,
                               SimpleFeature current)
                        throws IOException
Generates the SQL UPDATE statement

Parameters:
attributes - the attribute columns to be inserted
feature -
Returns:
DB2 UPDATE statement
Throws:
IOException
UnsupportedOperationException

makeDeleteSql

public String makeDeleteSql(SimpleFeature feature)
                     throws IOException
Generates the SQL delete statement

Parameters:
feature -
Returns:
DB2 DELETE statement
Throws:
IOException
IOException
UnsupportedOperationException

makeFIDWhere

protected String makeFIDWhere(SimpleFeature feature)
                       throws IOException
Build a DB2 WHERE clause based on the FID column values

Parameters:
feature -
Returns:
A DB2 WHERE clause based on the FID column values.
Throws:
IOException

isTypeNumeric

protected boolean isTypeNumeric(int columnType)
Checks if column type is SQL numeric type

Parameters:
SQL - columnType
Returns:
true if the column is an SQL numeric type


Copyright © 1996-2009 Geotools. All Rights Reserved.