org.geotools.filter
Class SQLEncoderMySQL

java.lang.Object
  extended byorg.geotools.filter.SQLEncoder
      extended byorg.geotools.filter.SQLEncoderMySQL
All Implemented Interfaces:
FilterVisitor

public class SQLEncoderMySQL
extends SQLEncoder
implements 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

Field Summary
 
Fields inherited from class org.geotools.filter.SQLEncoder
mapper, out
 
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.
 void visit(GeometryFilter filter)
          Turns a geometry filter into the postgis sql bbox statement.
 void visit(LikeFilter filter)
          Called when accept is called on a Like Filter.
 void visitLiteralGeometry(LiteralExpression 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.filter.SQLEncoder
encode, encode, escapeName, getCapabilities, getColnameEscape, setColnameEscape, setFIDMapper, setSqlNameEscape, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.geotools.filter.FilterVisitor
visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
 

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: SQLEncoder
Sets the capabilities of this filter.

Overrides:
createFilterCapabilities in class SQLEncoder
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.
Task:
REVISIT: pass in a featureType so that geometries can figure out their own default geometry?

visit

public void visit(GeometryFilter filter)
           throws java.lang.RuntimeException
Turns a geometry filter into the postgis sql bbox statement.

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

visitLiteralGeometry

public void visitLiteralGeometry(LiteralExpression 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 SQLEncoder
Parameters:
expression - the expression to visit and encode.
Throws:
java.io.IOException - for IO exception (need a better error)

visit

public void visit(LikeFilter filter)
Description copied from interface: FilterVisitor
Called when accept is called on a Like Filter. Implementers will want to access the pattern and value.

Specified by:
visit in interface FilterVisitor
Overrides:
visit in class SQLEncoder
Parameters:
filter - the Like Filter to be visited.


Copyright © GeoTools. All Rights Reserved.