📄 sqlencoder.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.4.2_13) on Tue Jun 05 11:36:29 GMT-05:00 2007 --><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><TITLE>SQLEncoder (Geotools 2.3.x 2.3.2 API)</TITLE><META NAME="keywords" CONTENT="org.geotools.filter.SQLEncoder class"><META NAME="keywords" CONTENT="IO_ERROR"><META NAME="keywords" CONTENT="capabilities"><META NAME="keywords" CONTENT="comparisions"><META NAME="keywords" CONTENT="out"><META NAME="keywords" CONTENT="mapper"><META NAME="keywords" CONTENT="setFIDMapper()"><META NAME="keywords" CONTENT="createFilterCapabilities()"><META NAME="keywords" CONTENT="encode()"><META NAME="keywords" CONTENT="getCapabilities()"><META NAME="keywords" CONTENT="visit()"><META NAME="keywords" CONTENT="visitLiteralGeometry()"><META NAME="keywords" CONTENT="setSqlNameEscape()"><META NAME="keywords" CONTENT="setColnameEscape()"><META NAME="keywords" CONTENT="getColnameEscape()"><META NAME="keywords" CONTENT="escapeName()"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){ parent.document.title="SQLEncoder (Geotools 2.3.x 2.3.2 API)";}</SCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/SQLEncoder.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../org/geotools/filter/SortOrder.html" title="class in org.geotools.filter"><B>PREV CLASS</B></A> <A HREF="../../../org/geotools/filter/SQLEncoderHsql.html" title="class in org.geotools.filter"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" target="_top"><B>FRAMES</B></A> <A HREF="SQLEncoder.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--></SCRIPT><NOSCRIPT> <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">org.geotools.filter</FONT><BR>Class SQLEncoder</H2><PRE><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A> <IMG SRC="../../../resources/inherit.gif" ALT="extended by"><B>SQLEncoder</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../../org/geotools/filter/FilterVisitor.html" title="interface in org.geotools.filter">FilterVisitor</A></DD></DL><DL><DT><B>Direct Known Subclasses:</B> <DD><A HREF="../../../org/geotools/data/db2/filter/SQLEncoderDB2.html" title="class in org.geotools.data.db2.filter">SQLEncoderDB2</A>, <A HREF="../../../org/geotools/filter/SQLEncoderHsql.html" title="class in org.geotools.filter">SQLEncoderHsql</A>, <A HREF="../../../org/geotools/filter/SQLEncoderMySQL.html" title="class in org.geotools.filter">SQLEncoderMySQL</A>, <A HREF="../../../org/geotools/filter/SQLEncoderOracle.html" title="class in org.geotools.filter">SQLEncoderOracle</A>, <A HREF="../../../org/geotools/filter/SQLEncoderPostgis.html" title="class in org.geotools.filter">SQLEncoderPostgis</A>, <A HREF="../../../org/geotools/arcsde/filter/SQLEncoderSDE.html" title="class in org.geotools.arcsde.filter">SQLEncoderSDE</A></DD></DL><HR><DL><DT>public class <B>SQLEncoder</B><DT>extends <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A><DT>implements <A HREF="../../../org/geotools/filter/FilterVisitor.html" title="interface in org.geotools.filter">FilterVisitor</A></DL><P>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.<P><P><DL><DT><B>Author:</B></DT> <DD>Chris Holmes, TOPP</DD><DT><B>Module:</B></DT><DD><CODE><B>module/main</B></CODE> (<A HREF="http://maven.geotools.fr/repository/org/geotools/gt2-main/"><CODE>gt2-main.jar</CODE></A>) (<A HREF="http://maven.geotools.fr/reports/main/index.html">Maven report</A>) (<A HREF="http://svn.geotools.org/geotools/tags/2.3.2/module/main/src/org/geotools/filter/SQLEncoder.java">SVN head</A>)</DD><DT><B>'TODO:'</B></DT> <DD>TODO: Implement LikeFilter encoding, need to figure out escape chars, the rest of the code should work right. Once fixed be sure to add the LIKE type to capabilities, so others know that they can be encoded., REVISIT: need to figure out exceptions, we're currently eating io errors, which is bad. Probably need a generic visitor exception.</DD></DL><HR><P><!-- ======== NESTED CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Field Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected <A HREF="../../../org/geotools/filter/FilterCapabilities.html" title="class in org.geotools.filter">FilterCapabilities</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/geotools/filter/SQLEncoder.html#capabilities">capabilities</A></B></CODE><BR> The filter types that this class can encode</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected static <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/util/Map.html" title="class or interface in java.util">Map</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/geotools/filter/SQLEncoder.html#comparisions">comparisions</A></B></CODE><BR> Map of comparison types to sql representation</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected static <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/geotools/filter/SQLEncoder.html#IO_ERROR">IO_ERROR</A></B></CODE><BR> error message for exceptions</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected <A HREF="../../../org/geotools/data/jdbc/fidmapper/FIDMapper.html" title="interface in org.geotools.data.jdbc.fidmapper">FIDMapper</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/geotools/filter/SQLEncoder.html#mapper">mapper</A></B></CODE><BR> the fid mapper used to encode the fid filters</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/io/Writer.html" title="class or interface in java.io">Writer</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/geotools/filter/SQLEncoder.html#out">out</A></B></CODE><BR> where to write the constructed string from visiting the filters.</TD></TR></TABLE> <!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../org/geotools/filter/SQLEncoder.html#SQLEncoder()">SQLEncoder</A></B>()</CODE><BR> Empty constructor</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../org/geotools/filter/SQLEncoder.html#SQLEncoder(java.io.Writer, org.geotools.filter.Filter)">SQLEncoder</A></B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/io/Writer.html" title="class or interface in java.io">Writer</A> out, <A HREF="../../../org/geotools/filter/Filter.html" title="interface in org.geotools.filter">Filter</A> filter)</CODE><BR> Convenience constructor to perform the whole encoding process at once.</TD></TR></TABLE> <!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected <A HREF="../../../org/geotools/filter/FilterCapabilities.html" title="class in org.geotools.filter">FilterCapabilities</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/geotools/filter/SQLEncoder.html#createFilterCapabilities()">createFilterCapabilities</A></B>()</CODE><BR> Sets the capabilities of this filter.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/geotools/filter/SQLEncoder.html#encode(org.geotools.filter.Filter)">encode</A></B>(<A HREF="../../../org/geotools/filter/Filter.html" title="interface in org.geotools.filter">Filter</A> filter)</CODE><BR> Performs the encoding, returns a string of the encoded SQL.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/geotools/filter/SQLEncoder.html#encode(java.io.Writer, org.geotools.filter.Filter)">encode</A></B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/io/Writer.html" title="class or interface in java.io">Writer</A> out, <A HREF="../../../org/geotools/filter/Filter.html" title="interface in org.geotools.filter">Filter</A> filter)</CODE><BR> Performs the encoding, sends the encoded sql to the writer passed in.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/geotools/filter/SQLEncoder.html#escapeName(java.lang.String)">escapeName</A></B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> name)</CODE><BR> Surrounds a name with the SQL escape character.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../../org/geotools/filter/FilterCapabilities.html" title="class in org.geotools.filter">FilterCapabilities</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/geotools/filter/SQLEncoder.html#getCapabilities()">getCapabilities</A></B>()</CODE><BR> Describes the capabilities of this encoder.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -