Package org.geotools.xml

Examples of org.geotools.xml.Encoder


        SimpleFeature feature = ff.createSimpleFeature(new Object[] {"dummyValue"}, ft, "dummyId");
       
        InsertElementType insert = wfsfac.createInsertElementType();
        insert.getFeature().add(feature);       
       
        Encoder encoder = new Encoder(new WFSConfiguration());
        //System.out.println(encoder.encodeAsString(insert, WFS.Insert));
        Document doc = encoder.encodeAsDOM(insert, WFS.Insert);
        XMLAssert.assertXpathEvaluatesTo("dummyId", "//wfs:Insert/wfs:dummyFeatureType/@gml:id", doc);
        XMLAssert.assertXpathEvaluatesTo("dummyValue", "//wfs:Insert/wfs:dummyFeatureType/wfs:dummyAttribute", doc);
       
    }
View Full Code Here


        FilterFactory2 filterfac = CommonFactoryFinder.getFilterFactory2();
               
        DeleteElementType delete = wfsfac.createDeleteElementType();
        delete.setFilter(filterfac.id( filterfac.featureId("someid")));
       
        Encoder encoder = new Encoder(new WFSConfiguration());
        //System.out.println(encoder.encodeAsString(delete, WFS.Delete));
        Document doc = encoder.encodeAsDOM(delete, WFS.Delete);
        XMLAssert.assertXpathEvaluatesTo("someid", "//wfs:Delete/ogc:Filter/ogc:FeatureId/@fid", doc);       
       
    }
View Full Code Here

                   
                    Object value = ((PropertyType) object).getValue();
                   
                    output.startElement(WFS.NAMESPACE, VALUE, "wfs:" + VALUE, null);
                    if (value instanceof Geometry) {
                        Encoder encoder = new Encoder(new org.geotools.gml2.GMLConfiguration());
                        encoder.encode(value, org.geotools.gml2.GML._Geometry, output);
                    }
                    else {
                        String s = value.toString();
                        output.characters(s.toCharArray(), 0, s.length());
                    }
View Full Code Here

    Encoder encoder;
   
    @Before
    public void setup() {
        parser = new Parser(new CSWConfiguration());
        encoder = new Encoder(new CSWConfiguration());
        encoder.getNamespaces().declarePrefix("csw", CSW.NAMESPACE);
        encoder.getNamespaces().declarePrefix("dc", DC.NAMESPACE);
        encoder.getNamespaces().declarePrefix("dct", DCT.NAMESPACE);
        encoder.getNamespaces().declarePrefix("ows", OWS.NAMESPACE);
        encoder.setIndenting(true);
View Full Code Here

    public void testEncodeFeatureCollection() throws Exception {
        FeatureCollectionType fc = WfsFactory.eINSTANCE.createFeatureCollectionType();
        FeatureCollection features = store.getFeatureSource("feature").getFeatures();
        fc.getFeature().add( features );

        Encoder e = encoder();
        e.getNamespaces().declarePrefix( "geotools", "http://geotools.org");
        e.setIndenting(true);
       
        Document d = e.encodeAsDOM( fc, WFS.FeatureCollection );
//        TransformerFactory.newInstance().newTransformer().transform(
//            new DOMSource(d), new StreamResult(System.out));
       
        NamedNodeMap attributes = d.getDocumentElement().getAttributes();
        assertEquals("unknown", attributes.getNamedItem("numberMatched" ).getTextContent());
View Full Code Here

    public void testEncodeNumberMatchedReturned() throws Exception {
        // prepare empty result
        net.opengis.wfs20.FeatureCollectionType fc = Wfs20Factory.eINSTANCE.createFeatureCollectionType();
        fc.setNumberReturned(new BigInteger("0"));

        Encoder e = encoder();

        Document d = e.encodeAsDOM( fc, WFS.FeatureCollection );
        NamedNodeMap attributes = d.getDocumentElement().getAttributes();
        assertEquals("unknown", attributes.getNamedItem("numberMatched" ).getTextContent());
        assertEquals("0", attributes.getNamedItem("numberReturned" ).getTextContent());
       
        // try with -1
        e = encoder();
        fc.setNumberMatched(-1);
        d = e.encodeAsDOM( fc, WFS.FeatureCollection );
        attributes = d.getDocumentElement().getAttributes();
        assertEquals("unknown", attributes.getNamedItem("numberMatched" ).getTextContent());
        assertEquals("0", attributes.getNamedItem("numberReturned" ).getTextContent());
       
        // now with a valid value
        e = encoder();
        fc.setNumberMatched(10);
        d = e.encodeAsDOM( fc, WFS.FeatureCollection );
        attributes = d.getDocumentElement().getAttributes();
        assertEquals("10", attributes.getNamedItem("numberMatched" ).getTextContent());
        assertEquals("0", attributes.getNamedItem("numberReturned" ).getTextContent());
    }
View Full Code Here

        FeatureCollectionType fc = WfsFactory.eINSTANCE.createFeatureCollectionType();
        FeatureCollection features = store.getFeatureSource("feature").getFeatures();
        fc.getFeature().add( features );
        Configuration wfsConfiguration = new org.geotools.wfs.v2_0.WFSConfiguration();
        wfsConfiguration.getProperties().add(GMLConfiguration.NO_FEATURE_BOUNDS);
        Encoder e = encoder(wfsConfiguration);
        e.getNamespaces().declarePrefix( "geotools", "http://geotools.org");
        e.setIndenting(true);
       
        Document d = e.encodeAsDOM( fc, WFS.FeatureCollection );
        TransformerFactory.newInstance().newTransformer().transform(
            new DOMSource(d), new StreamResult(System.out));
       
        assertEquals( 0, d.getElementsByTagName( "wfs:boundedBy" ).getLength() );
        assertEquals( 0, d.getElementsByTagName( "gml:boundedBy" ).getLength() );
View Full Code Here

        FeatureCollectionType fc = WfsFactory.eINSTANCE.createFeatureCollectionType();
       
        fc.getFeature().add( store.getFeatureSource("feature").getFeatures() );
        fc.getFeature().add( store.getFeatureSource("other").getFeatures() );
       
        Encoder e = encoder();
        e.getNamespaces().declarePrefix( "geotools", "http://geotools.org");
        e.setIndenting(true);
       
        Document d = e.encodeAsDOM( fc, WFS.FeatureCollection );
        //TransformerFactory.newInstance().newTransformer().transform(
        //    new DOMSource(d), new StreamResult(System.out));
       
        List<Element> members = getChildElementsByTagName( d.getDocumentElement(), "wfs:member" );
        assertEquals( 2, members.size() );
View Full Code Here

        }
        return elements;
    }

    Encoder encoder(Configuration configuration) {
        return new Encoder(configuration);
    }
View Full Code Here

    Encoder encoder(Configuration configuration) {
        return new Encoder(configuration);
    }
   
    Encoder encoder() {
        return new Encoder(new org.geotools.wfs.v2_0.WFSConfiguration());
    }
View Full Code Here

TOP

Related Classes of org.geotools.xml.Encoder

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.