Encodes a filter into a SQL WHERE statement. It should hopefully be generic
enough that any SQL database will work with it, though it has only been
tested with MySQL and Postgis. This generic SQL encoder should eventually
be able to encode all filters except Geometry Filters (currently
LikeFilters are not yet fully implemented, but when they are they should be
generic enough). This is because the OGC's SFS for SQL document specifies
two ways of doing SQL databases, one with native geometry types and one
without. To implement an encoder for one of the two types simply subclass
off of this encoder and put in the proper GeometryFilter visit method. Then
add the filter types supported to the capabilities in the static
capabilities.addType block.
author: Chris Holmes, TOPP
The value of this string is prefixed and appended to table schema names,
table names and column names in an SQL statement to support mixed-case
and non-English names.
Convenience constructor to perform the whole encoding process at once.
Parameters: out - the writer to encode the SQL to. Parameters: filter - the Filter to be encoded. throws: SQLEncoderException - If there were problems encoding
Performs the encoding, sends the encoded sql to the writer passed in.
Parameters: out - the writer to encode the SQL to. Parameters: filter - the Filter to be encoded. throws: SQLEncoderException - If filter type not supported, or if therewere io problems.
Performs the encoding, returns a string of the encoded SQL.
Parameters: filter - the Filter to be encoded. the string of the SQL where statement. throws: SQLEncoderException - If filter type not supported, or if therewere io problems.
Sets the FIDMapper that will be used in subsequente visit calls. There
must be a FIDMapper in order to invoke the FIDFilter encoder.
Parameters: mapper -
The value of this string is prefixed and appended to table schema names,
table names and column names in an SQL statement to support mixed-case
and non-English names. Without this, the DBMS may assume a mixed-case
name in the query should be treated as upper-case and an SQLCODE of
-204 or 206 may result if the name is not found.
Typically this is the double-quote character, ", but may not be for all
databases.
For example, consider the following query:
SELECT Geom FROM Spear.ArchSites May be interpreted by the database as:
SELECT GEOM FROM SPEAR.ARCHSITES If the column and table names were
actually created using mixed-case, the query needs to be specified as:
SELECT "Geom" from "Spear"."ArchSites"
Parameters: escape - the character to be used to escape database names
This should never be called. This can only happen if a subclass of
AbstractFilter failes to implement its own version of
accept(FilterVisitor);
Parameters: filter - The filter to visit throws: RuntimeException - for IO Encoding problems.
Writes the SQL for the Like Filter. Assumes the current java
implemented wildcards for the Like Filter: . for multi and .? for
single. And replaces them with the SQL % and _, respectively. Currently
does nothing, and should not be called, not included in the
capabilities.
Parameters: filter - the Like Filter to be visited. throws: UnsupportedOperationException - always, as likes aren'timplemented yet.
Writes the SQL for the Logic Filter.
Parameters: filter - the logic statement to be turned into SQL. throws: RuntimeException - for io exception with writer
Writes the SQL for a Compare Filter.
DJB: note, postgis overwrites this implementation because of the way
null is handled. This is for filters and filters
are handled. They will come here with "property = null".
NOTE:
SELECT * FROM
WHERE isnull; -- postgresql
SELECT * FROM
WHERE isnull(); -- oracle???
Parameters: filter - the comparison to be turned into SQL. throws: RuntimeException - for io exception with writer
Writes the SQL for the attribute Expression.
Parameters: expression - the attribute to turn to SQL. throws: RuntimeException - for io exception with writer
Writes sql for a function expression. Not currently supported.
Parameters: expression - a function expression throws: UnsupportedOperationException - every time, this isn't supported.
Subclasses must implement this method in order to encode geometry
filters according to the specific database implementation
Parameters: expression - throws: IOException - DOCUMENT ME! throws: RuntimeException - DOCUMENT ME!