Package org.geotools.filter.text.cql2
Class CQL
Object
CQL
Utility class to parse CQL predicates and expressions to GeoAPI
Filters and Expressions,
respectively.
CQL is an acronym for Contextual Query Language, a query predicate language whose syntax is similar to a SQL WHERE clause, defined as OGC Common Query Language in clause 6.2.2 of the OGC Catalog Service for Web, version 2.0.1 implementation specification.
This class provides three methods, toFilter(String), toExpression(String) and
toFilterList(String); and an overloaded version of each one for the user to provide a FilterFactory
implementation to use.
Usage
Here are some usage examples. Refer to the <a href="href="http://docs.geotools.org/latest/userguide/guide/library/cql/internal.html">BNF of grammar to see what exactly you can do.
Filter f = CQL.toFilter("ATTR1 < 10 AND ATTR2 < 2 OR ATTR3 > 10");
Filter f = CQL.toFilter("NAME = 'New York' ");
Filter f = CQL.toFilter("NAME LIKE 'New%' ");
Filter f = CQL.toFilter("NAME IS NULL");
Filter f = CQL.toFilter("DATE BEFORE 2006-11-30T01:30:00Z");
Filter f = CQL.toFilter("NAME DOES-NOT-EXIST");
Filter f = CQL.toFilter("QUANTITY BETWEEN 10 AND 20");
Filter f = CQL.toFilter("CROSSES(SHAPE, LINESTRING(1 2, 10 15))");
Filter f = CQL.toFilter("BBOX(SHAPE, 10,20,30,40)");
Expression e = CQL.toExpression("NAME");
Expression e = CQL.toExpression("QUANTITY * 2");
Expression e = CQL.toExpression("strConcat(NAME, 'suffix')");
List filters = CQL.toFilterList("NAME IS NULL;BBOX(SHAPE, 10,20,30,40);INCLUDE");
Implementation specification 1.0- Since:
- 2.5
- Author:
- Mauricio Pazos (Axios Engineering), Gabriel Roldan (Axios Engineering)
-
Method Summary
Modifier and TypeMethodDescriptionstatic final voidCommand line expression tester used to try out filters and expressions.static Stringstatic StringtoCQL(Expression expression) Generates the expression text associated to theExpressionobject.static StringGenerates the cql predicate associated to theFilterobject.static ExpressiontoExpression(String cqlExpression) Parses the input string in OGC CQL format into an Expression, using the systems defaultFilterFactoryimplementation.static ExpressiontoExpression(String cqlExpression, FilterFactory filterFactory) Parses the input string in OGC CQL format into anExpression, using the providedFilterFactory.static FilterParses the input string in OGC CQL format into a Filter, using the systems default FilterFactory implementation.static FiltertoFilter(String cqlPredicate, FilterFactory filterFactory) Parses the input string in OGC CQL format into a Filter, using the provided FilterFactory.toFilterList(String cqlFilterList) Parses the input string, which has to be a list of OGC CQL predicates separated by;into aListofFilters, using the provided FilterFactory.toFilterList(String cqlSequencePredicate, FilterFactory filterFactory) Parses the input string which has to be a list of OGC CQL predicates separated by ";" into aListofFilters, using the provided FilterFactory.
-
Method Details
-
toFilter
Parses the input string in OGC CQL format into a Filter, using the systems default FilterFactory implementation.- Parameters:
cqlPredicate- a string containing a query predicate in OGC CQL format.- Returns:
- a
Filterequivalent to the constraint specified incqlPredicate. - Throws:
CQLException
-
toFilter
Parses the input string in OGC CQL format into a Filter, using the provided FilterFactory.- Parameters:
cqlPredicate- a string containing a query predicate in OGC CQL format.filterFactory- theFilterFactoryto use for the creation of the Filter. If it is null the method finds the default implementation.- Returns:
- a
Filterequivalent to the constraint specified inPredicate. - Throws:
CQLException
-
toExpression
Parses the input string in OGC CQL format into an Expression, using the systems defaultFilterFactoryimplementation.- Parameters:
cqlExpression- a string containing an OGC CQL expression.- Returns:
- a
Expressionequivalent to the one specified incqlExpression. - Throws:
CQLException
-
toExpression
public static Expression toExpression(String cqlExpression, FilterFactory filterFactory) throws CQLException Parses the input string in OGC CQL format into anExpression, using the providedFilterFactory.- Parameters:
cqlExpression- a string containing a OGC CQL expression.filterFactory- theFilterFactoryto use for the creation of the Expression. If it is null the method finds the default implementation.- Returns:
- a
Filterequivalent to the constraint specified incqlExpression. - Throws:
CQLException
-
toFilterList
Parses the input string, which has to be a list of OGC CQL predicates separated by;into aListofFilters, using the provided FilterFactory.- Parameters:
cqlFilterList- a list of OGC CQL predicates separated by ";"- Returns:
- a
ListofFilter, one for each input CQL statement - Throws:
CQLException
-
toCQL
- Returns:
- ecql predicates separated by ";"
-
toCQL
Generates the cql predicate associated to theFilterobject.- Returns:
- cql predicate
-
toCQL
Generates the expression text associated to theExpressionobject.- Returns:
- expression as text
-
toFilterList
public static List<Filter> toFilterList(String cqlSequencePredicate, FilterFactory filterFactory) throws CQLException Parses the input string which has to be a list of OGC CQL predicates separated by ";" into aListofFilters, using the provided FilterFactory.- Parameters:
cqlSequencePredicate- a list of OGC CQL predicates separated by ";"filterFactory- theFilterFactoryto use for the creation of the Expression. If it is null the method finds the default implementation.- Returns:
- a List of
Filter, one for each input CQL statement - Throws:
CQLException
-
main
Command line expression tester used to try out filters and expressions.
-