org.geotools.data.jdbc
Interface SQLBuilder

All Known Implementing Classes:
DB2SQLBuilder, DefaultSQLBuilder, GeoAPISQLBuilder, MySQLSQLBuilder, PostgisSQLBuilder

public interface SQLBuilder

Provides an interface for SQL statement construction.

Currently just doing query building, but obviously this can be extended.

Author:
Sean Geoghegan, Defence Science and Technology Organisation.
Module:
modules/library/jdbc   (gt2-jdbc.jar) (Maven report) (SVN head)

Method Summary
 String buildSQLQuery(String typeName, FIDMapper mapper, AttributeType[] attrTypes, Filter filter)
          Makes an SQL Select statement.
 Filter getPostQueryFilter(Filter filter)
          Returns the Filter required for post processing.
 Filter getPreQueryFilter(Filter filter)
           
 void sqlColumns(StringBuffer sql, FIDMapper mapper, AttributeType[] attributes)
          Produces the select information required.
 void sqlFrom(StringBuffer sql, String typeName)
          Consutrcts FROM clause for featureType sql: FROM typeName
 void sqlOrderBy(StringBuffer sql, SortBy[] sortBy)
          Constructs ORDER BY clause.
 void sqlWhere(StringBuffer sql, Filter preFilter)
          Constructs WHERE clause, if needed, for FILTER.
 

Method Detail

buildSQLQuery

String buildSQLQuery(String typeName,
                     FIDMapper mapper,
                     AttributeType[] attrTypes,
                     Filter filter)
                     throws SQLEncoderException
Makes an SQL Select statement. Constructs an SQL statement that will select the features from the table based on the filter. The default implementation creates a select statement for the table with the name typeName, selecting all the columns with the names in the attrTypes array using the filter as a WHERE clause. The default implementation ignores the maxFeature parameter since this requires DB dependant SQL. Subclasses can override this to provide the maxFeatures functionality specific to their DB.

Parameters:
typeName - a String with the typeName used as the table to query
mapper - an FIDMapper
attrTypes - the array of AttributeType elements for the select statement
filter - the filter to convert to a where statement
Returns:
a String representing an SQL statement
Throws:
SQLEncoderException - If an error occurs encoding the SQL FIXME: This should change to a FilterToSQLException after SQLEncoder is dropped

getPostQueryFilter

Filter getPostQueryFilter(Filter filter)
Returns the Filter required for post processing.

The result will be null if no post processing is required.

This method is used by DefaultJDBCFeatureSource to see if the a Query can be optimized

Parameters:
filter -
Returns:
Filter required for post processing, or null

getPreQueryFilter

Filter getPreQueryFilter(Filter filter)

sqlColumns

void sqlColumns(StringBuffer sql,
                FIDMapper mapper,
                AttributeType[] attributes)
Produces the select information required.

The featureType, if known, is always requested.

sql: featureID (,attributeColumn)*

We may need to provide AttributeReaders with a hook so they can request a wrapper function.

Parameters:
sql -
mapper -
attributes -

sqlFrom

void sqlFrom(StringBuffer sql,
             String typeName)
Consutrcts FROM clause for featureType

sql: FROM typeName

Parameters:
sql -
typeName -

sqlWhere

void sqlWhere(StringBuffer sql,
              Filter preFilter)
              throws SQLEncoderException
Constructs WHERE clause, if needed, for FILTER.

sql: WHERE filter encoding

FIXME: This should change to a FilterToSQLException after SQLEncoder is dropped

Throws:
SQLEncoderException

sqlOrderBy

void sqlOrderBy(StringBuffer sql,
                SortBy[] sortBy)
                throws SQLEncoderException
Constructs ORDER BY clause.

sql: ORDER BY <property1> [ASC|DESC], ....

FIXME: This should change to a FilterToSQLException after SQLEncoder is dropped

Throws:
SQLEncoderException


Copyright © 1996-2008 Geotools. All Rights Reserved.