|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.filter.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 java.io.Writer |
out
where to write the constructed string from visiting the filters. |
Constructor Summary | |
SQLEncoder()
Empty constructor |
|
SQLEncoder(java.io.Writer out,
Filter filter)
Convenience constructor to perform the whole encoding process at once. |
Method Summary | |
protected FilterCapabilities |
createFilterCapabilities()
Sets the capabilities of this filter. |
java.lang.String |
encode(Filter filter)
Performs the encoding, returns a string of the encoded SQL. |
void |
encode(java.io.Writer out,
Filter filter)
Performs the encoding, sends the encoded sql to the writer passed in. |
FilterCapabilities |
getCapabilities()
Describes the capabilities of this encoder. |
void |
visit(AttributeExpression expression)
Writes the SQL for the attribute Expression. |
void |
visit(BetweenFilter filter)
Writes the SQL for the Between Filter. |
void |
visit(CompareFilter filter)
Writes the SQL for a Compare Filter. |
void |
visit(Expression expression)
Writes the SQL for the attribute Expression. |
void |
visit(FidFilter filter)
This only exists the fulfill the interface - unless There is a way of determining the FID column in the database... |
void |
visit(Filter filter)
This should never be called. |
void |
visit(FunctionExpression expression)
Writes sql for a function expression. |
void |
visit(GeometryFilter filter)
Writes the SQL for the Geometry Filter. |
void |
visit(LikeFilter filter)
Writes the SQL for the Like Filter. |
void |
visit(LiteralExpression expression)
Export the contents of a Literal Expresion |
void |
visit(LogicFilter filter)
Writes the SQL for the Logic Filter. |
void |
visit(MathExpression expression)
Writes the SQL for the Math Expression. |
void |
visit(NullFilter filter)
Writes the SQL for the Null Filter. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.io.Writer out
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 |
protected FilterCapabilities createFilterCapabilities()
public void encode(java.io.Writer out, 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(Filter filter) throws SQLEncoderException
filter
- the Filter to be encoded.
SQLEncoderException
- If filter 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
visit
in interface FilterVisitor
filter
- the comparison to be turned into SQL.
java.lang.RuntimeException
- for io exception with writerpublic void visit(GeometryFilter filter)
visit
in interface FilterVisitor
filter
- the geometry logic to be turned into SQL.public void visit(NullFilter filter) throws java.lang.RuntimeException
visit
in interface FilterVisitor
filter
- the null filter to be written to SQL.
java.lang.RuntimeException
- for io exception with writerpublic void visit(FidFilter filter)
visit
in interface FilterVisitor
filter
- the Fid Filter.public void visit(AttributeExpression expression) throws java.lang.RuntimeException
visit
in interface FilterVisitor
expression
- the attribute to turn to SQL.
java.lang.RuntimeException
- for io exception with writerpublic void visit(Expression expression)
visit
in interface FilterVisitor
expression
- the attribute to turn to SQL.public void visit(LiteralExpression expression) throws java.lang.RuntimeException
visit
in interface FilterVisitor
expression
- the Literal to export
java.lang.RuntimeException
- for io exception with writerpublic void visit(MathExpression expression) throws java.lang.RuntimeException
visit
in interface FilterVisitor
expression
- the Math phrase to be written.
java.lang.RuntimeException
- for io problemspublic void visit(FunctionExpression expression) throws java.lang.UnsupportedOperationException
visit
in interface FilterVisitor
expression
- a function expression
java.lang.UnsupportedOperationException
- every time, this isn't supported.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |