Package org.geotools.data.db2
Class DB2FilterToSQL
- Object
-
- FilterToSQL
-
- PreparedFilterToSQL
-
- 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:
- GEOMETRY_BBOX
- GEOMETRY_CONTAINS
- GEOMETRY_CROSSES
- GEOMETRY_DISJOINT
- GEOMETRY_EQUALS
- GEOMETRY_INTERSECTS
- GEOMETRY_OVERLAPS
- GEOMETRY_TOUCHES
- GEOMETRY_WITHIN
- GEOMETRY_DWITHIN
- Author:
- Mueller Christian
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class FilterToSQL
FilterToSQL.FieldEncoder
-
-
Field Summary
-
Fields inherited from class PreparedFilterToSQL
descriptors, dialect, dimensions, literalTypes, literalValues, SRIDs
-
Fields inherited from class FilterToSQL
capabilities, currentDimension, currentGeometry, currentSRID, databaseSchema, encodingFunction, escapeBackslash, featureType, fieldEncoder, filterFactory, inEncodingEnabled, inline, IO_ERROR, out, primaryKey, sqlNameEscape
-
-
Constructor Summary
Constructors Constructor Description DB2FilterToSQL(Writer out)DB2FilterToSQL(PreparedStatementSQLDialect dialect)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddSelectivity()protected FilterCapabilitiescreateFilterCapabilities()Sets the DB2 filter capabilities.Stringdb2Geom(Geometry geom)Construct a geometry from the WKT representation of a geometryHashMap<Class<?>,String>getPredicateMap()booleanisFunctionEncodingEnabled()booleanisLooseBBOXEnabled()voidsetFunctionEncodingEnabled(boolean functionEncodingEnabled)voidsetLooseBBOXEnabled(boolean looseBBOXEnabled)voidsetSelectivityClause(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.Objectvisit(ExcludeFilter filter, Object extraData)VisitFilter.EXCLUDE(often used during data structure transformations).Objectvisit(Function function, Object extraData)Writes sql for a function expression.Objectvisit(IncludeFilter filter, Object extraData)VisitFilter.INCLUDE(often used during data structure transformations).protected ObjectvisitBinarySpatialOperator(BinarySpatialOperator filter, Expression e1, Expression e2, boolean swapped, Object extraData)protected ObjectvisitBinarySpatialOperator(BinarySpatialOperator filter, Expression e1, Expression e2, Object extraData)Handles the more general case of two generic expressions.protected ObjectvisitBinarySpatialOperator(BinarySpatialOperator filter, PropertyName property, Literal geometry, boolean swapped, Object extraData)Handles the common case of a PropertyName,Literal geometry binary spatial operator.booleanvisitFunction(Function function, Object extraData)Performs custom visits for functions that cannot be encoded asfunctionName(p1, p2, ... pN).voidvisitLiteralGeometry(Literal expression)Construct the appropriate geometry type from the WKT representation of a literal expressionprotected voidwriteLiteral(Object literal)Writes out a non null, non geometry literal.-
Methods inherited from class PreparedFilterToSQL
convertEnvelopeToPolygon, getDescriptors, getDimensions, getLiteralTypes, getLiteralValues, getSRIDs, isPrepareEnabled, setPrepareEnabled, visit, visit
-
Methods inherited from class FilterToSQL
cast, encode, encode, encodeBinaryComparisonOperator, encodeToString, encodeToString, escapeLiteral, escapeName, evaluateLiteral, getCapabilities, getDatabaseSchema, getDistanceInNativeUnits, getExpressionType, getFeatureType, getFunctionName, getFunctionReturnType, getParameter, getPrimaryKey, getSqlNameEscape, isBinaryExpression, isEscapeBackslash, isInEncodingEnabled, processLikeLeftOperand, setCapabilities, setDatabaseSchema, setEscapeBackslash, setFeatureType, setFieldEncoder, setInEncodingEnabled, 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, visit, visit, visitBinaryComparisonOperator, visitBinarySpatialOperator, visitBinaryTemporalOperator, visitBinaryTemporalOperator, visitBinaryTemporalOperator, visitInFunction, visitLiteralTimePeriod, visitNullFilter, writeBinaryExpression, writeBinaryExpressionMember
-
-
-
-
Constructor Detail
-
DB2FilterToSQL
public DB2FilterToSQL(PreparedStatementSQLDialect dialect)
-
DB2FilterToSQL
public DB2FilterToSQL(Writer out)
-
-
Method Detail
-
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:
createFilterCapabilitiesin classFilterToSQL- 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:FilterToSQLHandles the common case of a PropertyName,Literal geometry binary spatial operator.- Overrides:
visitBinarySpatialOperatorin classFilterToSQL
-
visitBinarySpatialOperator
protected Object visitBinarySpatialOperator(BinarySpatialOperator filter, Expression e1, Expression e2, Object extraData)
Description copied from class:FilterToSQLHandles the more general case of two generic expressions.The most common case is two PropertyName expressions, which happens during a spatial join.
- Overrides:
visitBinarySpatialOperatorin classFilterToSQL
-
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:
visitLiteralGeometryin classFilterToSQL- 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:FilterVisitorVisitFilter.EXCLUDE(often used during data structure transformations).- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL- Parameters:
filter- the filter to be visitedextraData- Value object provided to visitor- Returns:
- subclass supplied
-
visit
public Object visit(IncludeFilter filter, Object extraData)
Description copied from interface:FilterVisitorVisitFilter.INCLUDE(often used during data structure transformations).- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL- Parameters:
filter- the filter to be visitedextraData- Value object provided to visitor- Returns:
- subclass supplied
-
isLooseBBOXEnabled
public boolean isLooseBBOXEnabled()
-
setLooseBBOXEnabled
public void setLooseBBOXEnabled(boolean looseBBOXEnabled)
-
writeLiteral
protected void writeLiteral(Object literal) throws IOException
Description copied from class:FilterToSQLWrites 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:
writeLiteralin classFilterToSQL- 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 asfunctionName(p1, p2, ... pN).- Throws:
IOException
-
visit
public Object visit(Function function, Object extraData) throws RuntimeException
Description copied from class:FilterToSQLWrites 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:
visitin interfaceExpressionVisitor- Overrides:
visitin classFilterToSQL- Parameters:
function- a function expression- Throws:
RuntimeException- If an IO error occurs.- See Also:
FilterToSQL.getFunctionName(Function)
-
-