org.geotools.jdbc
Class BasicSQLDialect

Object
  extended by SQLDialect
      extended by BasicSQLDialect
Direct Known Subclasses:
DB2SQLDialectBasic, H2DialectBasic, MySQLDialectBasic, PostGISDialect, SpatiaLiteDialect, SQLServerDialect

public abstract class BasicSQLDialect
extends SQLDialect


Field Summary
 
Fields inherited from class SQLDialect
BASE_DBMS_CAPABILITIES, dataStore, LOGGER
 
Constructor Summary
protected BasicSQLDialect(JDBCDataStore dataStore)
           
 
Method Summary
 FilterToSQL createFilterToSQL()
          Creates the filter encoder to be used by the datastore when encoding query predicates.
abstract  void encodeGeometryValue(Geometry value, int srid, StringBuffer sql)
          Encodes a geometry value in an sql statement.
 void encodeValue(Object value, Class type, StringBuffer sql)
          Encodes a value in an sql statement.
 void onDelete(Statement delete, Connection cx, SimpleFeatureType featureType)
          Callback invoked before a DELETE statement is executed against the database.
 void onInsert(Statement insert, Connection cx, SimpleFeatureType featureType)
          Callback invoked before an INSERT statement is executed against the database.
 void onSelect(Statement select, Connection cx, SimpleFeatureType featureType)
          Callback invoked before a SELECT statement is executed against the database.
 void onUpdate(Statement update, Connection cx, SimpleFeatureType featureType)
          Callback invoked before an UPDATE statement is executed against the database.
 
Methods inherited from class SQLDialect
addSupportedHints, applyLimitOffset, createCRS, decodeGeometryEnvelope, decodeGeometryValue, decodeGeometryValue, encodeColumnAlias, encodeColumnName, encodeColumnName, encodeColumnType, encodeGeometryColumn, encodeGeometryColumn, encodeGeometryColumn, encodeGeometryColumnGeneralized, encodeGeometryColumnGeneralized, encodeGeometryColumnSimplified, encodeGeometryColumnSimplified, encodeGeometryEnvelope, encodeJoin, encodePostColumnCreateTable, encodePostCreateTable, encodePostSelect, encodePrimaryKey, encodeSchemaName, encodeTableAlias, encodeTableName, getDefaultVarcharSize, getGeometrySRID, getGeometryTypeName, getLastAutoGeneratedValue, getMapping, getNameEscape, getNextAutoGeneratedValue, getNextSequenceValue, getOptimizedBounds, getSequenceForColumn, handleSelectHints, handleUserDefinedType, includeTable, initializeConnection, isAutoCommitQuery, isLimitOffsetSupported, lookupGeneratedValuesPostInsert, ne, postCreateAttribute, postCreateFeatureType, postCreateTable, registerAggregateFunctions, registerClassToSqlMappings, registerSqlTypeNameToClassMappings, registerSqlTypeToClassMappings, registerSqlTypeToSqlTypeNameOverrides
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicSQLDialect

protected BasicSQLDialect(JDBCDataStore dataStore)
Method Detail

encodeValue

public void encodeValue(Object value,
                        Class type,
                        StringBuffer sql)
Encodes a value in an sql statement.

Subclasses may wish to override or extend this method to handle specific types. This default implementation does the following:

  1. The value is encoded via its Object.toString() representation.
  2. If type is a character type (extends CharSequence), it is wrapped in single quotes (').


encodeGeometryValue

public abstract void encodeGeometryValue(Geometry value,
                                         int srid,
                                         StringBuffer sql)
                                  throws IOException
Encodes a geometry value in an sql statement.

An implementations should serialize value into some exchange format which will then be transported to the underlying database. For example, consider an implementation which converts a geometry into its well known text representation:

   
   sql.append( "GeomFromText('" );
   sql.append( new WKTWriter().write( value ) );
   sql.append( ")" );
   
  

The srid parameter is the spatial reference system identifier of the geometry, or 0 if not known.

Attention should be paid to emtpy geometries (g.isEmtpy() == true) as they cannot be encoded in WKB and several databases fail to handle them property. Common treatment is to equate them to NULL

Throws:
IOException

createFilterToSQL

public FilterToSQL createFilterToSQL()
Creates the filter encoder to be used by the datastore when encoding query predicates.

Sublcasses can override this method to return a subclass of FilterToSQL if need be.


onSelect

public void onSelect(Statement select,
                     Connection cx,
                     SimpleFeatureType featureType)
              throws SQLException
Callback invoked before a SELECT statement is executed against the database.

The callback is provided with both the statement being executed and the database connection. Neither should be closed. Any statements created from the connection however in this method should be closed.

Parameters:
select - The select statement being executed
cx - The database connection
featureType - The feature type the select is executing against.
Throws:
SQLException

onDelete

public void onDelete(Statement delete,
                     Connection cx,
                     SimpleFeatureType featureType)
              throws SQLException
Callback invoked before a DELETE statement is executed against the database.

The callback is provided with both the statement being executed and the database connection. Neither should be closed. Any statements created from the connection however in this method should be closed.

Parameters:
delete - The delete statement being executed
cx - The database connection
featureType - The feature type the delete is executing against.
Throws:
SQLException

onInsert

public void onInsert(Statement insert,
                     Connection cx,
                     SimpleFeatureType featureType)
              throws SQLException
Callback invoked before an INSERT statement is executed against the database.

The callback is provided with both the statement being executed and the database connection. Neither should be closed. Any statements created from the connection however in this method should be closed.

Parameters:
insert - The delete statement being executed
cx - The database connection
featureType - The feature type the insert is executing against.
Throws:
SQLException

onUpdate

public void onUpdate(Statement update,
                     Connection cx,
                     SimpleFeatureType featureType)
              throws SQLException
Callback invoked before an UPDATE statement is executed against the database.

The callback is provided with both the statement being executed and the database connection. Neither should be closed. Any statements created from the connection however in this method should be closed.

Parameters:
update - The delete statement being executed
cx - The database connection
featureType - The feature type the update is executing against.
Throws:
SQLException


Copyright © 1996-2014 Geotools. All Rights Reserved.