org.geotools.filter
Class SQLEncoderMySQL

java.lang.Object
  extended by org.geotools.data.jdbc.FilterToSQL
      extended by org.geotools.filter.SQLEncoderMySQL
All Implemented Interfaces:
org.opengis.filter.expression.ExpressionVisitor, org.opengis.filter.FilterVisitor

public class SQLEncoderMySQL
extends FilterToSQL
implements org.opengis.filter.FilterVisitor

Encodes a filter into a SQL WHERE statement for MySQL. This class adds the ability to turn geometry filters into sql statements if they are bboxes.

Author:
Chris Holmes, TOPP, Debasish Sahu, debasish.sahu@rmsi.com, Harry Bullen

Field Summary
 
Fields inherited from class org.geotools.data.jdbc.FilterToSQL
capabilities, currentGeometry, currentSRID, databaseSchema, encodingFunction, featureType, IO_ERROR, mapper, out, primaryKey
 
Constructor Summary
SQLEncoderMySQL()
          Empty constructor TODO: rethink empty constructor, as BBOXes _need_ an SRID, must make client set it somehow.
SQLEncoderMySQL(int srid)
           
 
Method Summary
protected  FilterCapabilities createFilterCapabilities()
          Sets the capabilities of this filter.
 void setDefaultGeometry(java.lang.String name)
          Sets the default geometry, so that filters with null for one of their expressions can assume that the default geometry is intended.
 void setSRID(int srid)
          Sets a spatial reference system ESPG number, so that the geometry can be properly encoded for postgis.
 java.lang.Object visit(org.opengis.filter.spatial.BBOX filter, java.lang.Object extra)
          Turns a geometry filter into the mySQL bbox statement.
 void visit(org.opengis.filter.PropertyIsLike filter)
           
 void visitLiteralGeometry(org.opengis.filter.expression.Literal expression)
          Checks to see if the literal is a geometry, and encodes it if it is, if not just sends to the parent class.
 
Methods inherited from class org.geotools.data.jdbc.FilterToSQL
encode, encode, encodeToString, encodeToString, escapeName, evaluateLiteral, getCapabilities, getDatabaseSchema, getFIDMapper, getPrimaryKey, setCapabilities, setDatabaseSchema, setFeatureType, setFIDMapper, setPrimaryKey, setSqlNameEscape, setWriter, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visitBinaryComparisonOperator, visitBinarySpatialOperator, visitBinarySpatialOperator, visitNullFilter, writeLiteral
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opengis.filter.FilterVisitor
visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visitNullFilter
 

Constructor Detail

SQLEncoderMySQL

public SQLEncoderMySQL()
Empty constructor TODO: rethink empty constructor, as BBOXes _need_ an SRID, must make client set it somehow. Maybe detect when encode is called?


SQLEncoderMySQL

public SQLEncoderMySQL(int srid)
Method Detail

createFilterCapabilities

protected FilterCapabilities createFilterCapabilities()
Description copied from class: FilterToSQL
Sets the capabilities of this filter.

Overrides:
createFilterCapabilities in class FilterToSQL
Returns:
FilterCapabilities for this Filter
See Also:
SQLEncoder.createFilterCapabilities()

setSRID

public void setSRID(int srid)
Sets a spatial reference system ESPG number, so that the geometry can be properly encoded for postgis. If geotools starts actually creating geometries with valid srids then this method will no longer be needed.

Parameters:
srid - the integer code for the EPSG spatial reference system.

setDefaultGeometry

public void setDefaultGeometry(java.lang.String name)
Sets the default geometry, so that filters with null for one of their expressions can assume that the default geometry is intended.

Parameters:
name - the name of the default geometry Attribute.

visit

public java.lang.Object visit(org.opengis.filter.spatial.BBOX filter,
                              java.lang.Object extra)
Turns a geometry filter into the mySQL bbox statement.

Specified by:
visit in interface org.opengis.filter.FilterVisitor
Overrides:
visit in class FilterToSQL
Parameters:
filter - the geometry filter to be encoded.
Throws:
java.lang.RuntimeException - for IO exception (need a better error)

visitLiteralGeometry

public void visitLiteralGeometry(org.opengis.filter.expression.Literal expression)
                          throws java.io.IOException
Checks to see if the literal is a geometry, and encodes it if it is, if not just sends to the parent class.

Overrides:
visitLiteralGeometry in class FilterToSQL
Parameters:
expression - the expression to visit and encode.
Throws:
java.io.IOException - for IO exception (need a better error) TODO: this should use WKB

visit

public void visit(org.opengis.filter.PropertyIsLike filter)


Copyright © 1996-2010 Geotools. All Rights Reserved.