Class 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
    • 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.
      • 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
      • 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()
      • 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).
        Throws:
        IOException