Package org.geotools.xml

Examples of org.geotools.xml.Encoder


   
    @Test
    public void testRoundTripCapabilities() throws Exception {
        CapabilitiesType caps = (CapabilitiesType) parser.parse(getClass().getResourceAsStream("Capabilities.xml"));

        Encoder encoder = new Encoder(new CSWConfiguration());
        encoder.setIndenting(true);
        encoder.setNamespaceAware(true);
        encoder.getNamespaces().declarePrefix("ows", OWS.NAMESPACE);
        encoder.getNamespaces().declarePrefix("ogc", OGC.NAMESPACE);
        encoder.getNamespaces().declarePrefix("gml", GML.NAMESPACE);
        String encoded = encoder.encodeAsString(caps, CSW.Capabilities);
        // System.out.println(encoded);
       
        CapabilitiesType reParsed = (CapabilitiesType) parser.parse(new StringReader(encoded));
        assertTrue(EMFUtils.emfEquals(caps, reParsed));
    }
View Full Code Here


                output.endElement(rimNamespace, "Slot", "rim:Slot");
                output.endPrefixMapping("rim");
            }
        });
       
        Encoder encoder = new Encoder(new CSWConfiguration());
        encoder.setIndenting(true);
        encoder.setNamespaceAware(true);
        encoder.getNamespaces().declarePrefix("ows", OWS.NAMESPACE);
        encoder.getNamespaces().declarePrefix("ogc", OGC.NAMESPACE);
        encoder.getNamespaces().declarePrefix("gml", GML.NAMESPACE);
        String encoded = encoder.encodeAsString(caps, CSW.Capabilities);
       
        // System.out.println(encoded);

        // prepare xmlunit
        Map<String, String> namespaces = new HashMap<String, String>();
View Full Code Here

        ComplexDataType cd = f.createComplexDataType();
        data.setComplexData(cd);

        //cd.getData().add(new GeometryFactory().createPoint(new Coordinate(1, 2)));

        Encoder e = new Encoder(new WPSConfiguration());
        e.setIndenting(true);
        e.encode(ex, WPS.Execute, System.out);
    }
View Full Code Here

        ComplexDataType cdata = f.createComplexDataType();
        data.setComplexData(cdata);
        //cdata.getData().add(new GeometryFactory().createPoint(new Coordinate(1, 1)));

        Encoder e = new Encoder(new WPSConfiguration());
        e.setIndenting(true);
        e.encode(response, WPS.ExecuteResponse, System.out);
    }
View Full Code Here

    @Override
    public void write(Object value, OutputStream output, Operation operation) throws IOException,
            ServiceException {
        PostDiffResponseType response = (PostDiffResponseType) value;
        Encoder encoder = new Encoder(configuration, gss.getSchema());
        encoder.setIndenting(true);

        encoder.encode(response, GSS.PostDiffResponse, output);
    }
View Full Code Here

    @Override
    public void write(Object value, OutputStream output, Operation operation) throws IOException,
            ServiceException {
        GetDiffResponseType response = (GetDiffResponseType) value;
        Encoder encoder = new Encoder(configuration, gss.getSchema());
        encoder.setIndenting(true);

        encoder.encode(response, GSS.GetDiffResponse, output);
    }
View Full Code Here

    @Override
    public void write(Object value, OutputStream output, Operation operation) throws IOException,
            ServiceException {
        CentralRevisionsType cr = (CentralRevisionsType) value;
        Encoder encoder = new Encoder(configuration, gss.getSchema());
        encoder.setIndenting(true);

        // declare namespaces to make the output validate
        for (LayerRevision l : cr.getLayerRevisions()) {
            encoder.getNamespaces().declarePrefix(l.getTypeName().getPrefix(),
                    l.getTypeName().getNamespaceURI());
        }

        encoder.encode(cr, GSS.CentralRevisions, output);
    }
View Full Code Here

     * @param featureById
     * @return
     * @throws IOException
     */
    String toGML3(SimpleFeature feature) throws IOException {
        Encoder encoder = new Encoder(configuration, configuration.getXSD().getSchema());
        NamespaceInfo nsi = catalog
                .getNamespaceByURI(feature.getType().getName().getNamespaceURI());
        if (nsi != null) {
            encoder.getNamespaces().declarePrefix(nsi.getPrefix(), nsi.getURI());
        }
        encoder.setEncoding(Charset.forName("UTF-8"));
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        encoder.encode(feature, GML._Feature, bos);
        return bos.toString("UTF-8");
    }
View Full Code Here

        if (filter == null) {
            st.setString(index, null);
            return;
        }

        Encoder encoder = new Encoder(ogc);
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        try {
            encoder.encode(filter, OGC.Filter, output);
            st.setString(index, new String(output.toByteArray()));
        } catch (Exception e) {
            String msg = "Could not encode filter: " + filter;
            throw new HibernateException(msg, e);
        }
View Full Code Here

        return layerName.getPrefix() + ":" + layerName.getLocalPart();
    }

    public GetDiffResponseType getDiff(GetDiffType getDiff) throws IOException {
        // prepare the encoder
        Encoder encoder = new Encoder(configuration, configuration.getXSD().getSchema());
        QName layerName = getDiff.getTypeName();
        encoder.getNamespaces().declarePrefix(layerName.getPrefix(), layerName.getNamespaceURI());
        encoder.setEncoding(Charset.forName("UTF-8"));

        // prepare POST request
        PostMethod method = new PostMethod(address.toExternalForm());
        method.setContentChunked(true);
        method.setRequestEntity(new XMLEntity(getDiff, GSS.GetDiff, encoder));
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.