org.geotools.data.jdbc
Class FilterToSQL

java.lang.Object
  extended by org.geotools.data.jdbc.FilterToSQL
All Implemented Interfaces:
org.opengis.filter.expression.ExpressionVisitor, org.opengis.filter.FilterVisitor
Direct Known Subclasses:
FilterToSQLSDE, H2FilterToSQL, MySQLFilterToSQL, PostgisFilterToSQL, PreparedFilterToSQL, SpatiaLiteFilterToSQL, SQLEncoderMySQL, SQLServerFilterToSQL

public class FilterToSQL
extends java.lang.Object
implements org.opengis.filter.FilterVisitor, org.opengis.filter.expression.ExpressionVisitor

Encodes a filter into a SQL WHERE statement. It should hopefully be generic enough that any SQL database will work with it. This generic SQL encoder should eventually be able to encode all filters except Geometry Filters. This is because the OGC's SFS for SQL document specifies two ways of doing SQL databases, one with native geometry types and one without. To implement an encoder for one of the two types simply subclass off of this encoder and put in the proper GeometryFilter visit method. Then add the filter types supported to the capabilities by overriding the {createFilterCapabilities() method. This version was ported from the original to support org.opengis.filter type Filters.

Author:
originally by Chris Holmes, TOPP, ported by Saul Farber, MassGIS

Field Summary
protected  FilterCapabilities capabilities
          The filter types that this class can encode
protected  org.opengis.feature.type.GeometryDescriptor currentGeometry
          the geometry descriptor corresponding to the current binary spatial filter being encoded
protected  java.lang.Integer currentSRID
          the srid corresponding to the current binary spatial filter being encoded
protected  java.lang.String databaseSchema
          The schema that contains the table the filter being encoded against.
protected  boolean encodingFunction
          flag which indicates that the encoder is currently encoding a function
protected  org.opengis.feature.simple.SimpleFeatureType featureType
          the schmema the encoder will be used to be encode sql for
protected static java.lang.String IO_ERROR
          error message for exceptions
protected  FIDMapper mapper
          Deprecated. use primaryKey
protected  java.io.Writer out
          where to write the constructed string from visiting the filters.
protected  PrimaryKey primaryKey
          The primary key corresponding to the table the filter is being encoded against.
 
Constructor Summary
FilterToSQL()
          Default constructor
FilterToSQL(java.io.Writer out)
           
 
Method Summary
protected  FilterCapabilities createFilterCapabilities()
          Sets the capabilities of this filter.
 void encode(org.opengis.filter.expression.Expression expression)
          Performs the encoding, sends the encoded sql to the writer passed in.
 void encode(org.opengis.filter.Filter filter)
          Performs the encoding, sends the encoded sql to the writer passed in.
 java.lang.String encodeToString(org.opengis.filter.expression.Expression expression)
          purely a convenience method.
 java.lang.String encodeToString(org.opengis.filter.Filter filter)
          purely a convenience method.
 java.lang.String escapeName(java.lang.String name)
          Surrounds a name with the SQL escape character.
protected  java.lang.Object evaluateLiteral(org.opengis.filter.expression.Literal expression, java.lang.Class target)
           
 FilterCapabilities getCapabilities()
          Describes the capabilities of this encoder.
 java.lang.String getDatabaseSchema()
           
 FIDMapper getFIDMapper()
          Deprecated. use getPrimaryKey()
 PrimaryKey getPrimaryKey()
           
 void setCapabilities(FilterCapabilities capabilities)
          Sets the capabilities for the encoder.
 void setDatabaseSchema(java.lang.String databaseSchema)
           
 void setFeatureType(org.opengis.feature.simple.SimpleFeatureType featureType)
          Sets the featuretype the encoder is encoding sql for.
 void setFIDMapper(FIDMapper mapper)
          Deprecated. use setPrimaryKey(PrimaryKey)
 void setPrimaryKey(PrimaryKey primaryKey)
           
 void setSqlNameEscape(java.lang.String escape)
          Sets the SQL name escape string.
 void setWriter(java.io.Writer out)
          Sets the writer the encoder will write to.
 java.lang.Object visit(org.opengis.filter.expression.Add expression, java.lang.Object extraData)
           
 java.lang.Object visit(org.opengis.filter.And filter, java.lang.Object extraData)
          Write the SQL for an And filter
 java.lang.Object visit(org.opengis.filter.spatial.BBOX filter, java.lang.Object extraData)
           
 java.lang.Object visit(org.opengis.filter.spatial.Beyond filter, java.lang.Object extraData)
           
protected  java.lang.Object visit(org.opengis.filter.expression.BinaryExpression expression, java.lang.String operator, java.lang.Object extraData)
          Writes the SQL for the Math Expression.
protected  java.lang.Object visit(org.opengis.filter.BinaryLogicOperator filter, java.lang.Object extraData)
          Common implementation for BinaryLogicOperator filters.
 java.lang.Object visit(org.opengis.filter.spatial.Contains filter, java.lang.Object extraData)
           
 java.lang.Object visit(org.opengis.filter.spatial.Crosses filter, java.lang.Object extraData)
           
 java.lang.Object visit(org.opengis.filter.spatial.Disjoint filter, java.lang.Object extraData)
           
 java.lang.Object visit(org.opengis.filter.expression.Divide expression, java.lang.Object extraData)
           
 java.lang.Object visit(org.opengis.filter.spatial.DWithin filter, java.lang.Object extraData)
           
 java.lang.Object visit(org.opengis.filter.spatial.Equals filter, java.lang.Object extraData)
           
 java.lang.Object visit(org.opengis.filter.ExcludeFilter filter, java.lang.Object extraData)
           
 java.lang.Object visit(org.opengis.filter.expression.Function function, java.lang.Object extraData)
          Writes sql for a function expression.
 java.lang.Object visit(org.opengis.filter.Id filter, java.lang.Object extraData)
          Encodes an Id filter
 java.lang.Object visit(org.opengis.filter.IncludeFilter filter, java.lang.Object extraData)
           
 java.lang.Object visit(org.opengis.filter.spatial.Intersects filter, java.lang.Object extraData)
           
 java.lang.Object visit(org.opengis.filter.expression.Literal expression, java.lang.Object context)
          Export the contents of a Literal Expresion
 java.lang.Object visit(org.opengis.filter.expression.Multiply expression, java.lang.Object extraData)
           
 java.lang.Object visit(org.opengis.filter.expression.NilExpression expression, java.lang.Object extraData)
           
 java.lang.Object visit(org.opengis.filter.Not filter, java.lang.Object extraData)
          Write the SQL for a Not filter
 java.lang.Object visit(org.opengis.filter.Or filter, java.lang.Object extraData)
          Write the SQL for an Or filter
 java.lang.Object visit(org.opengis.filter.spatial.Overlaps filter, java.lang.Object extraData)
           
 java.lang.Object visit(org.opengis.filter.PropertyIsBetween filter, java.lang.Object extraData)
          Writes the SQL for the PropertyIsBetween Filter.
 java.lang.Object visit(org.opengis.filter.PropertyIsEqualTo filter, java.lang.Object extraData)
          Write the SQL for this kind of filter
 java.lang.Object visit(org.opengis.filter.PropertyIsGreaterThan filter, java.lang.Object extraData)
          Write the SQL for this kind of filter
 java.lang.Object visit(org.opengis.filter.PropertyIsGreaterThanOrEqualTo filter, java.lang.Object extraData)
          Write the SQL for this kind of filter
 java.lang.Object visit(org.opengis.filter.PropertyIsLessThan filter, java.lang.Object extraData)
          Write the SQL for this kind of filter
 java.lang.Object visit(org.opengis.filter.PropertyIsLessThanOrEqualTo filter, java.lang.Object extraData)
          Write the SQL for this kind of filter
 java.lang.Object visit(org.opengis.filter.PropertyIsLike filter, java.lang.Object extraData)
          Writes the SQL for the Like Filter.
 java.lang.Object visit(org.opengis.filter.PropertyIsNotEqualTo filter, java.lang.Object extraData)
          Write the SQL for this kind of filter
 java.lang.Object visit(org.opengis.filter.PropertyIsNull filter, java.lang.Object extraData)
          Writes the SQL for the Null Filter.
 java.lang.Object visit(org.opengis.filter.expression.PropertyName expression, java.lang.Object extraData)
          Writes the SQL for the attribute Expression.
 java.lang.Object visit(org.opengis.filter.expression.Subtract expression, java.lang.Object extraData)
           
 java.lang.Object visit(org.opengis.filter.spatial.Touches filter, java.lang.Object extraData)
           
 java.lang.Object visit(org.opengis.filter.spatial.Within filter, java.lang.Object extraData)
           
protected  void visitBinaryComparisonOperator(org.opengis.filter.BinaryComparisonOperator filter, java.lang.Object extraData)
          Common implementation for BinaryComparisonOperator filters.
protected  java.lang.Object visitBinarySpatialOperator(org.opengis.filter.spatial.BinarySpatialOperator filter, java.lang.Object extraData)
           
protected  java.lang.Object visitBinarySpatialOperator(org.opengis.filter.spatial.BinarySpatialOperator filter, org.opengis.filter.expression.PropertyName property, org.opengis.filter.expression.Literal geometry, boolean swapped, java.lang.Object extraData)
           
protected  void visitLiteralGeometry(org.opengis.filter.expression.Literal expression)
          Subclasses must implement this method in order to encode geometry filters according to the specific database implementation
 java.lang.Object visitNullFilter(java.lang.Object extraData)
          Encodes a null filter value.
protected  void writeLiteral(java.lang.Object literal)
          Writes out a non null, non geometry literal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IO_ERROR

protected static final java.lang.String IO_ERROR
error message for exceptions

See Also:
Constant Field Values

capabilities

protected FilterCapabilities capabilities
The filter types that this class can encode


out

protected java.io.Writer out
where to write the constructed string from visiting the filters.


mapper

protected FIDMapper mapper
Deprecated. use primaryKey
the fid mapper used to encode the fid filters


primaryKey

protected PrimaryKey primaryKey
The primary key corresponding to the table the filter is being encoded against.


databaseSchema

protected java.lang.String databaseSchema
The schema that contains the table the filter being encoded against.


featureType

protected org.opengis.feature.simple.SimpleFeatureType featureType
the schmema the encoder will be used to be encode sql for


encodingFunction

protected boolean encodingFunction
flag which indicates that the encoder is currently encoding a function


currentGeometry

protected org.opengis.feature.type.GeometryDescriptor currentGeometry
the geometry descriptor corresponding to the current binary spatial filter being encoded


currentSRID

protected java.lang.Integer currentSRID
the srid corresponding to the current binary spatial filter being encoded

Constructor Detail

FilterToSQL

public FilterToSQL()
Default constructor


FilterToSQL

public FilterToSQL(java.io.Writer out)
Method Detail

setWriter

public void setWriter(java.io.Writer out)
Sets the writer the encoder will write to.


encode

public void encode(org.opengis.filter.Filter filter)
            throws FilterToSQLException
Performs the encoding, sends the encoded sql to the writer passed in.

Parameters:
filter - the Filter to be encoded.
Throws:
OpenGISFilterToOpenGISFilterToSQLEncoderException - If filter type not supported, or if there were io problems.
FilterToSQLException

encodeToString

public java.lang.String encodeToString(org.opengis.filter.Filter filter)
                                throws FilterToSQLException
purely a convenience method. Equivalent to: StringWriter out = new StringWriter(); new FilterToSQL(out).encode(filter); out.getBuffer().toString();

Parameters:
filter -
Returns:
a string representing the filter encoded to SQL.
Throws:
FilterToSQLException

encode

public void encode(org.opengis.filter.expression.Expression expression)
            throws FilterToSQLException
Performs the encoding, sends the encoded sql to the writer passed in.

Parameters:
filter - the Filter to be encoded.
Throws:
OpenGISFilterToOpenGISFilterToSQLEncoderException - If filter type not supported, or if there were io problems.
FilterToSQLException

encodeToString

public java.lang.String encodeToString(org.opengis.filter.expression.Expression expression)
                                throws FilterToSQLException
purely a convenience method. Equivalent to: StringWriter out = new StringWriter(); new FilterToSQL(out).encode(filter); out.getBuffer().toString();

Parameters:
filter -
Returns:
a string representing the filter encoded to SQL.
Throws:
FilterToSQLException

setFeatureType

public void setFeatureType(org.opengis.feature.simple.SimpleFeatureType featureType)
Sets the featuretype the encoder is encoding sql for.

This is used for context for attribute expressions when encoding to sql.

Parameters:
featureType -

setFIDMapper

public void setFIDMapper(FIDMapper mapper)
Deprecated. use setPrimaryKey(PrimaryKey)

Sets the FIDMapper that will be used in subsequente visit calls. There must be a FIDMapper in order to invoke the FIDFilter encoder.

Parameters:
mapper -

getFIDMapper

public FIDMapper getFIDMapper()
Deprecated. use getPrimaryKey()


getPrimaryKey

public PrimaryKey getPrimaryKey()

setPrimaryKey

public void setPrimaryKey(PrimaryKey primaryKey)

getDatabaseSchema

public java.lang.String getDatabaseSchema()

setDatabaseSchema

public void setDatabaseSchema(java.lang.String databaseSchema)

createFilterCapabilities

protected FilterCapabilities createFilterCapabilities()
Sets the capabilities of this filter.

Returns:
FilterCapabilities for this Filter

getCapabilities

public final FilterCapabilities getCapabilities()
Describes the capabilities of this encoder.

Performs lazy creation of capabilities.

If you're subclassing this class, override createFilterCapabilities to declare which filtercapabilities you support. Don't use this method.

Returns:
The capabilities supported by this encoder.

setCapabilities

public void setCapabilities(FilterCapabilities capabilities)
Sets the capabilities for the encoder.


visit

public java.lang.Object visit(org.opengis.filter.ExcludeFilter filter,
                              java.lang.Object extraData)
Specified by:
visit in interface org.opengis.filter.FilterVisitor
Parameters:
the - filter to be visited
See Also:
FilterVisitor#visit(ExcludeFilter, Object)} Writes the SQL for the IncludeFilter by writing "FALSE".

visit

public java.lang.Object visit(org.opengis.filter.IncludeFilter filter,
                              java.lang.Object extraData)
Specified by:
visit in interface org.opengis.filter.FilterVisitor
Parameters:
the - filter to be visited
See Also:
FilterVisitor#visit(IncludeFilter, Object)} Writes the SQL for the IncludeFilter by writing "TRUE".

visit

public java.lang.Object visit(org.opengis.filter.PropertyIsBetween filter,
                              java.lang.Object extraData)
                       throws java.lang.RuntimeException
Writes the SQL for the PropertyIsBetween Filter.

Specified by:
visit in interface org.opengis.filter.FilterVisitor
Parameters:
filter - the Filter to be visited.
Throws:
java.lang.RuntimeException - for io exception with writer

visit

public java.lang.Object visit(org.opengis.filter.PropertyIsLike filter,
                              java.lang.Object extraData)
Writes the SQL for the Like Filter. Assumes the current java implemented wildcards for the Like Filter: . for multi and .? for single. And replaces them with the SQL % and _, respectively.

Specified by:
visit in interface org.opengis.filter.FilterVisitor
Parameters:
filter - the Like Filter to be visited.

visit

public java.lang.Object visit(org.opengis.filter.And filter,
                              java.lang.Object extraData)
Write the SQL for an And filter

Specified by:
visit in interface org.opengis.filter.FilterVisitor
Parameters:
filter - the filter to visit
extraData - extra data (unused by this method)

visit

public java.lang.Object visit(org.opengis.filter.Not filter,
                              java.lang.Object extraData)
Write the SQL for a Not filter

Specified by:
visit in interface org.opengis.filter.FilterVisitor
Parameters:
filter - the filter to visit
extraData - extra data (unused by this method)

visit

public java.lang.Object visit(org.opengis.filter.Or filter,
                              java.lang.Object extraData)
Write the SQL for an Or filter

Specified by:
visit in interface org.opengis.filter.FilterVisitor
Parameters:
filter - the filter to visit
extraData - extra data (unused by this method)

visit

protected java.lang.Object visit(org.opengis.filter.BinaryLogicOperator filter,
                                 java.lang.Object extraData)
Common implementation for BinaryLogicOperator filters. This way they're all handled centrally.

Parameters:
filter - the logic statement to be turned into SQL.
extraData - extra filter data. Not modified directly by this method.

visit

public java.lang.Object visit(org.opengis.filter.PropertyIsEqualTo filter,
                              java.lang.Object extraData)
Write the SQL for this kind of filter

Specified by:
visit in interface org.opengis.filter.FilterVisitor
Parameters:
filter - the filter to visit
extraData - extra data (unused by this method)

visit

public java.lang.Object visit(org.opengis.filter.PropertyIsGreaterThanOrEqualTo filter,
                              java.lang.Object extraData)
Write the SQL for this kind of filter

Specified by:
visit in interface org.opengis.filter.FilterVisitor
Parameters:
filter - the filter to visit
extraData - extra data (unused by this method)

visit

public java.lang.Object visit(org.opengis.filter.PropertyIsGreaterThan filter,
                              java.lang.Object extraData)
Write the SQL for this kind of filter

Specified by:
visit in interface org.opengis.filter.FilterVisitor
Parameters:
filter - the filter to visit
extraData - extra data (unused by this method)

visit

public java.lang.Object visit(org.opengis.filter.PropertyIsLessThan filter,
                              java.lang.Object extraData)
Write the SQL for this kind of filter

Specified by:
visit in interface org.opengis.filter.FilterVisitor
Parameters:
filter - the filter to visit
extraData - extra data (unused by this method)

visit

public java.lang.Object visit(org.opengis.filter.PropertyIsLessThanOrEqualTo filter,
                              java.lang.Object extraData)
Write the SQL for this kind of filter

Specified by:
visit in interface org.opengis.filter.FilterVisitor
Parameters:
filter - the filter to visit
extraData - extra data (unused by this method)

visit

public java.lang.Object visit(org.opengis.filter.PropertyIsNotEqualTo filter,
                              java.lang.Object extraData)
Write the SQL for this kind of filter

Specified by:
visit in interface org.opengis.filter.FilterVisitor
Parameters:
filter - the filter to visit
extraData - extra data (unused by this method)

visitBinaryComparisonOperator

protected void visitBinaryComparisonOperator(org.opengis.filter.BinaryComparisonOperator filter,
                                             java.lang.Object extraData)
                                      throws java.lang.RuntimeException
Common implementation for BinaryComparisonOperator filters. This way they're all handled centrally. DJB: note, postgis overwrites this implementation because of the way null is handled. This is for filters and filters are handled. They will come here with "property = null". NOTE: SELECT * FROM WHERE isnull; -- postgresql SELECT * FROM
WHERE isnull(); -- oracle???

Parameters:
filter - the comparison to be turned into SQL.
Throws:
java.lang.RuntimeException - for io exception with writer

visit

public java.lang.Object visit(org.opengis.filter.PropertyIsNull filter,
                              java.lang.Object extraData)
                       throws java.lang.RuntimeException
Writes the SQL for the Null Filter.

Specified by:
visit in interface org.opengis.filter.FilterVisitor
Parameters:
filter - the null filter to be written to SQL.
Throws:
java.lang.RuntimeException - for io exception with writer

visit

public java.lang.Object visit(org.opengis.filter.Id filter,
                              java.lang.Object extraData)
Encodes an Id filter

Specified by:
visit in interface org.opengis.filter.FilterVisitor
Parameters:
filter - the
Throws:
java.lang.RuntimeException - If there's a problem writing output

visit

public java.lang.Object visit(org.opengis.filter.spatial.BBOX filter,
                              java.lang.Object extraData)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.Beyond filter,
                              java.lang.Object extraData)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.Contains filter,
                              java.lang.Object extraData)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.Crosses filter,
                              java.lang.Object extraData)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.Disjoint filter,
                              java.lang.Object extraData)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.DWithin filter,
                              java.lang.Object extraData)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.Equals filter,
                              java.lang.Object extraData)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.Intersects filter,
                              java.lang.Object extraData)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.Overlaps filter,
                              java.lang.Object extraData)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.Touches filter,
                              java.lang.Object extraData)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.Within filter,
                              java.lang.Object extraData)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visitBinarySpatialOperator

protected java.lang.Object visitBinarySpatialOperator(org.opengis.filter.spatial.BinarySpatialOperator filter,
                                                      java.lang.Object extraData)

visitBinarySpatialOperator

protected java.lang.Object visitBinarySpatialOperator(org.opengis.filter.spatial.BinarySpatialOperator filter,
                                                      org.opengis.filter.expression.PropertyName property,
                                                      org.opengis.filter.expression.Literal geometry,
                                                      boolean swapped,
                                                      java.lang.Object extraData)

visitNullFilter

public java.lang.Object visitNullFilter(java.lang.Object extraData)
Encodes a null filter value. The current implementation does exactly nothing.

Specified by:
visitNullFilter in interface org.opengis.filter.FilterVisitor
Parameters:
extraData - extra data to be used to evaluate the filter
Returns:
the untouched extraData parameter

visit

public java.lang.Object visit(org.opengis.filter.expression.PropertyName expression,
                              java.lang.Object extraData)
                       throws java.lang.RuntimeException
Writes the SQL for the attribute Expression.

Specified by:
visit in interface org.opengis.filter.expression.ExpressionVisitor
Parameters:
expression - the attribute to turn to SQL.
Throws:
java.lang.RuntimeException - for io exception with writer

visit

public java.lang.Object visit(org.opengis.filter.expression.Literal expression,
                              java.lang.Object context)
                       throws java.lang.RuntimeException
Export the contents of a Literal Expresion

Specified by:
visit in interface org.opengis.filter.expression.ExpressionVisitor
Parameters:
expression - the Literal to export
Throws:
java.lang.RuntimeException - for io exception with writer

evaluateLiteral

protected java.lang.Object evaluateLiteral(org.opengis.filter.expression.Literal expression,
                                           java.lang.Class target)

writeLiteral

protected void writeLiteral(java.lang.Object literal)
                     throws java.io.IOException
Writes out a non null, non geometry literal. The base class properly handles null, numeric and booleans (true|false), and turns everything else into a string. Subclasses are expected to override this shall they need a different treatment (e.g. for dates)

Parameters:
literal -
Throws:
java.io.IOException

visitLiteralGeometry

protected void visitLiteralGeometry(org.opengis.filter.expression.Literal expression)
                             throws java.io.IOException
Subclasses must implement this method in order to encode geometry filters according to the specific database implementation

Parameters:
expression -
Throws:
java.io.IOException - DOCUMENT ME!
java.lang.RuntimeException - DOCUMENT ME!

visit

public java.lang.Object visit(org.opengis.filter.expression.Add expression,
                              java.lang.Object extraData)
Specified by:
visit in interface org.opengis.filter.expression.ExpressionVisitor

visit

public java.lang.Object visit(org.opengis.filter.expression.Divide expression,
                              java.lang.Object extraData)
Specified by:
visit in interface org.opengis.filter.expression.ExpressionVisitor

visit

public java.lang.Object visit(org.opengis.filter.expression.Multiply expression,
                              java.lang.Object extraData)
Specified by:
visit in interface org.opengis.filter.expression.ExpressionVisitor

visit

public java.lang.Object visit(org.opengis.filter.expression.Subtract expression,
                              java.lang.Object extraData)
Specified by:
visit in interface org.opengis.filter.expression.ExpressionVisitor

visit

protected java.lang.Object visit(org.opengis.filter.expression.BinaryExpression expression,
                                 java.lang.String operator,
                                 java.lang.Object extraData)
                          throws java.lang.RuntimeException
Writes the SQL for the Math Expression.

Parameters:
expression - the Math phrase to be written.
operator - The operator of the expression.
Throws:
java.lang.RuntimeException - for io problems

visit

public java.lang.Object visit(org.opengis.filter.expression.Function function,
                              java.lang.Object extraData)
                       throws java.lang.RuntimeException
Writes sql for a function expression.

Specified by:
visit in interface org.opengis.filter.expression.ExpressionVisitor
Parameters:
expression - a function expression
Throws:
java.lang.RuntimeException - If an IO error occurs.

visit

public java.lang.Object visit(org.opengis.filter.expression.NilExpression expression,
                              java.lang.Object extraData)
Specified by:
visit in interface org.opengis.filter.expression.ExpressionVisitor

setSqlNameEscape

public void setSqlNameEscape(java.lang.String escape)
Sets the SQL name escape string.

The value of this string is prefixed and appended to table schema names, table names and column names in an SQL statement to support mixed-case and non-English names. Without this, the DBMS may assume a mixed-case name in the query should be treated as upper-case and an SQLCODE of -204 or 206 may result if the name is not found.

Typically this is the double-quote character, ", but may not be for all databases.

For example, consider the following query:

SELECT Geom FROM Spear.ArchSites May be interpreted by the database as: SELECT GEOM FROM SPEAR.ARCHSITES If the column and table names were actually created using mixed-case, the query needs to be specified as: SELECT "Geom" from "Spear"."ArchSites"

Parameters:
escape - the character to be used to escape database names

escapeName

public java.lang.String escapeName(java.lang.String name)
Surrounds a name with the SQL escape character.

Parameters:
name -
Returns:
DOCUMENT ME!


Copyright © 1996-2010 Geotools. All Rights Reserved.