Package org.geotools.data.mongodb
Class AbstractFilterToMongo
- Object
-
- AbstractFilterToMongo
-
- All Implemented Interfaces:
ExpressionVisitor
,FilterVisitor
- Direct Known Subclasses:
FilterToMongo
public abstract class AbstractFilterToMongo extends Object implements FilterVisitor, ExpressionVisitor
Abstract visitor responsible for generating a BasicDBObject to use as a MongoDB query.- Author:
- Gerald Gay, Data Tactics Corp., Alan Mangan, Data Tactics Corp., Tom Kunicki, Boundless Spatial Inc. (C) 2011, Open Source Geospatial Foundation (OSGeo)
- See Also:
GNU Lesser General Public License (LGPL)
-
-
Field Summary
Fields Modifier and Type Field Description protected FeatureType
featureType
The schmema the encoder will use as reference to drive filter encodingprotected MongoGeometryBuilder
geometryBuilder
static int
HUNDRED_KM_IN_METERS
protected static Logger
LOGGER
-
Constructor Summary
Constructors Constructor Description AbstractFilterToMongo()
AbstractFilterToMongo(MongoGeometryBuilder builder)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected BasicDBObject
asDBObject(Object extraData)
protected abstract String
getGeometryPath()
Method responsible for retrieving the MongoDB geometry json pathprotected abstract String
getPropertyPath(String property)
Method responsible for mapping a PropertyName to the corresponding MongoDB json pathprotected Class<?>
getValueType(Expression e)
protected abstract Class<?>
getValueTypeInternal(Expression expression)
Method responsible of retrieving the value type of an Expressionvoid
setFeatureType(FeatureType featureType)
Sets the feature type the encoder is encoding a filter for.Object
visit(And filter, Object extraData)
Object
visit(ExcludeFilter filter, Object extraData)
VisitFilter.EXCLUDE
(often used during data structure transformations).Object
visit(Add expression, Object extraData)
Object
visit(Divide expression, Object extraData)
Object
visit(Function function, Object extraData)
Object
visit(Literal expression, Object extraData)
Object
visit(Multiply expression, Object extraData)
Object
visit(NilExpression expression, Object extraData)
Used to visit a Expression.NIL, also called fornull
where an expression is expected.Object
visit(PropertyName expression, Object extraData)
Object
visit(Subtract expression, Object extraData)
Object
visit(Id filter, Object extraData)
Object
visit(IncludeFilter filter, Object extraData)
VisitFilter.INCLUDE
(often used during data structure transformations).Object
visit(Not filter, Object extraData)
Object
visit(Or filter, Object extraData)
Object
visit(PropertyIsBetween filter, Object extraData)
Object
visit(PropertyIsEqualTo filter, Object extraData)
Object
visit(PropertyIsGreaterThanOrEqualTo filter, Object extraData)
Object
visit(PropertyIsGreaterThan filter, Object extraData)
Object
visit(PropertyIsLessThanOrEqualTo filter, Object extraData)
Object
visit(PropertyIsLessThan filter, Object extraData)
Object
visit(PropertyIsLike filter, Object extraData)
Encode LIKE using MongoDB Regex.Object
visit(PropertyIsNil filter, Object extraData)
Object
visit(PropertyIsNotEqualTo filter, Object extraData)
Object
visit(PropertyIsNull filter, Object extraData)
Object
visit(BBOX filter, Object extraData)
Object
visit(Beyond filter, Object extraData)
Object
visit(Contains filter, Object extraData)
Object
visit(Crosses filter, Object extraData)
Object
visit(Disjoint filter, Object extraData)
Object
visit(DWithin filter, Object extraData)
DWITHIN filter is delegated to Mongo's $near operator for point geometry, otherwise it is delegated to $geoIntersects.Object
visit(Equals filter, Object extraData)
Object
visit(Intersects filter, Object extraData)
Object
visit(Overlaps filter, Object extraData)
Object
visit(Touches filter, Object extraData)
Object
visit(Within filter, Object extraData)
Object
visit(After after, Object extraData)
Object
visit(AnyInteracts anyInteracts, Object extraData)
Object
visit(Before before, Object extraData)
Object
visit(Begins begins, Object extraData)
Object
visit(BegunBy begunBy, Object extraData)
Object
visit(During during, Object extraData)
Object
visit(EndedBy endedBy, Object extraData)
Object
visit(Ends ends, Object extraData)
Object
visit(Meets meets, Object extraData)
Object
visit(MetBy metBy, Object extraData)
Object
visit(OverlappedBy overlappedBy, Object extraData)
Object
visit(TContains contains, Object extraData)
Object
visit(TEquals equals, Object extraData)
Object
visit(TOverlaps contains, Object extraData)
Object
visitNullFilter(Object extraData)
Used to account for anull
filter value.-
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface FilterVisitor
visit
-
-
-
-
Field Detail
-
HUNDRED_KM_IN_METERS
public static final int HUNDRED_KM_IN_METERS
- See Also:
- Constant Field Values
-
LOGGER
protected static Logger LOGGER
-
geometryBuilder
protected final MongoGeometryBuilder geometryBuilder
-
featureType
protected FeatureType featureType
The schmema the encoder will use as reference to drive filter encoding
-
-
Constructor Detail
-
AbstractFilterToMongo
public AbstractFilterToMongo(MongoGeometryBuilder builder)
-
AbstractFilterToMongo
public AbstractFilterToMongo()
-
-
Method Detail
-
asDBObject
protected BasicDBObject asDBObject(Object extraData)
-
setFeatureType
public void setFeatureType(FeatureType featureType)
Sets the feature type the encoder is encoding a filter for.The type of the attributes may drive how the filter is translated to a mongodb query document.
-
visit
public Object visit(Literal expression, Object extraData)
- Specified by:
visit
in interfaceExpressionVisitor
-
visit
public Object visit(PropertyName expression, Object extraData)
- Specified by:
visit
in interfaceExpressionVisitor
-
getGeometryPath
protected abstract String getGeometryPath()
Method responsible for retrieving the MongoDB geometry json path- Returns:
- the MongoDB json paath for the default geometry
-
getPropertyPath
protected abstract String getPropertyPath(String property)
Method responsible for mapping a PropertyName to the corresponding MongoDB json path- Parameters:
property
- the string property name to map- Returns:
- the MongoDB json path
-
visit
public Object visit(ExcludeFilter filter, Object extraData)
Description copied from interface:FilterVisitor
VisitFilter.EXCLUDE
(often used during data structure transformations).- Specified by:
visit
in interfaceFilterVisitor
- Parameters:
filter
-Filter.EXCLUDE
.extraData
- Value object provided to visitor- Returns:
- subclass supplied
-
visit
public Object visit(IncludeFilter filter, Object extraData)
Description copied from interface:FilterVisitor
VisitFilter.INCLUDE
(often used during data structure transformations).- Specified by:
visit
in interfaceFilterVisitor
- Parameters:
filter
-Filter.INCLUDE
.extraData
- Value object provided to visitor- Returns:
- subclass supplied
-
visit
public Object visit(And filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(Or filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(Not filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(PropertyIsBetween filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(PropertyIsEqualTo filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
getValueType
protected Class<?> getValueType(Expression e)
-
getValueTypeInternal
protected abstract Class<?> getValueTypeInternal(Expression expression)
Method responsible of retrieving the value type of an Expression- Parameters:
expression
- the expression for which find the value type- Returns:
- the type as a Class of the Expression
-
visit
public Object visit(PropertyIsNotEqualTo filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(PropertyIsGreaterThan filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(PropertyIsGreaterThanOrEqualTo filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(PropertyIsLessThan filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(PropertyIsLessThanOrEqualTo filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(PropertyIsLike filter, Object extraData)
Encode LIKE using MongoDB Regex.- filter.getWildCard() returns SQL-like '%'
- filter.getSingleChar() returns SQL-like '_'
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(PropertyIsNull filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(Id filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(BBOX filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(Intersects filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(Within filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visitNullFilter
public Object visitNullFilter(Object extraData)
Description copied from interface:FilterVisitor
Used to account for anull
filter value.This is particularly used during data structure transofrmations, however the use of
null
is not recommended. Please make use of Filter.NONE and Filter.ALL as placeholder objects that communicate intent.- Specified by:
visitNullFilter
in interfaceFilterVisitor
- Parameters:
extraData
- Value object provided to visitor- Returns:
- subclass defined
-
visit
public Object visit(NilExpression expression, Object extraData)
Description copied from interface:ExpressionVisitor
Used to visit a Expression.NIL, also called fornull
where an expression is expected.This is particularly useful when doing data transformations, as an example when using a StyleSymbolizer Expression.NIL can be used to represent the default stroke color.
- Specified by:
visit
in interfaceExpressionVisitor
- Returns:
- implementation specific
-
visit
public Object visit(Beyond filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(Contains filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(Crosses filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(Disjoint filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(DWithin filter, Object extraData)
DWITHIN filter is delegated to Mongo's $near operator for point geometry, otherwise it is delegated to $geoIntersects. To properly compute the buffer the azimuthal equidistant projection is being used.- Specified by:
visit
in interfaceFilterVisitor
- Parameters:
filter
-extraData
-- Returns:
-
visit
public Object visit(Equals filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(Overlaps filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(Touches filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(Add expression, Object extraData)
- Specified by:
visit
in interfaceExpressionVisitor
-
visit
public Object visit(Divide expression, Object extraData)
- Specified by:
visit
in interfaceExpressionVisitor
-
visit
public Object visit(Function function, Object extraData)
- Specified by:
visit
in interfaceExpressionVisitor
-
visit
public Object visit(Multiply expression, Object extraData)
- Specified by:
visit
in interfaceExpressionVisitor
-
visit
public Object visit(Subtract expression, Object extraData)
- Specified by:
visit
in interfaceExpressionVisitor
-
visit
public Object visit(PropertyIsNil filter, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(After after, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(AnyInteracts anyInteracts, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(Before before, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(Begins begins, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(BegunBy begunBy, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(During during, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(EndedBy endedBy, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(Ends ends, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(Meets meets, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(MetBy metBy, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(OverlappedBy overlappedBy, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(TContains contains, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(TEquals equals, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
visit
public Object visit(TOverlaps contains, Object extraData)
- Specified by:
visit
in interfaceFilterVisitor
-
-