org.geotools.filter.text.cql2
Class CQL

Object
  extended by CQL

public class CQL
extends Object

Utility class to parse CQL predicates and expressions to GeoAPI Filters and Expressions, respectively.

CQL is an acronym for OGC Common Query Language, a query predicate language whose syntax is similar to a SQL WHERE clause, defined 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 complete 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("CROSS(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");
 
 

Since:
2.5
Author:
Mauricio Pazos (Axios Engineering), Gabriel Roldan (Axios Engineering)
Module:
modules/library/cql (gt-cql.jar)

Method Summary
static void main(String[] args)
           
static String toCQL(Expression expression)
          WARNING THIS IS A WORK IN PROGRESS.
static String toCQL(Filter filter)
          WARNING THIS IS A WORK IN PROGRESS.
static Expression toExpression(String cqlExpression)
          Parses the input string in OGC CQL format into an Expression, using the systems default FilterFactory implementation.
static Expression toExpression(String cqlExpression, FilterFactory filterFactory)
          Parses the input string in OGC CQL format into an Expression, using the provided FilterFactory.
static Filter toFilter(String cqlPredicate)
          Parses the input string in OGC CQL format into a Filter, using the systems default FilterFactory implementation.
static Filter toFilter(String cqlPredicate, FilterFactory filterFactory)
          Parses the input string in OGC CQL format into a Filter, using the provided FilterFactory.
static List<Filter> toFilterList(String cqlFilterList)
          Parses the input string, which has to be a list of OGC CQL predicates separated by ; into a List of Filters, using the provided FilterFactory.
static List<Filter> toFilterList(String cqlSequencePredicate, FilterFactory filterFactory)
          Parses the input string which has to be a list of OGC CQL predicates separated by ";" into a List of Filters, using the provided FilterFactory.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toFilter

public static Filter toFilter(String cqlPredicate)
                       throws CQLException
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 Filter equivalent to the constraint specified in cqlPredicate.
Throws:
CQLException

toFilter

public static Filter toFilter(String cqlPredicate,
                              FilterFactory filterFactory)
                       throws CQLException
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 - the FilterFactory to use for the creation of the Filter. If it is null the method finds the default implementation.
Returns:
a Filter equivalent to the constraint specified in Predicate.
Throws:
CQLException

toExpression

public static Expression toExpression(String cqlExpression)
                               throws CQLException
Parses the input string in OGC CQL format into an Expression, using the systems default FilterFactory implementation.

Parameters:
cqlExpression - a string containing an OGC CQL expression.
Returns:
a Expression equivalent to the one specified in cqlExpression.
Throws:
CQLException

toExpression

public static Expression toExpression(String cqlExpression,
                                      FilterFactory filterFactory)
                               throws CQLException
Parses the input string in OGC CQL format into an Expression, using the provided FilterFactory.

Parameters:
cqlExpression - a string containing a OGC CQL expression.
filterFactory - the FilterFactory to use for the creation of the Expression. If it is null the method finds the default implementation.
Returns:
a Filter equivalent to the constraint specified in cqlExpression.
Throws:
CQLException

toFilterList

public static List<Filter> toFilterList(String cqlFilterList)
                                 throws CQLException
Parses the input string, which has to be a list of OGC CQL predicates separated by ; into a List of Filters, using the provided FilterFactory.

Parameters:
cqlFilterList - a list of OGC CQL predicates separated by ";"
Returns:
a List of Filter, one for each input CQL statement
Throws:
CQLException

toCQL

public static String toCQL(Filter filter)
WARNING THIS IS A WORK IN PROGRESS.

Parameters:
filter -
Returns:

toCQL

public static String toCQL(Expression expression)
WARNING THIS IS A WORK IN PROGRESS.

Parameters:
filter -
Returns:

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 a List of Filters, using the provided FilterFactory.

Parameters:
cqlSequencePredicate - a list of OGC CQL predicates separated by ";"
filterFactory - the FilterFactory to 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

public static final void main(String[] args)


Copyright © 1996-2009 Geotools. All Rights Reserved.