Java Doc for SQLEncoder.java in  » GIS » GeoTools-2.4.1 » org » geotools » filter » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoTools 2.4.1 » org.geotools.filter 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.geotools.filter.SQLEncoder

All known Subclasses:   org.geotools.filter.SQLEncoderOracle,  org.geotools.filter.SQLEncoderHsql,  org.geotools.filter.SQLEncoderMySQL,  org.geotools.filter.SQLEncoderPostgis,
SQLEncoder
public class SQLEncoder implements org.geotools.filter.FilterVisitor2(Code)
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


Field Summary
final protected static  StringIO_ERROR
    
protected  FilterCapabilitiescapabilities
    
protected static  Mapcomparisions
    
protected  Classcontext
     A type to use as context when encoding literal.
protected  FeatureTypefeatureType
    
protected  FIDMappermapper
    
protected  Writerout
     where to write the constructed string from visiting the filters.

Constructor Summary
public  SQLEncoder()
    
public  SQLEncoder(Writer out, Filter filter)
     Convenience constructor to perform the whole encoding process at once.

Method Summary
protected  FilterCapabilitiescreateFilterCapabilities()
     Sets the capabilities of this filter.
public  voidencode(Writer out, org.opengis.filter.Filter filter)
     Performs the encoding, sends the encoded sql to the writer passed in.
public  Stringencode(org.opengis.filter.Filter filter)
     Performs the encoding, returns a string of the encoded SQL.
Parameters:
  filter - the Filter to be encoded.
public  StringescapeName(String name)
     Surrounds a name with the SQL escape character.
public synchronized  FilterCapabilitiesgetCapabilities()
     Describes the capabilities of this encoder.
protected  StringgetColnameEscape()
     Gets the column escape name.
public  voidsetColnameEscape(String escape)
     Sets the escape character for the column name.
public  voidsetFIDMapper(FIDMapper mapper)
     Sets the FIDMapper that will be used in subsequente visit calls.
public  voidsetFeatureType(FeatureType featureType)
     Sets the featuretype the encoder is encoding sql for.

This is used for context for attribute expressions when encoding to sql.

public  voidsetSqlNameEscape(String escape)
     Sets the SQL name escape string.

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.

public  voidvisit(Filter filter)
     This should never be called.
public  voidvisit(BetweenFilter filter)
     Writes the SQL for the Between Filter.
public  voidvisit(LikeFilter filter)
     Writes the SQL for the Like Filter.
public  voidvisit(LogicFilter filter)
     Writes the SQL for the Logic Filter.
public  voidvisit(CompareFilter filter)
     Writes the SQL for a Compare Filter. DJB: note, postgis overwrites this implementation because of the way null is handled.
public  voidvisit(NullFilter filter)
     Writes the SQL for the Null Filter.
public  voidvisit(FidFilter filter)
     Encodes an FidFilter.
public  voidvisit(AttributeExpression expression)
     Writes the SQL for the attribute Expression.
public  voidvisit(Expression expression)
     Writes the SQL for the attribute Expression.
public  voidvisit(LiteralExpression expression)
    
public  voidvisit(GeometryFilter filter)
    
public  voidvisit(MathExpression expression)
     Writes the SQL for the Math Expression.
public  voidvisit(FunctionExpression expression)
     Writes sql for a function expression.
public  voidvisit(IncludeFilter filter)
    
public  voidvisit(ExcludeFilter filter)
    
protected  voidvisitLiteralGeometry(LiteralExpression expression)
    

Field Detail
IO_ERROR
final protected static String IO_ERROR(Code)
error message for exceptions



capabilities
protected FilterCapabilities capabilities(Code)
The filter types that this class can encode



comparisions
protected static Map comparisions(Code)
Map of comparison types to sql representation



context
protected Class context(Code)
A type to use as context when encoding literal. NOTE: when we move to geoapi filter visitor api, this will not be needed.



featureType
protected FeatureType featureType(Code)
the schmema the encoder will be used to be encode sql for



mapper
protected FIDMapper mapper(Code)
the fid mapper used to encode the fid filters



out
protected Writer out(Code)
where to write the constructed string from visiting the filters.




Constructor Detail
SQLEncoder
public SQLEncoder()(Code)
Empty constructor



SQLEncoder
public SQLEncoder(Writer out, Filter filter) throws SQLEncoderException(Code)
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




Method Detail
createFilterCapabilities
protected FilterCapabilities createFilterCapabilities()(Code)
Sets the capabilities of this filter. FilterCapabilities for this Filter



encode
public void encode(Writer out, org.opengis.filter.Filter filter) throws SQLEncoderException(Code)
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.



encode
public String encode(org.opengis.filter.Filter filter) throws SQLEncoderException(Code)
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.



escapeName
public String escapeName(String name)(Code)
Surrounds a name with the SQL escape character.
Parameters:
  name - DOCUMENT ME!



getCapabilities
public synchronized FilterCapabilities getCapabilities()(Code)
Describes the capabilities of this encoder.

Performs lazy creation of capabilities.

The capabilities supported by this encoder.



getColnameEscape
protected String getColnameEscape()(Code)
Gets the column escape name. the string to be used to properly escape a db's name.



setColnameEscape
public void setColnameEscape(String escape)(Code)
Sets the escape character for the column name.
Parameters:
  escape - The character to be used to escape database names.



setFIDMapper
public void setFIDMapper(FIDMapper mapper)(Code)
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 -



setFeatureType
public void setFeatureType(FeatureType featureType)(Code)
Sets the featuretype the encoder is encoding sql for.

This is used for context for attribute expressions when encoding to sql.


Parameters:
  featureType -



setSqlNameEscape
public void setSqlNameEscape(String escape)(Code)
Sets the SQL name escape string.

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



visit
public void visit(Filter filter)(Code)
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.



visit
public void visit(BetweenFilter filter) throws RuntimeException(Code)
Writes the SQL for the Between Filter.
Parameters:
  filter - the Filter to be visited.
throws:
  RuntimeException - for io exception with writer



visit
public void visit(LikeFilter filter) throws UnsupportedOperationException(Code)
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.



visit
public void visit(LogicFilter filter) throws RuntimeException(Code)
Writes the SQL for the Logic Filter.
Parameters:
  filter - the logic statement to be turned into SQL.
throws:
  RuntimeException - for io exception with writer



visit
public void visit(CompareFilter filter) throws RuntimeException(Code)
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



visit
public void visit(NullFilter filter) throws RuntimeException(Code)
Writes the SQL for the Null Filter.
Parameters:
  filter - the null filter to be written to SQL.
throws:
  RuntimeException - for io exception with writer



visit
public void visit(FidFilter filter)(Code)
Encodes an FidFilter.
Parameters:
  filter -
throws:
  RuntimeException - DOCUMENT ME!
See Also:   org.geotools.filter.SQLEncoder.visit(org.geotools.filter.FidFilter)



visit
public void visit(AttributeExpression expression) throws RuntimeException(Code)
Writes the SQL for the attribute Expression.
Parameters:
  expression - the attribute to turn to SQL.
throws:
  RuntimeException - for io exception with writer



visit
public void visit(Expression expression)(Code)
Writes the SQL for the attribute Expression.
Parameters:
  expression - the attribute to turn to SQL.



visit
public void visit(LiteralExpression expression) throws RuntimeException(Code)
Export the contents of a Literal Expresion
Parameters:
  expression - the Literal to export
throws:
  RuntimeException - for io exception with writer



visit
public void visit(GeometryFilter filter)(Code)

See Also:   org.geotools.filter.FilterVisitor.visit(org.geotools.filter.GeometryFilter)



visit
public void visit(MathExpression expression) throws RuntimeException(Code)
Writes the SQL for the Math Expression.
Parameters:
  expression - the Math phrase to be written.
throws:
  RuntimeException - for io problems



visit
public void visit(FunctionExpression expression) throws UnsupportedOperationException(Code)
Writes sql for a function expression. Not currently supported.
Parameters:
  expression - a function expression
throws:
  UnsupportedOperationException - every time, this isn't supported.



visit
public void visit(IncludeFilter filter)(Code)



visit
public void visit(ExcludeFilter filter)(Code)



visitLiteralGeometry
protected void visitLiteralGeometry(LiteralExpression expression) throws IOException(Code)
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!



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.