org.geotools.data.db2
Class DB2FilterToSQL

Object
  extended by FilterToSQL
      extended by PreparedFilterToSQL
          extended by DB2FilterToSQL
All Implemented Interfaces:
ExpressionVisitor, FilterVisitor

public class DB2FilterToSQL
extends PreparedFilterToSQL

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

The following spatial filter operations are supported:

Author:
Mueller Christian

Nested Class Summary
 
Nested classes/interfaces inherited from class FilterToSQL
FilterToSQL.FieldEncoder
 
Field Summary
 
Fields inherited from class PreparedFilterToSQL
dialect, dimensions, literalTypes, literalValues, SRIDs
 
Fields inherited from class FilterToSQL
capabilities, currentDimension, currentGeometry, currentSRID, databaseSchema, encodingFunction, featureType, fieldEncoder, filterFactory, inline, IO_ERROR, mapper, out, primaryKey
 
Constructor Summary
DB2FilterToSQL(PreparedStatementSQLDialect dialect)
           
DB2FilterToSQL(Writer out)
           
 
Method Summary
protected  void addSelectivity()
           
protected  FilterCapabilities createFilterCapabilities()
          Sets the DB2 filter capabilities.
 String db2Geom(Geometry geom)
          Construct a geometry from the WKT representation of a geometry
 HashMap<Class<?>,String> getPredicateMap()
           
 boolean isFunctionEncodingEnabled()
           
 boolean isLooseBBOXEnabled()
           
 void setFunctionEncodingEnabled(boolean functionEncodingEnabled)
           
 void setLooseBBOXEnabled(boolean looseBBOXEnabled)
           
 void setSelectivityClause(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.
 Object visit(BBOX filter, Object extraData)
           
 Object visit(ExcludeFilter filter, Object extraData)
          Visit Filter.EXCLUDE (often used during data structure transformations).
 Object visit(Function function, Object extraData)
          Writes sql for a function expression.
 Object visit(IncludeFilter filter, Object extraData)
          Visit Filter.INCLUDE (often used during data structure transformations).
protected  Object visitBinarySpatialOperator(BinarySpatialOperator filter, Expression e1, Expression e2, boolean swapped, Object extraData)
           
protected  Object visitBinarySpatialOperator(BinarySpatialOperator filter, Expression e1, Expression e2, Object extraData)
          Handles the more general case of two generic expressions.
protected  Object visitBinarySpatialOperator(BinarySpatialOperator filter, PropertyName property, Literal geometry, boolean swapped, Object extraData)
          Handles the common case of a PropertyName,Literal geometry binary spatial operator.
 boolean visitFunction(Function function, Object extraData)
          Performs custom visits for functions that cannot be encoded as functionName(p1, p2, ... pN).
 void visitLiteralGeometry(Literal expression)
          Construct the appropriate geometry type from the WKT representation of a literal expression
protected  void writeLiteral(Object literal)
          Writes out a non null, non geometry literal.
 
Methods inherited from class PreparedFilterToSQL
getDimensions, getLiteralTypes, getLiteralValues, getSRIDs, isPrepareEnabled, setPrepareEnabled, visit, visit
 
Methods inherited from class FilterToSQL
cast, encode, encode, encodeToString, encodeToString, escapeName, evaluateLiteral, getCapabilities, getDatabaseSchema, getFIDMapper, getFunctionName, getParameter, getPrimaryKey, setCapabilities, setDatabaseSchema, setFeatureType, setFIDMapper, setFieldEncoder, setInline, 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, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visitBinaryComparisonOperator, visitBinarySpatialOperator, visitBinaryTemporalOperator, visitBinaryTemporalOperator, visitBinaryTemporalOperator, visitLiteralTimePeriod, visitNullFilter
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DB2FilterToSQL

public DB2FilterToSQL(PreparedStatementSQLDialect dialect)

DB2FilterToSQL

public DB2FilterToSQL(Writer out)
Method Detail

getPredicateMap

public HashMap<Class<?>,String> getPredicateMap()

db2Geom

public String db2Geom(Geometry geom)
Construct a geometry from the WKT representation of a geometry

Parameters:
geom - the constructor for the geometry.

createFilterCapabilities

protected FilterCapabilities createFilterCapabilities()
Sets the DB2 filter capabilities.

Overrides:
createFilterCapabilities in class FilterToSQL
Returns:
FilterCapabilities for DB2

setSelectivityClause

public void setSelectivityClause(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

visitBinarySpatialOperator

protected Object visitBinarySpatialOperator(BinarySpatialOperator filter,
                                            PropertyName property,
                                            Literal geometry,
                                            boolean swapped,
                                            Object extraData)
Description copied from class: FilterToSQL
Handles the common case of a PropertyName,Literal geometry binary spatial operator.

Overrides:
visitBinarySpatialOperator in class FilterToSQL

visitBinarySpatialOperator

protected Object visitBinarySpatialOperator(BinarySpatialOperator filter,
                                            Expression e1,
                                            Expression e2,
                                            Object extraData)
Description copied from class: FilterToSQL
Handles the more general case of two generic expressions.

The most common case is two PropertyName expressions, which happens during a spatial join.

Overrides:
visitBinarySpatialOperator in class FilterToSQL

visitBinarySpatialOperator

protected Object visitBinarySpatialOperator(BinarySpatialOperator filter,
                                            Expression e1,
                                            Expression e2,
                                            boolean swapped,
                                            Object extraData)

visitLiteralGeometry

public void visitLiteralGeometry(Literal expression)
                          throws IOException
Construct the appropriate geometry type from the WKT representation of a literal expression

Overrides:
visitLiteralGeometry in class FilterToSQL
Parameters:
expression - the expression turn into a geometry constructor.
Throws:
IOException - Passes back exception if generated by this.out.write()

addSelectivity

protected void addSelectivity()
                       throws IOException
Throws:
IOException

visit

public Object visit(ExcludeFilter filter,
                    Object extraData)
Description copied from interface: FilterVisitor
Visit Filter.EXCLUDE (often used during data structure transformations).

Specified by:
visit in interface FilterVisitor
Overrides:
visit in class FilterToSQL
Parameters:
filter - Filter.EXCLUDE.
extraData - Value object provided to visitor
Returns:
subclass supplied
See Also:
FilterVisitor#visit(ExcludeFilter, Object)} Writes the SQL for the IncludeFilter by writing "FALSE".

visit

public Object visit(IncludeFilter filter,
                    Object extraData)
Description copied from interface: FilterVisitor
Visit Filter.INCLUDE (often used during data structure transformations).

Specified by:
visit in interface FilterVisitor
Overrides:
visit in class FilterToSQL
Parameters:
filter - Filter.INCLUDE.
extraData - Value object provided to visitor
Returns:
subclass supplied
See Also:
FilterVisitor#visit(IncludeFilter, Object)} Writes the SQL for the IncludeFilter by writing "TRUE".

isLooseBBOXEnabled

public boolean isLooseBBOXEnabled()

setLooseBBOXEnabled

public void setLooseBBOXEnabled(boolean looseBBOXEnabled)

writeLiteral

protected void writeLiteral(Object literal)
                     throws IOException
Description copied from class: FilterToSQL
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)

Overrides:
writeLiteral in class FilterToSQL
Throws:
IOException

isFunctionEncodingEnabled

public boolean isFunctionEncodingEnabled()

setFunctionEncodingEnabled

public void setFunctionEncodingEnabled(boolean functionEncodingEnabled)

visitFunction

public boolean visitFunction(Function function,
                             Object extraData)
                      throws IOException
Performs custom visits for functions that cannot be encoded as functionName(p1, p2, ... pN).

Parameters:
function -
extraData -
Returns:
Throws:
IOException

visit

public Object visit(Function function,
                    Object extraData)
             throws RuntimeException
Description copied from class: FilterToSQL
Writes sql for a function expression. By default it will write the call by using the same arguments provided to the GeoTools function, subclasses should override on a case by case basis if this behavior is not the desired one.

Specified by:
visit in interface ExpressionVisitor
Overrides:
visit in class FilterToSQL
Throws:
RuntimeException - If an IO error occurs.
See Also:
FilterToSQL.getFunctionName(Function)

visit

public Object visit(BBOX filter,
                    Object extraData)
             throws RuntimeException
Specified by:
visit in interface FilterVisitor
Overrides:
visit in class FilterToSQL
Throws:
RuntimeException


Copyright © 1996-2014 Geotools. All Rights Reserved.