|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.filter.SQLEncoder
public class SQLEncoder
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.
Field Summary | |
---|---|
protected FilterCapabilities |
capabilities
Deprecated. The filter types that this class can encode |
protected static java.util.Map |
comparisions
Deprecated. Map of comparison types to sql representation |
protected java.lang.Class |
context
Deprecated. A type to use as context when encoding literal. |
protected org.opengis.feature.simple.SimpleFeatureType |
featureType
Deprecated. the schmema the encoder will be used to be encode sql for |
protected static java.lang.String |
IO_ERROR
Deprecated. error message for exceptions |
protected FIDMapper |
mapper
Deprecated. the fid mapper used to encode the fid filters |
protected java.io.Writer |
out
Deprecated. where to write the constructed string from visiting the filters. |
Constructor Summary | |
---|---|
SQLEncoder()
Deprecated. Empty constructor |
|
SQLEncoder(java.io.Writer out,
Filter filter)
Deprecated. Convenience constructor to perform the whole encoding process at once. |
Method Summary | |
---|---|
protected FilterCapabilities |
createFilterCapabilities()
Deprecated. Sets the capabilities of this filter. |
java.lang.String |
encode(org.opengis.filter.expression.Expression expression)
Deprecated. Performs the encoding, returns a string of the encoded SQL. |
java.lang.String |
encode(org.opengis.filter.Filter filter)
Deprecated. Performs the encoding, returns a string of the encoded SQL. |
void |
encode(java.io.Writer out,
org.opengis.filter.expression.Expression expression)
Deprecated. |
void |
encode(java.io.Writer out,
org.opengis.filter.Filter filter)
Deprecated. Performs the encoding, sends the encoded sql to the writer passed in. |
java.lang.String |
escapeName(java.lang.String name)
Deprecated. Surrounds a name with the SQL escape character. |
FilterCapabilities |
getCapabilities()
Deprecated. Describes the capabilities of this encoder. |
protected java.lang.String |
getColnameEscape()
Deprecated. the escapeName method is preferred over this, it automatically returns the name properly escaped, since that's all getColnameEscape was being used for. |
FIDMapper |
getFIDMapper()
Deprecated. |
void |
setColnameEscape(java.lang.String escape)
Deprecated. Use setSqlNameEscape instead, as it is more aptly named. |
void |
setFeatureType(org.opengis.feature.simple.SimpleFeatureType featureType)
Deprecated. Sets the featuretype the encoder is encoding sql for. |
void |
setFIDMapper(FIDMapper mapper)
Deprecated. Sets the FIDMapper that will be used in subsequente visit calls. |
void |
setSqlNameEscape(java.lang.String escape)
Deprecated. Sets the SQL name escape string. |
void |
visit(AttributeExpression expression)
Deprecated. Writes the SQL for the attribute Expression. |
void |
visit(BetweenFilter filter)
Deprecated. Writes the SQL for the Between Filter. |
void |
visit(CompareFilter filter)
Deprecated. Writes the SQL for a Compare Filter. |
void |
visit(org.opengis.filter.ExcludeFilter filter)
Deprecated. |
void |
visit(Expression expression)
Deprecated. Writes the SQL for the attribute Expression. |
void |
visit(FidFilter filter)
Deprecated. Encodes an FidFilter. |
void |
visit(Filter filter)
Deprecated. This should never be called. |
void |
visit(FunctionExpression expression)
Deprecated. Writes sql for a function expression. |
void |
visit(GeometryFilter filter)
Deprecated. Called when accept is called on a Geometry Filter. |
void |
visit(org.opengis.filter.IncludeFilter filter)
Deprecated. |
void |
visit(LikeFilter filter)
Deprecated. Writes the SQL for the Like Filter. |
void |
visit(LiteralExpression expression)
Deprecated. Export the contents of a Literal Expresion |
void |
visit(LogicFilter filter)
Deprecated. Writes the SQL for the Logic Filter. |
void |
visit(MathExpression expression)
Deprecated. Writes the SQL for the Math Expression. |
void |
visit(NullFilter filter)
Deprecated. Writes the SQL for the Null Filter. |
protected void |
visitLiteralGeometry(LiteralExpression expression)
Deprecated. Subclasses must implement this method in order to encode geometry filters according to the specific database implementation |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String IO_ERROR
protected FilterCapabilities capabilities
protected static java.util.Map comparisions
protected java.io.Writer out
protected FIDMapper mapper
protected org.opengis.feature.simple.SimpleFeatureType featureType
protected java.lang.Class context
Constructor Detail |
---|
public SQLEncoder()
public SQLEncoder(java.io.Writer out, Filter filter) throws SQLEncoderException
out
- the writer to encode the SQL to.filter
- the Filter to be encoded.
SQLEncoderException
- If there were problems encodingMethod Detail |
---|
public void setFeatureType(org.opengis.feature.simple.SimpleFeatureType featureType)
This is used for context for attribute expressions when encoding to sql.
featureType
- public void setFIDMapper(FIDMapper mapper)
mapper
- public FIDMapper getFIDMapper()
protected FilterCapabilities createFilterCapabilities()
public void encode(java.io.Writer out, org.opengis.filter.Filter filter) throws SQLEncoderException
out
- the writer to encode the SQL to.filter
- the Filter to be encoded.
SQLEncoderException
- If filter type not supported, or if there
were io problems.public java.lang.String encode(org.opengis.filter.Filter filter) throws SQLEncoderException
filter
- the Filter to be encoded.
SQLEncoderException
- If filter type not supported, or if there
were io problems.public void encode(java.io.Writer out, org.opengis.filter.expression.Expression expression) throws SQLEncoderException
SQLEncoderException
public java.lang.String encode(org.opengis.filter.expression.Expression expression) throws SQLEncoderException
expression
- the expression to be encoded.
SQLEncoderException
- If expression type not supported, or if there
were io problems.public FilterCapabilities getCapabilities()
Performs lazy creation of capabilities.
public void visit(Filter filter)
visit
in interface FilterVisitor
filter
- The filter to visit
java.lang.RuntimeException
- for IO Encoding problems.public void visit(BetweenFilter filter) throws java.lang.RuntimeException
visit
in interface FilterVisitor
filter
- the Filter to be visited.
java.lang.RuntimeException
- for io exception with writerpublic void visit(LikeFilter filter) throws java.lang.UnsupportedOperationException
visit
in interface FilterVisitor
filter
- the Like Filter to be visited.
java.lang.UnsupportedOperationException
- always, as likes aren't
implemented yet.public void visit(LogicFilter filter) throws java.lang.RuntimeException
visit
in interface FilterVisitor
filter
- the logic statement to be turned into SQL.
java.lang.RuntimeException
- for io exception with writerpublic void visit(CompareFilter filter) throws java.lang.RuntimeException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |