Class 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)
    • Constructor Detail

      • AbstractFilterToMongo

        public AbstractFilterToMongo()
    • Method Detail

      • asDBObject

        protected BasicDBObject asDBObject​(Object extraData)
      • getGeometryPath

        protected abstract String getGeometryPath()
        Method responsible of retrieving the MongoDB geometry json path
        Returns:
        the MongoDB json paath for the default geometry
      • getPropertyPath

        protected abstract String getPropertyPath​(String property)
        Method responsible of 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​(And filter,
                            Object extraData)
        Specified by:
        visit in interface FilterVisitor
      • visit

        public Object visit​(Or filter,
                            Object extraData)
        Specified by:
        visit in interface FilterVisitor
      • visit

        public Object visit​(Not filter,
                            Object extraData)
        Specified by:
        visit in interface FilterVisitor
      • 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​(PropertyIsLike filter,
                            Object extraData)
        Encode LIKE using MongoDB Regex.
        • filter.getWildCard() returns SQL-like '%'
        • filter.getSingleChar() returns SQL-like '_'
        As an example "foo_bar%" converts to foo.bar.*
        Specified by:
        visit in interface FilterVisitor
      • visit

        public Object visit​(Id filter,
                            Object extraData)
        Specified by:
        visit in interface FilterVisitor
      • visit

        public Object visit​(BBOX filter,
                            Object extraData)
        Specified by:
        visit in interface FilterVisitor
      • visitNullFilter

        public Object visitNullFilter​(Object extraData)
        Description copied from interface: FilterVisitor
        Used to account for a null 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 interface FilterVisitor
        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 for null 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 interface ExpressionVisitor
        Returns:
        implementation specific
      • visit

        public Object visit​(Ends ends,
                            Object extraData)
        Specified by:
        visit in interface FilterVisitor