Package org.opengis.filter

Examples of org.opengis.filter.PropertyIsLike


            Map hints) throws IOException, OperationNotSupportedException {
            if (!canEncode(element, value, hints)) {
                return;
            }

            PropertyIsLike lf = (PropertyIsLike) value;

            AttributesImpl at = new AttributesImpl();
            at.addAttribute(FilterSchema.NAMESPACE.toString(), "wildCard",
                null, "string", lf.getWildCard());
            at.addAttribute(FilterSchema.NAMESPACE.toString(), "singleChar",
                null, "string", lf.getSingleChar());
            at.addAttribute(FilterSchema.NAMESPACE.toString(), "escape", null,
                "string", lf.getEscape());

            output.startElement(element.getNamespace(), element.getName(), at);
            elems[0].getType().encode(elems[0], lf.getExpression(), output, hints); // PropertyName
            elems[1].getType().encode(elems[1], lf.getLiteral(), output, hints); // Literal
            output.endElement(element.getNamespace(), element.getName());
        }
View Full Code Here


    @Test
    public void testLikeFilter() throws Exception {
        final String wildcard = "%";
        final String single = "?";
        final String escape = "\\";
        PropertyIsLike like = ff.like(ff.property("/measurement/determinand_description"),
                "%n_1_1", wildcard, single, escape, true, MatchAction.ONE);

        PropertyIsLike unmapped = (PropertyIsLike) like.accept(visitor, null);
        assertEquals(like.getLiteral(), unmapped.getLiteral());
        assertEquals(like.getWildCard(), unmapped.getWildCard());
        assertEquals(like.getSingleChar(), unmapped.getSingleChar());
        assertEquals(like.getEscape(), unmapped.getEscape());
        assertEquals(like.isMatchingCase(), unmapped.isMatchingCase());
        assertEquals(like.getMatchAction(), unmapped.getMatchAction());

        Expression unmappedExpr = unmapped.getExpression();
        assertTrue(unmappedExpr instanceof PropertyName);
        assertEquals("determinand_description", ((PropertyName) unmappedExpr).getPropertyName());
    }
View Full Code Here

    public QName getTarget() {
        return FES.PropertyIsLikeType;
    }
   
    public Object getProperty(Object object, QName name) throws Exception {
        PropertyIsLike isLike = (PropertyIsLike) object;
   
        if (FES.expression.equals(name)) {
            return new Object[] {
                    isLike.getExpression(),
                    isLike.getLiteral() != null ? factory.literal(isLike
                            .getLiteral()) : null };
        }
   
        return super.getProperty(object, name);
    }
View Full Code Here

public class OGCPropertyIsLikeTypeBindingTest extends FilterTestSupport {

    public void testParse() throws Exception {
        FilterMockData.propertyIsLike(document, document);

        PropertyIsLike isLike = (PropertyIsLike) parse();

        assertNotNull(isLike.getExpression());
        assertNotNull(isLike.getLiteral());

        assertEquals("x", isLike.getWildCard());
        assertEquals("y", isLike.getSingleChar());
        assertEquals("z", isLike.getEscape());
        assertEquals(false, isLike.isMatchingCase());
    }
View Full Code Here

        return factory.like(name, literal.toString(), wildcard, single, escape, matchCase);
    }

    public Object getProperty(Object object, QName name)
        throws Exception {
        PropertyIsLike isLike = (PropertyIsLike) object;

        if (OGC.PropertyName.equals(name)) {
            return isLike.getExpression();
        }

        if (OGC.Literal.equals(name)) {
            return isLike.getLiteral() != null ? factory.literal( isLike.getLiteral() ) : null;
        }

        if ("wildCard".equals(name.getLocalPart())) {
            return isLike.getWildCard();
        }

        if ("singleChar".equals(name.getLocalPart())) {
            return isLike.getSingleChar();
        }

        if ("escape".equals(name.getLocalPart()) || "escapeChar".equals(name.getLocalPart())) {
            return isLike.getEscape();
        }

        return null;
    }
View Full Code Here

        assertEquals(between, result);
    }
   
    @Test
    public void testLike() {
        PropertyIsLike like = ff.like(ff.property("a"), "*A*");
        NullHandlingVisitor visitor = new NullHandlingVisitor();
        Filter result = (Filter) like.accept(visitor, null);
        assertTrue(result instanceof And);
        Filter expected = ff.and(like, propertyNotNull("a"));
        assertEquals(expected, result);
       
        like = ff.like(ff.literal("a"), "*A*");
        result = (Filter) like.accept(visitor, null);
        assertEquals(like, result);
    }
View Full Code Here

public class FESFilterTest extends FESTestSupport {

    public void testEncodePropertyIsLike() throws Exception {
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
        PropertyIsLike filter = ff.like(ff.property("name"), "%test%");
        org.geotools.filter.v2_0.FESConfiguration configuration = new org.geotools.filter.v2_0.FESConfiguration();
        org.geotools.xml.Encoder encoder = new org.geotools.xml.Encoder(configuration);
        encoder.encode(filter, org.geotools.filter.v2_0.FES.Filter, os);
       
        DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
View Full Code Here

    }

    public void testParse() throws Exception {
        FilterMockData.propertyIsLike(document, document);

        PropertyIsLike isLike = (PropertyIsLike) parse();

        assertNotNull(isLike.getExpression());
        assertNotNull(isLike.getLiteral());

        assertEquals("x", isLike.getWildCard());
        assertEquals("y", isLike.getSingleChar());
        assertEquals("z", isLike.getEscape());
    }
View Full Code Here

            org.opengis.filter.expression.Expression pattern = this.resultStack
                    .popExpression();
            org.opengis.filter.expression.Expression expr = this.resultStack
                    .popExpression();

            PropertyIsLike f = filterFactory.like(expr, pattern.toString(),
                    WC_MULTI, WC_SINGLE, ESCAPE, matchCase);

            return f;
        } catch (IllegalFilterException ife) {
            throw new CQLException("Exception building LikeFilter: " + ife.getMessage(), this.cqlSource);
View Full Code Here

     
    }


    private void testAttributeBetweenDoubleQuotes(final String attSample) throws CQLException {
        PropertyIsLike result;
        PropertyName attResult = null;

        result = (PropertyIsLike) CompilerUtil.parseFilter(this.language, attSample + " LIKE 'abc%'");

        attResult = (PropertyName) result.getExpression();

        String expected = attSample.replace('.', '/');
        expected = expected.substring(1, expected.length()-1);

        String propertyName = attResult.getPropertyName();
View Full Code Here

TOP

Related Classes of org.opengis.filter.PropertyIsLike

Copyright © 2018 www.massapicom. 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.