org.geotools.jdbc
Class PreparedFilterToSQL

Object
  extended by FilterToSQL
      extended by PreparedFilterToSQL
All Implemented Interfaces:
ExpressionVisitor, FilterVisitor
Direct Known Subclasses:
DB2FilterToSQL, OracleFilterToSQL, PostgisPSFilterToSql

public class PreparedFilterToSQL
extends FilterToSQL

Extension of FilterToSQL intended for use with prepared statements.

Each time a Literal is visited, a '?' is encoded, and the value and type of the literal are stored, available after the fact via getLiteralValues() and getLiteralTypes().

Author:
Justin Deoliveira, OpenGEO, Andrea Aime, OpenGEO
Module:
modules/library/jdbc (gt-jdbc.jar)

Field Summary
protected  Integer currentSRID
           
protected  PreparedStatementSQLDialect dialect
           
protected  List<Class> literalTypes
           
protected  List<Object> literalValues
          ordered list of literal values encountered and their types
protected  List<Integer> SRIDs
           
 
Fields inherited from class FilterToSQL
capabilities, encodingFunction, featureType, IO_ERROR, mapper, out
 
Constructor Summary
PreparedFilterToSQL()
          Deprecated. Use PreparedFilterToSQL(PreparedStatementSQLDialect) instead
PreparedFilterToSQL(PreparedStatementSQLDialect dialect)
          Contructor taking a reference to the SQL dialect, will use it to encode geometry placeholders
PreparedFilterToSQL(Writer out)
           
 
Method Summary
 List<Class> getLiteralTypes()
           
 List<Object> getLiteralValues()
           
 List<Integer> getSRIDs()
          Returns the list of native SRID for each literal that happens to be a geometry, or null otherwise
 boolean isPrepareEnabled()
          If true (default) a sql statement with literal placemarks is created, otherwise a normal statement is created
 void setPrepareEnabled(boolean prepareEnabled)
           
 Object visit(Id filter, Object extraData)
          Encodes an Id filter
 Object visit(Literal expression, Object context)
          Export the contents of a Literal Expresion
protected  Object visitBinarySpatialOperator(BinarySpatialOperator filter, Object extraData)
           
protected  Object visitBinarySpatialOperator(BinarySpatialOperator filter, PropertyName property, Literal geometry, boolean swapped, Object extraData)
          Subclasses should override this, the property and the geometry have already been separated out
 
Methods inherited from class FilterToSQL
createFilterCapabilities, encode, encode, encodeToString, encodeToString, escapeName, evaluateLiteral, getCapabilities, getFIDMapper, setCapabilities, setFeatureType, setFIDMapper, 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, visitBinaryComparisonOperator, visitLiteralGeometry, visitNullFilter, writeLiteral
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentSRID

protected Integer currentSRID

literalValues

protected List<Object> literalValues
ordered list of literal values encountered and their types


literalTypes

protected List<Class> literalTypes

SRIDs

protected List<Integer> SRIDs

dialect

protected PreparedStatementSQLDialect dialect
Constructor Detail

PreparedFilterToSQL

public PreparedFilterToSQL()
Deprecated. Use PreparedFilterToSQL(PreparedStatementSQLDialect) instead

Default constructor


PreparedFilterToSQL

public PreparedFilterToSQL(PreparedStatementSQLDialect dialect)
Contructor taking a reference to the SQL dialect, will use it to encode geometry placeholders

Parameters:
dialect -

PreparedFilterToSQL

public PreparedFilterToSQL(Writer out)
Method Detail

isPrepareEnabled

public boolean isPrepareEnabled()
If true (default) a sql statement with literal placemarks is created, otherwise a normal statement is created

Returns:

setPrepareEnabled

public void setPrepareEnabled(boolean prepareEnabled)

visit

public Object visit(Literal expression,
                    Object context)
             throws RuntimeException
Description copied from class: FilterToSQL
Export the contents of a Literal Expresion

Specified by:
visit in interface ExpressionVisitor
Overrides:
visit in class FilterToSQL
Parameters:
expression - the Literal to export
Throws:
RuntimeException - for io exception with writer

visit

public Object visit(Id filter,
                    Object extraData)
Encodes an Id filter

Specified by:
visit in interface FilterVisitor
Overrides:
visit in class FilterToSQL
Parameters:
filter - the
Throws:
RuntimeException - If there's a problem writing output

getLiteralValues

public List<Object> getLiteralValues()

getLiteralTypes

public List<Class> getLiteralTypes()

getSRIDs

public List<Integer> getSRIDs()
Returns the list of native SRID for each literal that happens to be a geometry, or null otherwise

Returns:

visitBinarySpatialOperator

protected Object visitBinarySpatialOperator(BinarySpatialOperator filter,
                                            Object extraData)
Overrides:
visitBinarySpatialOperator in class FilterToSQL
See Also:
FilterVisitor#visit()}

visitBinarySpatialOperator

protected Object visitBinarySpatialOperator(BinarySpatialOperator filter,
                                            PropertyName property,
                                            Literal geometry,
                                            boolean swapped,
                                            Object extraData)
Subclasses should override this, the property and the geometry have already been separated out

Parameters:
filter - the original filter to be encoded
property - the property name
geometry - the geometry name
swapped - if true, the operation is literal op name, if false it's the normal name op literal
extraData - the context


Copyright © 1996-2009 Geotools. All Rights Reserved.