Examples of FilterFactory2


Examples of org.opengis.filter.FilterFactory2

                if( value.length==1 )
                    return value[0].getValue();
                if( value.length==0 )
                    return Filter.EXCLUDE;
                try{
                    FilterFactory2 fac=CommonFactoryFinder.getFilterFactory2(null);
                    //LogicFilter filter=fac.createLogicFilter(FilterType.LOGIC_OR);
                    List<org.opengis.filter.Filter> filters = new ArrayList<org.opengis.filter.Filter>();
                    Set ids = new HashSet();
                    boolean isOnlyFids = true;
                    for (int i = 0; i < value.length; i++) {
                        org.opengis.filter.Filter value2 = (org.opengis.filter.Filter) value[i].getValue();
                        if( value2 == Filter.EXCLUDE) continue;
                        if( value2 instanceof Id){
                            Id idFilter = (Id) value2;
                            ids.addAll( idFilter.getIdentifiers() );
                        }
                        else {
                            isOnlyFids = false;
                        }                       
                        filters.add( value2 );
                    }                   
                    if( isOnlyFids && !ids.isEmpty()){
                        return fac.id( ids );
                    }
                    else if( filters.isEmpty() ){
                        return Filter.EXCLUDE;
                    }
                    else if( filters.size() == 1 ){
                        return filters.iterator().next();                       
                    }
                    else {
                        return fac.or( filters );                       
                    }
                    //return filter;
                }catch(IllegalFilterException e){
                    return value[0].getValue();
                }
View Full Code Here

Examples of org.opengis.filter.FilterFactory2

            if ((fid == null) || "".equals(fid)) {
                fid = attrs1.getValue(FeatureIdType.attrs[0].getNamespace()
                                                           .toString(),
                        FeatureIdType.attrs[0].getName());
            }
            FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
            Set<FeatureId> fids = new HashSet<FeatureId>();
            fids.add( ff.featureId(fid) );
           
            return ff.id( fids );
            //FidFilter r = FilterFactoryFinder.createFilterFactory().createFidFilter(fid);
            //return r;
        }
View Full Code Here

Examples of org.opengis.filter.FilterFactory2

         *      org.xml.sax.Attributes, java.util.Map)
         */
        public Object getValue(Element element, ElementValue[] value, Attributes attrs, Map hints)
                throws SAXException, OperationNotSupportedException {

            FilterFactory2 factory = FilterSchema.filterFactory(hints);

            try {
                short type = ComparisonOpsType.findFilterType(element.getName());

                Expression expr1 = (Expression) value[0].getValue();
                Expression expr2 = (Expression) value[1].getValue();

                switch (type) {
                case FilterType.COMPARE_EQUALS:
                    return factory.equals(expr1, expr2);

                case FilterType.COMPARE_NOT_EQUALS:
                    return factory.notEqual(expr1, expr2);

                case FilterType.COMPARE_GREATER_THAN:
                    return factory.greater(expr1, expr2);

                case FilterType.COMPARE_GREATER_THAN_EQUAL:
                    return factory.greaterOrEqual(expr1, expr2);

                case FilterType.COMPARE_LESS_THAN:
                    return factory.less(expr1, expr2);

                case FilterType.COMPARE_LESS_THAN_EQUAL:
                    return factory.lessOrEqual(expr1, expr2);

                default:
                    throw new SAXException("Illegal filter for " + element);

                }
View Full Code Here

Examples of org.opengis.filter.FilterFactory2

         *      org.geotools.xml.schema.ElementValue[],
         *      org.xml.sax.Attributes, java.util.Map)
         */
        public Object getValue(Element element, ElementValue[] value,
            Attributes attrs, Map hints) throws SAXException{
          FilterFactory2 factory = FilterSchema.filterFactory( hints );
            //          <xsd:extension base="ogc:ComparisonOpsType">
            //            <xsd:sequence>
            //              <xsd:element ref="ogc:PropertyName"/>
            //              <xsd:element ref="ogc:Literal"/>
            //            </xsd:sequence>
            //            <xsd:attribute name="wildCard" type="xsd:string" use="required"/>
            //            <xsd:attribute name="singleChar" type="xsd:string" use="required"/>
            //            <xsd:attribute name="escape" type="xsd:string" use="required"/>
            //          </xsd:extension>         
          try {
           
            Expression expr = (Expression) value[0].getValue();
            String wildCard = attrs.getValue( "wildCard" );
            String singleChar = attrs.getValue( "singleChar" );
            String escape = attrs.getValue( "escape" );
            Literal pattern = (Literal) value[1].getValue();
           
         
            return factory.like(expr, (String) pattern.getValue(), wildCard, singleChar, escape);
                        }
          catch( ClassCastException expressionRequired ){
            throw new SAXException("Illegal filter for "+element, expressionRequired );
      }
          catch (IllegalFilterException e) {
View Full Code Here

Examples of org.opengis.filter.FilterFactory2

         *      org.geotools.xml.schema.ElementValue[],
         *      org.xml.sax.Attributes, java.util.Map)
         */
        public Object getValue(Element element, ElementValue[] value, Attributes attrs, Map hints)
                throws SAXException {
            FilterFactory2 factory = FilterSchema.filterFactory(hints);
            try {
                Expression expr = (Expression) value[0].getValue();

                return factory.isNull(expr);
            } catch (ClassCastException expressionRequired) {
                throw new SAXException("Illegal filter for " + element, expressionRequired);
            } catch (IllegalFilterException e) {
                throw new SAXException("Illegal filter for " + element);
            }
View Full Code Here

Examples of org.opengis.filter.FilterFactory2

         *      org.geotools.xml.schema.ElementValue[],
         *      org.xml.sax.Attributes, java.util.Map)
         */
        public Object getValue(Element element, ElementValue[] value, Attributes attrs, Map hints)
                throws SAXException {
            FilterFactory2 factory = FilterSchema.filterFactory(hints);
            try {
                Expression left = (Expression) value[1].getValue();
                Expression middle = (Expression) value[0].getValue();
                Expression right = (Expression) value[2].getValue();

                return factory.between(middle, left, right);

            } catch (ClassCastException expressionRequired) {
                throw new SAXException("Illegal filter for " + element, expressionRequired);
            } catch (IllegalFilterException e) {
                throw new SAXException("Illegal filter for " + element);
View Full Code Here

Examples of org.opengis.filter.FilterFactory2

    private void fireAdded(final SimpleFeature addedFeature) {
        final String typeName = featureType.getTypeName();
        final BoundingBox bounds = addedFeature.getBounds();
        ReferencedEnvelope referencedEnvelope = ReferencedEnvelope.reference(bounds);
        String fid = addedFeature.getID();
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
        Filter filter = ff.id(Collections.singleton(ff.featureId(fid)));
        doFireFeaturesAdded(typeName, referencedEnvelope, filter);
    }
View Full Code Here

Examples of org.opengis.filter.FilterFactory2

    private void fireChanged(final SimpleFeature changedFeature) {
        final String typeName = featureType.getTypeName();
        final BoundingBox bounds = changedFeature.getBounds();
        ReferencedEnvelope referencedEnvelope = ReferencedEnvelope.reference(bounds);
        String fid = changedFeature.getID();
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
        Filter filter = ff.id(Collections.singleton(ff.featureId(fid)));

        doFireFeaturesChanged(typeName, referencedEnvelope, filter);
    }
View Full Code Here

Examples of org.opengis.filter.FilterFactory2

    private void fireRemoved(final SimpleFeature removedFeature) {
        String typeName = featureType.getTypeName();
        BoundingBox bounds = removedFeature.getBounds();
        ReferencedEnvelope referencedEnvelope = ReferencedEnvelope.reference(bounds);
        String fid = removedFeature.getID();
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
        Filter filter = ff.id(Collections.singleton(ff.featureId(fid)));
        doFireFeaturesRemoved(typeName, referencedEnvelope, filter);
    }
View Full Code Here

Examples of org.opengis.filter.FilterFactory2

        assertEquals(1, fids.size());
        String featureId = fids.first();
        assertTrue(allFids.contains(featureId));

        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
        Filter filterOne = ff.id(Collections.singleton(ff.featureId(featureId)));

        assertEquals("no events on AUTO_COMMIT", 0, listener.list.size());
        assertEquals("no events on transaction1", 0, listener1.list.size());
        assertEquals("no events on transaction2", 0, listener2.list.size());
        featureStore1.removeFeatures(filterOne);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.