org.geotools.data.db2.filter
Class SQLEncoderDB2

java.lang.Object
  extended byorg.geotools.filter.SQLEncoder
      extended byorg.geotools.data.db2.filter.SQLEncoderDB2
All Implemented Interfaces:
FilterVisitor

public class SQLEncoderDB2
extends SQLEncoder
implements FilterVisitor

Generate a WHERE clause for DB2 Spatial Extender based on a spatial filter.

The following spatial filter operations are supported:

Author:
David Adler - IBM Corporation

Field Summary
 
Fields inherited from class org.geotools.filter.SQLEncoder
mapper, out
 
Constructor Summary
SQLEncoderDB2()
          Construct an SQLEncoderDB2
SQLEncoderDB2(java.io.Writer out, Filter filter)
          Construct an SQLEncoderDB2 that does the encoding (through superclass) directly based on the filter parameter.
 
Method Summary
protected  FilterCapabilities createFilterCapabilities()
          Sets the DB2 filter capabilities.
 void setSelectivityClause(java.lang.String string)
          Sets a SELECTIVITY clause that can be included with the spatial predicate to influence the query optimizer to exploit a spatial index if it exists.
 void setSRID(int srid)
          Set the value of the srid value to be used if a DB2 Spatial Extender geometry needs to be constructed.
 void visit(GeometryFilter filter)
          Generate a WHERE clause for the input GeometryFilter.
 void visit(LikeFilter filter)
          Writes the SQL for the Like Filter.
 void visitLiteralGeometry(LiteralExpression expression)
          Construct an ST_Geometry from the WKT representation of a literal expression
 
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

SQLEncoderDB2

public SQLEncoderDB2()
Construct an SQLEncoderDB2


SQLEncoderDB2

public SQLEncoderDB2(java.io.Writer out,
                     Filter filter)
              throws SQLEncoderException
Construct an SQLEncoderDB2 that does the encoding (through superclass) directly based on the filter parameter.

Parameters:
out - a writer object
filter - query filter to be encoded
Throws:
SQLEncoderException
Method Detail

visit

public void visit(LikeFilter filter)
           throws java.lang.RuntimeException
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 FilterVisitor
Overrides:
visit in class SQLEncoder
Parameters:
filter - the Like Filter to be visited.
Throws:
java.lang.RuntimeException - if writing the expression fails.

visit

public void visit(GeometryFilter filter)
           throws java.lang.RuntimeException
Generate a WHERE clause for the input GeometryFilter.

The following spatial filter operations are supported:

Specified by:
visit in interface FilterVisitor
Overrides:
visit in class SQLEncoder
Parameters:
filter - The geometry filter to be processed.
Throws:
java.lang.RuntimeException - for IO exception
See Also:
FilterVisitor.visit(org.geotools.filter.GeometryFilter)

visitLiteralGeometry

public void visitLiteralGeometry(LiteralExpression expression)
                          throws java.io.IOException
Construct an ST_Geometry from the WKT representation of a literal expression

Overrides:
visitLiteralGeometry in class SQLEncoder
Parameters:
expression - the expression turn into an ST_Geometry.
Throws:
java.io.IOException - Passes back exception if generated by this.out.write()

setSRID

public void setSRID(int srid)
Set the value of the srid value to be used if a DB2 Spatial Extender geometry needs to be constructed.

This is specifically the DB2 Spatial Extender spatial reference system identifier and not a coordinate system identifier ala EPSG.

Parameters:
srid - Spatial reference system identifier to be used.

createFilterCapabilities

protected FilterCapabilities createFilterCapabilities()
Sets the DB2 filter capabilities.

Overrides:
createFilterCapabilities in class SQLEncoder
Returns:
FilterCapabilities for DB2

setSelectivityClause

public void setSelectivityClause(java.lang.String string)
Sets a SELECTIVITY clause that can be included with the spatial predicate to influence the query optimizer to exploit a spatial index if it exists.

The parameter should be of the form:
"SELECTIVITY 0.001"
where the numeric value is the fraction of rows that will be returned by using the index scan. This doesn't have to be true. The value 0.001 is typically used to force the use of the spatial in all cases if the spatial index exists.

Parameters:
string - a selectivity clause


Copyright © GeoTools. All Rights Reserved.