org.deegree_impl.services.wfs.filterencoding
Class AbstractSQLBuilder

java.lang.Object
  extended byorg.deegree_impl.services.wfs.filterencoding.AbstractSQLBuilder
Direct Known Subclasses:
GMLDBSQLBuilder, MySQLSQLBuilder, OracleSQLBuilder, PointDBSQLBuilder, PostgisSQLBuilder

public abstract class AbstractSQLBuilder
extends java.lang.Object

Abstract superclass for the generation of SQL-fragments from a Filter object. FIXME: - featureFilter2SQL () lacks configurability (should be moved to the concrete implementation maybe) - function2SQL () lacks function name checks (might break the generated SQL)

Version:
14.09.2002
Author:
Markus Schneider, Andreas Poth
See Also:
Filter

Field Summary
private  java.lang.StringBuffer closedBr
           
protected  FeatureType ft
           
protected  boolean not
           
private  java.util.Stack sqlFrag
           
private  java.util.Stack usedProperties
           
 
Constructor Summary
AbstractSQLBuilder(FeatureType ft)
           
 
Method Summary
 java.lang.StringBuffer arithmeticExpression2SQL(ArithmeticExpression expr)
          Generates a SQL-fragment for the given object.
 java.lang.StringBuffer comparisonOperation2SQL(ComparisonOperation operation)
          Generates a SQL-fragment for the given object.
 java.lang.String complexFilter2SQL(ComplexFilter filter)
          Generates a SQL-fragment for the given object.
 java.lang.StringBuffer expression2SQL(Expression expr)
          Generates a SQL-fragment for the given object.
 java.lang.String featureFilter2SQL(FeatureFilter filter)
          Generates a SQL-fragment for the given object.
 java.lang.String filter2SQL(Filter filter)
          Generates a SQL-fragment for the given object.
abstract  java.lang.String formatDate(java.lang.String time)
          abstract method that have to be implemented by extending classes to format a database vendor specific date
abstract  java.lang.String formatTime(java.lang.String time)
          abstract method that have to be implemented by extending classes to format a database vendor specific time
abstract  java.lang.String formatTimestamp(java.lang.String time)
          abstract method that have to be implemented by extending classes to format a database vendor specific timestamp
 java.lang.StringBuffer function2SQL(Function function)
          Generates a SQL-fragment for the given object.
private  java.lang.StringBuffer getRelatedTableSQL(java.lang.String targetTable, java.lang.String property)
           
private  java.lang.String getTableName(java.lang.String prop)
          extracts the table name from a property. it is assumed that the property name is constructed like this: table.propertyname or schema.table.propertyname.
 java.lang.StringBuffer literal2SQL(Literal literal)
          Generates a SQL-fragment for the given object.
 java.lang.StringBuffer logicalOperation2SQL(LogicalOperation operation)
          Generates a SQL-fragment for the given object.
 java.lang.StringBuffer operation2SQL(Operation operation)
          Generates a SQL-fragment for the given object.
 java.lang.StringBuffer propertyIsBetweenOperation2SQL(PropertyIsBetweenOperation operation)
          Generates a SQL-fragment for the given object.
 java.lang.StringBuffer propertyIsCOMPOperation2SQL(PropertyIsCOMPOperation operation)
          Generates a SQL-fragment for the given object.
 java.lang.StringBuffer propertyIsLikeOperation2SQL(PropertyIsLikeOperation operation)
          Generates a SQL-fragment for the given object.
 java.lang.StringBuffer propertyIsNullOperation2SQL(PropertyIsNullOperation operation)
          Generates a SQL-fragment for the given object.
 java.lang.StringBuffer propertyName2SQL(PropertyName propertyName)
          Generates a SQL-fragment for the given object.
abstract  java.lang.StringBuffer spatialOperation2SQL(SpatialOperation operation)
          Generates a SQL-fragment for the given object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ft

protected FeatureType ft

usedProperties

private java.util.Stack usedProperties

closedBr

private java.lang.StringBuffer closedBr

sqlFrag

private java.util.Stack sqlFrag

not

protected boolean not
Constructor Detail

AbstractSQLBuilder

public AbstractSQLBuilder(FeatureType ft)
Method Detail

filter2SQL

public java.lang.String filter2SQL(Filter filter)
                            throws java.lang.Exception
Generates a SQL-fragment for the given object.

Throws:
java.lang.Exception

featureFilter2SQL

public java.lang.String featureFilter2SQL(FeatureFilter filter)
Generates a SQL-fragment for the given object.


complexFilter2SQL

public java.lang.String complexFilter2SQL(ComplexFilter filter)
                                   throws java.lang.Exception
Generates a SQL-fragment for the given object.

Throws:
java.lang.Exception

operation2SQL

public java.lang.StringBuffer operation2SQL(Operation operation)
                                     throws java.lang.Exception
Generates a SQL-fragment for the given object.

Throws:
java.lang.Exception

spatialOperation2SQL

public abstract java.lang.StringBuffer spatialOperation2SQL(SpatialOperation operation)
                                                     throws java.lang.Exception
Generates a SQL-fragment for the given object. As this depends very much on the handling of geometry data by the concrete database in use, this method is abstract and must be overwritten by any implementation.

Throws:
java.lang.Exception

comparisonOperation2SQL

public java.lang.StringBuffer comparisonOperation2SQL(ComparisonOperation operation)
                                               throws java.lang.Exception
Generates a SQL-fragment for the given object.

Throws:
java.lang.Exception

propertyIsCOMPOperation2SQL

public java.lang.StringBuffer propertyIsCOMPOperation2SQL(PropertyIsCOMPOperation operation)
                                                   throws java.lang.Exception
Generates a SQL-fragment for the given object.

Throws:
java.lang.Exception

propertyIsLikeOperation2SQL

public java.lang.StringBuffer propertyIsLikeOperation2SQL(PropertyIsLikeOperation operation)
                                                   throws java.lang.Exception
Generates a SQL-fragment for the given object. Replacing and escape handling is based on a finite automaton with 2 states: (escapeMode) - ' is appended as \', \ is appended as \\ - every character (including the escapeChar) is simply appended - unset escapeMode (escapeMode is false) - ' is appended as \', \ is appended as \\ - escapeChar means: skip char, set escapeMode - wildCard means: append % - singleChar means: append ?

Throws:
java.lang.Exception

propertyIsNullOperation2SQL

public java.lang.StringBuffer propertyIsNullOperation2SQL(PropertyIsNullOperation operation)
                                                   throws java.lang.Exception
Generates a SQL-fragment for the given object.

Throws:
java.lang.Exception

propertyIsBetweenOperation2SQL

public java.lang.StringBuffer propertyIsBetweenOperation2SQL(PropertyIsBetweenOperation operation)
                                                      throws java.lang.Exception
Generates a SQL-fragment for the given object.

Throws:
java.lang.Exception

logicalOperation2SQL

public java.lang.StringBuffer logicalOperation2SQL(LogicalOperation operation)
                                            throws java.lang.Exception
Generates a SQL-fragment for the given object.

Throws:
java.lang.Exception

expression2SQL

public java.lang.StringBuffer expression2SQL(Expression expr)
                                      throws java.lang.Exception
Generates a SQL-fragment for the given object.

Throws:
java.lang.Exception

propertyName2SQL

public java.lang.StringBuffer propertyName2SQL(PropertyName propertyName)
                                        throws java.lang.Exception
Generates a SQL-fragment for the given object.

Throws:
java.lang.Exception

getRelatedTableSQL

private java.lang.StringBuffer getRelatedTableSQL(java.lang.String targetTable,
                                                  java.lang.String property)

literal2SQL

public java.lang.StringBuffer literal2SQL(Literal literal)
Generates a SQL-fragment for the given object.


formatDate

public abstract java.lang.String formatDate(java.lang.String time)
abstract method that have to be implemented by extending classes to format a database vendor specific date


formatTime

public abstract java.lang.String formatTime(java.lang.String time)
abstract method that have to be implemented by extending classes to format a database vendor specific time


formatTimestamp

public abstract java.lang.String formatTimestamp(java.lang.String time)
abstract method that have to be implemented by extending classes to format a database vendor specific timestamp


function2SQL

public java.lang.StringBuffer function2SQL(Function function)
                                    throws java.lang.Exception
Generates a SQL-fragment for the given object.

Throws:
java.lang.Exception

arithmeticExpression2SQL

public java.lang.StringBuffer arithmeticExpression2SQL(ArithmeticExpression expr)
                                                throws java.lang.Exception
Generates a SQL-fragment for the given object.

Throws:
java.lang.Exception

getTableName

private java.lang.String getTableName(java.lang.String prop)
extracts the table name from a property. it is assumed that the property name is constructed like this: table.propertyname or schema.table.propertyname. if no table is specified with a property name, the name of the feature types master table will be returned.