Class SelectionClauseWriter
java.lang.Object
org.apache.sis.internal.filter.Visitor<AbstractFeature,SelectionClause>
org.apache.sis.internal.sql.feature.SelectionClauseWriter
Converter from filters/expressions to the
WHERE part of SQL statement.
This base class handles ANSI compliant SQL. Subclasses can add database-specific syntax.
As soon as a filter or expression is not supported by this interpreter, the writing of the SQL statement stops and next filters operations will be executed with Java code.
Implementation notes
For now, we over-use parenthesis to ensure consistent operator priority. In the future, we could evolve this component to provide more elegant transcription of filter groups.Thread-safety
Instances of this classes shall be unmodified after construction and thus thread-safe. Information about the state of a conversion to SQL is stored inSelectionClause.- Since:
- 1.1
- Version:
- 1.1
- Author:
- Alexis Manin (Geomatys), Martin Desruisseaux (Geomatys)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final SelectionClauseWriterThe default instance. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new converter initialized to the same handlers than the specified converter. -
Method Summary
Modifier and TypeMethodDescriptionprotected SelectionClauseWriterCreates a new converter of the same class thanthisand initialized with the same data.protected final voidtypeNotFound(Enum<?> type, Filter<AbstractFeature> filter, SelectionClause sql) Invoked when an unsupported filter is found.protected final voidtypeNotFound(String type, Expression<AbstractFeature, ?> expression, SelectionClause sql) Invoked when an unsupported expression is found.protected final voidwriteBinaryOperator(SelectionClause sql, Filter<AbstractFeature> filter, String operator) Writes the expressions of a filter as a binary operator.Methods inherited from class org.apache.sis.internal.filter.Visitor
getExpressionHandler, getFilterHandler, removeFilterHandlers, setBinaryComparisonHandlers, setBinaryTemporalHandlers, setExpressionHandler, setFilterHandler, setLogicalHandlers, setMathHandlers, setNullAndNilHandlers, setSpatialHandlers, visit, visit
-
Field Details
-
DEFAULT
The default instance.
-
-
Constructor Details
-
SelectionClauseWriter
Creates a new converter initialized to the same handlers than the specified converter. The given source is usuallyDEFAULT.- Parameters:
source- the converter from which to copy the handlers.
-
-
Method Details
-
duplicate
Creates a new converter of the same class thanthisand initialized with the same data. This method is invoked before to remove handlers for functions that are unsupported on the target database software.- Returns:
- a converter initialized to a copy of
this.
-
typeNotFound
protected final void typeNotFound(Enum<?> type, Filter<AbstractFeature> filter, SelectionClause sql) Invoked when an unsupported filter is found. The SQL string is marked as invalid and may be truncated (later) to the length that it has the last time that it was valid.- Overrides:
typeNotFoundin classVisitor<AbstractFeature,SelectionClause> - Parameters:
type- the filter type which has not been found, ornullif is null.filter- the filter (may benull).sql- where to write the result of all actions.
-
typeNotFound
protected final void typeNotFound(String type, Expression<AbstractFeature, ?> expression, SelectionClause sql) Invoked when an unsupported expression is found. The SQL string is marked as invalid and may be truncated (later) to the length that it has the last time that it was valid.- Overrides:
typeNotFoundin classVisitor<AbstractFeature,SelectionClause> - Parameters:
type- the expression type which has not been found, ornullif is null.expression- the expression (may benull).sql- where to write the result of all actions.
-
writeBinaryOperator
protected final void writeBinaryOperator(SelectionClause sql, Filter<AbstractFeature> filter, String operator) Writes the expressions of a filter as a binary operator. The filter must have exactly two expressions, otherwise the SQL will be declared invalid.- Parameters:
sql- where to append the SQL clause.filter- the filter for which to append the expressions.operator- the operator to write between the expressions.
-