org.geotools.filter.text.commons
Class AbstractFilterBuilder

Object
  extended by AbstractFilterBuilder

public abstract class AbstractFilterBuilder
extends Object

This abstract class provides the common behavior to build the filters for the related semantic actions of parsing language process.

Builds Filter or Expression and their components (literal, functions, etc). It maintains the results of semantic actions in the stack used to build complex filters and expressions.

Warning: This component is not published. It is part of module implementation. Client module should not use this feature.

Since:
2.6
Author:
Mauricio Pazos (Axios Engineering)
Module:
modules/library/cql (gt-cql.jar)

Field Summary
protected  String cqlSource
           
 
Constructor Summary
AbstractFilterBuilder(String cqlSource, FilterFactory filterFactory)
          New instance of FilterBuilder
 
Method Summary
 BinaryExpression buildAddExpression()
           
 Filter buildAndFilter()
           
 BBOX buildBBox()
           
 BBOX buildBBoxWithCRS()
           
 PropertyIsBetween buildBetween()
          builds PropertyIsBetween filter
 PropertyName buildCompoundAttribute(int nodeSimpleAttr, String nodeAttrSeparator)
           
 Literal buildDateTimeExpression(IToken token)
          Creates a literal with date time
 Literal buildDistanceUnit(IToken token)
           
 BinaryExpression buildDivideExpression()
           
 Literal buildDurationExpression(IToken token)
          Create an integer literal with duration value.
 Literal buildEnvelop(IToken token)
          Return the Envelop
 PropertyIsEqualTo buildEquals()
           
 Literal buildFalseLiteral()
           
 Function buildFunction(int functionNode)
          Builds a function expression
 Literal buildGeometry(IToken geometry)
          Builds geometry
 PropertyIsGreaterThan buildGreater()
           
 PropertyIsGreaterThanOrEqualTo buildGreaterOrEqual()
           
 String buildIdentifier(int nodeIdentifier)
           
 String buildIdentifierPart(IToken token)
          Creates the identifier part.
 PropertyIsLessThan buildLess()
           
 PropertyIsLessThanOrEqualTo buildLessOrEqual()
           
 PropertyIsLike buildLikeFilter()
          Bulds a like filter
 Literal buildLiteralDouble(String tokenImage)
           
 Literal buildLiteralInteger(String image)
           
 Literal buildLiteralString(String tokenImage)
           
 BinaryExpression buildMultiplyExpression()
           
 Not buildNotBetween()
           
 Filter buildNotFilter()
           
 Not buildNotFilter(Filter eq)
           
 Not buildNotLikeFilter()
           
 Filter buildOrFilter()
           
 PeriodNode buildPeriodBetweenDates()
          builds a PeriodNode (date1,date2)
 PeriodNode buildPeriodDateAndDuration()
          builds a Period with (date,duration)
 PeriodNode buildPeriodDurationAndDate()
          builds a Period Node with (duration,date).
 Not buildPorpertyNotIsNull()
           
 And buildPropertyBetweenDates()
          Create an AND filter with property between dates of period.
 PropertyIsEqualTo buildPropertyExists()
          Creates PropertyIsEqualTo with PropertyExists predicate
 PropertyIsGreaterThanOrEqualTo buildPropertyIsGTEFirstDate()
          Builds PropertyIsGreaterThanOrEqualTo begin of period
 PropertyIsGreaterThan buildPropertyIsGTLastDate()
          creates PropertyIsGreaterThan end date of period
 PropertyIsLessThanOrEqualTo buildPropertyIsLTELastDate()
           
 PropertyIsLessThan buildPropertyIsLTFirsDate()
           
 PropertyIsNull buildPropertyIsNull()
          Builds property is null filter
 PropertyName buildSimpleAttribute()
           
 DistanceBufferOperator buildSpatialBeyondFilter()
           
 BinarySpatialOperator buildSpatialContainsFilter()
           
 BinarySpatialOperator buildSpatialCrossesFilter()
           
 BinarySpatialOperator buildSpatialDisjointFilter()
           
 DistanceBufferOperator buildSpatialDWithinFilter()
           
 BinarySpatialOperator buildSpatialEqualFilter()
           
 BinarySpatialOperator buildSpatialIntersectsFilter()
           
 BinarySpatialOperator buildSpatialOverlapsFilter()
           
 BinarySpatialOperator buildSpatialTouchesFilter()
           
 BinarySpatialOperator buildSpatialWithinFilter()
           
 BinaryExpression buildSubtractExression()
           
 Literal buildTolerance()
           
 Literal buildTrueLiteral()
           
 Expression getExpression()
           
 Filter getFilter()
           
protected  FilterFactory getFilterFactory()
           
 List<Filter> getFilterList()
           
protected  BuildResultStack getResultStack()
           
protected  String getStatement()
           
 Result peekResult()
           
 void pushResult(Result result)
          Adds in the result stack the partial result associated to node.
protected  String removeQuotes(String source)
          Removes initial and final "'" from string.
protected  String scanExpression(IToken initialToken)
          Extracts expression between initial token and last token in buffer.
protected  String transformWKTGeometry(String wktGeom)
          This transformation is required because some geometries like Multipoint has different definition in vividsolucion library.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cqlSource

protected final String cqlSource
Constructor Detail

AbstractFilterBuilder

public AbstractFilterBuilder(String cqlSource,
                             FilterFactory filterFactory)
New instance of FilterBuilder

Parameters:
cqlSource -
filterFactory -
Method Detail

getFilterFactory

protected FilterFactory getFilterFactory()

getResultStack

protected final BuildResultStack getResultStack()

getStatement

protected final String getStatement()

getFilter

public Filter getFilter()
                 throws CQLException
Throws:
CQLException

getExpression

public Expression getExpression()
                         throws CQLException
Throws:
CQLException

getFilterList

public List<Filter> getFilterList()
                           throws CQLException
Throws:
CQLException

buildAddExpression

public BinaryExpression buildAddExpression()
                                    throws CQLException
Throws:
CQLException

buildSubtractExression

public BinaryExpression buildSubtractExression()
                                        throws CQLException
Throws:
CQLException

buildMultiplyExpression

public BinaryExpression buildMultiplyExpression()
                                         throws CQLException
Throws:
CQLException

buildDivideExpression

public BinaryExpression buildDivideExpression()
                                       throws CQLException
Throws:
CQLException

buildAndFilter

public Filter buildAndFilter()
                      throws CQLException
Throws:
CQLException

buildOrFilter

public Filter buildOrFilter()
                     throws CQLException
Throws:
CQLException

buildNotFilter

public Filter buildNotFilter()
                      throws CQLException
Throws:
CQLException

buildLikeFilter

public PropertyIsLike buildLikeFilter()
                               throws CQLException
Bulds a like filter

Returns:
a PropertyIsLike
Throws:
CQLException

buildPropertyIsNull

public PropertyIsNull buildPropertyIsNull()
                                   throws CQLException
Builds property is null filter

Returns:
PropertyIsNull
Throws:
CQLException

buildPorpertyNotIsNull

public Not buildPorpertyNotIsNull()
                           throws CQLException
Throws:
CQLException

buildBetween

public PropertyIsBetween buildBetween()
                               throws CQLException
builds PropertyIsBetween filter

Returns:
PropertyIsBetween
Throws:
CQLException

buildNotBetween

public Not buildNotBetween()
                    throws CQLException
Throws:
CQLException

buildNotLikeFilter

public Not buildNotLikeFilter()
                       throws CQLException
Throws:
CQLException

buildPropertyExists

public PropertyIsEqualTo buildPropertyExists()
                                      throws CQLException
Creates PropertyIsEqualTo with PropertyExists predicate

Returns:
PropertyIsEqualTo
Throws:
CQLException

buildDateTimeExpression

public Literal buildDateTimeExpression(IToken token)
                                throws CQLException
Creates a literal with date time

Parameters:
n - with date time
Returns:
Literal
Throws:
CQLException

buildNotFilter

public Not buildNotFilter(Filter eq)

buildTrueLiteral

public Literal buildTrueLiteral()

buildFalseLiteral

public Literal buildFalseLiteral()

buildLiteralInteger

public Literal buildLiteralInteger(String image)

buildLiteralDouble

public Literal buildLiteralDouble(String tokenImage)

buildLiteralString

public Literal buildLiteralString(String tokenImage)

removeQuotes

protected String removeQuotes(String source)
Removes initial and final "'" from string. If some "''" is found it will be changed by a single quote "'".

Parameters:
source -
Returns:
string without initial and final quote, and "''" replaced by "'".

buildIdentifier

public String buildIdentifier(int nodeIdentifier)
                       throws CQLException
Throws:
CQLException

buildIdentifierPart

public String buildIdentifierPart(IToken token)
Creates the identifier part. An identifier like "idpart1:idpart2:idpart3: ... idpartN" has N part.

Returns:
identifier part

buildSimpleAttribute

public PropertyName buildSimpleAttribute()
                                  throws CQLException
Throws:
CQLException

buildCompoundAttribute

public PropertyName buildCompoundAttribute(int nodeSimpleAttr,
                                           String nodeAttrSeparator)
                                    throws CQLException
Parameters:
nodeSimpleAttr -
nodeAttrSeparator -
Returns:
PropertyName
Throws:
CQLException

buildDistanceUnit

public Literal buildDistanceUnit(IToken token)
                          throws CQLException
Throws:
CQLException

buildTolerance

public Literal buildTolerance()
                       throws CQLException
Throws:
CQLException

buildSpatialEqualFilter

public BinarySpatialOperator buildSpatialEqualFilter()
                                              throws CQLException
Throws:
CQLException

buildSpatialDisjointFilter

public BinarySpatialOperator buildSpatialDisjointFilter()
                                                 throws CQLException
Throws:
CQLException

buildSpatialIntersectsFilter

public BinarySpatialOperator buildSpatialIntersectsFilter()
                                                   throws CQLException
Throws:
CQLException

buildSpatialTouchesFilter

public BinarySpatialOperator buildSpatialTouchesFilter()
                                                throws CQLException
Throws:
CQLException

buildSpatialCrossesFilter

public BinarySpatialOperator buildSpatialCrossesFilter()
                                                throws CQLException
Throws:
CQLException

buildSpatialWithinFilter

public BinarySpatialOperator buildSpatialWithinFilter()
                                               throws CQLException
Throws:
CQLException

buildSpatialContainsFilter

public BinarySpatialOperator buildSpatialContainsFilter()
                                                 throws CQLException
Throws:
CQLException

buildSpatialOverlapsFilter

public BinarySpatialOperator buildSpatialOverlapsFilter()
                                                 throws CQLException
Throws:
CQLException

buildBBox

public BBOX buildBBox()
               throws CQLException
Throws:
CQLException

buildBBoxWithCRS

public BBOX buildBBoxWithCRS()
                      throws CQLException
Throws:
CQLException

buildSpatialDWithinFilter

public DistanceBufferOperator buildSpatialDWithinFilter()
                                                 throws CQLException
Throws:
CQLException

buildSpatialBeyondFilter

public DistanceBufferOperator buildSpatialBeyondFilter()
                                                throws CQLException
Throws:
CQLException

buildPeriodBetweenDates

public PeriodNode buildPeriodBetweenDates()
                                   throws CQLException
builds a PeriodNode (date1,date2)

Returns:
PeriodNode
Throws:
CQLException

buildPeriodDurationAndDate

public PeriodNode buildPeriodDurationAndDate()
                                      throws CQLException
builds a Period Node with (duration,date).

Returns:
PeriodNode
Throws:
CQLException

buildPeriodDateAndDuration

public PeriodNode buildPeriodDateAndDuration()
                                      throws CQLException
builds a Period with (date,duration)

Returns:
PeriodNode
Throws:
CQLException

buildDurationExpression

public Literal buildDurationExpression(IToken token)
Create an integer literal with duration value.

Returns:
Literal

buildPropertyBetweenDates

public And buildPropertyBetweenDates()
                              throws CQLException
Create an AND filter with property between dates of period. (firstDate<= property <= lastDate)

Returns:
And filter
Throws:
CQLException

buildPropertyIsGTEFirstDate

public PropertyIsGreaterThanOrEqualTo buildPropertyIsGTEFirstDate()
                                                           throws CQLException
Builds PropertyIsGreaterThanOrEqualTo begin of period

Returns:
PropertyIsGreaterThanOrEqualTo
Throws:
CQLException

buildPropertyIsGTLastDate

public PropertyIsGreaterThan buildPropertyIsGTLastDate()
                                                throws CQLException
creates PropertyIsGreaterThan end date of period

Returns:
PropertyIsGreaterThan
Throws:
CQLException

buildPropertyIsLTFirsDate

public PropertyIsLessThan buildPropertyIsLTFirsDate()
                                             throws CQLException
Returns:
PropertyIsLessThan
Throws:
CQLException

buildPropertyIsLTELastDate

public PropertyIsLessThanOrEqualTo buildPropertyIsLTELastDate()
                                                       throws CQLException
Returns:
PropertyIsLessThanOrEqualTo
Throws:
CQLException

buildEquals

public PropertyIsEqualTo buildEquals()
                              throws CQLException
Returns:
PropertyIsEqualTo
Throws:
CQLException

buildGreater

public PropertyIsGreaterThan buildGreater()
                                   throws CQLException
Returns:
PropertyIsGreaterThan
Throws:
CQLException

buildLess

public PropertyIsLessThan buildLess()
                             throws CQLException
Returns:
PropertyIsLessThan
Throws:
CQLException

buildGreaterOrEqual

public PropertyIsGreaterThanOrEqualTo buildGreaterOrEqual()
                                                   throws CQLException
Returns:
PropertyIsGreaterThanOrEqualTo
Throws:
CQLException

buildLessOrEqual

public PropertyIsLessThanOrEqualTo buildLessOrEqual()
                                             throws CQLException
Returns:
PropertyIsLessThanOrEqualTo
Throws:
CQLException

buildGeometry

public Literal buildGeometry(IToken geometry)
                      throws CQLException
Builds geometry

Parameters:
geometry -
Returns:
a geometry
Throws:
CQLException

scanExpression

protected String scanExpression(IToken initialToken)
Extracts expression between initial token and last token in buffer.

Parameters:
initialToken -
Returns:
String the expression

transformWKTGeometry

protected String transformWKTGeometry(String wktGeom)
This transformation is required because some geometries like Multipoint has different definition in vividsolucion library.

 Then OGC require MULTIPOINT((1 2), (3 4))
 but vividsolunion works without point "(" ans ")"
 MULTIPOINT(1 2, 3 4)
 

Parameters:
wktGeom - ogc wkt geometry
Returns:
String vividsolution geometry

buildEnvelop

public Literal buildEnvelop(IToken token)
Return the Envelop

Parameters:
token -
Returns:
Literal

buildFunction

public Function buildFunction(int functionNode)
                       throws CQLException
Builds a function expression

Parameters:
functionNode - symbol used to identify the function node in parser tree
Returns:
Function
Throws:
CQLException

pushResult

public void pushResult(Result result)
Adds in the result stack the partial result associated to node.

Parameters:
built - partial result
token -
type - node associated to partial result

peekResult

public Result peekResult()


Copyright © 1996-2010 Geotools. All Rights Reserved.