Package org.geotools.xml

Examples of org.geotools.xml.Encoder


        encoded = new XSDateTimeBinding().encode(cal, null);
        assertEquals("2011-10-24T10:53:31.999Z", encoded);
    }

    private void testEncodeCalendar(Calendar cal, QName qname, String expected) throws Exception {
        Encoder encoder = new Encoder(new TestConfiguration());
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        encoder.encode(cal, qname, out);
       
        Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder()
                .parse(new ByteArrayInputStream(out.toByteArray()));
       
        String encodedValue = dom.getDocumentElement().getTextContent();
View Full Code Here


                inserted.getFeatureId().add(featureId);
            }
        }

        Configuration configuration = getStrategy().getWfsConfiguration();
        Encoder enc = new Encoder(configuration);
        enc.setEncoding(Charset.forName("UTF-8"));
        enc.setIndenting(true);
        enc.setIndentSize(1);

        String encodedTransactionResponse = enc.encodeAsString(tr,
                "1.0.0".equals(getStrategy().getVersion()) ? org.geotools.wfs.v1_0.WFS.WFS_TransactionResponse :
                    WFS.TransactionResponse);
        System.err.println(encodedTransactionResponse);
        return encodedTransactionResponse;
    }
View Full Code Here

            encName = org.geotools.filter.v1_0.OGC.Filter;
        } else {
            encName = org.geotools.filter.v2_0.FES.Filter;
        }

        Encoder encoder = new Encoder(filterConfig);
        // do not write the xml declaration
        encoder.setOmitXMLDeclaration(true);
        encoder.setEncoding(Charset.forName("UTF-8"));

        String encoded = encoder.encodeAsString(filter, encName);

        encoded = encoded.replaceAll("\n", "");
        return encoded;
    }
View Full Code Here

        final Configuration configuration = getWfsConfiguration();
        Charset charset = getConfig().getDefaultEncoding();
        if (null == charset) {
            charset = Charset.forName("UTF-8");
        }
        Encoder encoder = new Encoder(configuration);
        encoder.setEncoding(charset);
        encoder.setIndentSize(1);

        Set<QName> typeNames = new HashSet<QName>();

        if (request instanceof TransactionRequest) {
            TransactionRequest tx = (TransactionRequest) request;
            typeNames.addAll(tx.getTypeNames());
        } else {
            QName typeName = request.getTypeName();
            if (typeName != null) {
                typeNames.add(typeName);
            }
        }
        int i = 0;
        for (QName typeName : typeNames) {

            String prefix = typeName.getPrefix();
            String namespaceURI = typeName.getNamespaceURI();

            if (XMLConstants.NULL_NS_URI.equals(namespaceURI)) {
                continue;
            }

            if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) {
                prefix = "type_ns" + i;
            }

            encoder.getNamespaces().declarePrefix(prefix, namespaceURI);

            i++;
        }
        return encoder;
    }
View Full Code Here

                    + request.getOperation());
        }

        ByteArrayOutputStream out = new ByteArrayOutputStream();

        final Encoder encoder = prepareEncoder(request);
        final QName opName = getOperationName(request.getOperation());

        encoder.encode(requestObject, opName, out);

        requestTrace("Encoded ", request.getOperation(), " request: ", out);

        System.err.println(out.toString());
       
View Full Code Here

     * Returns a single-line string containing the xml representation of the given filter, as
     * appropriate for the {@code FILTER} parameter in a GetFeature request.
     */
    protected String encodeGetFeatureGetFilter(final Filter filter) throws IOException {
        Configuration filterConfig = getFilterConfiguration();
        Encoder encoder = new Encoder(filterConfig);
        // do not write the xml declaration
        encoder.setOmitXMLDeclaration(true);
        encoder.setEncoding(Charset.forName("UTF-8"));

        OutputStream out = new ByteArrayOutputStream();
        encoder.encode(filter, OGC.Filter, out);
        String encoded = out.toString();
        encoded = encoded.replaceAll("\n", "");
        return encoded;
    }
View Full Code Here

        }

        RequestComponents reqParts = strategy.createGetFeatureRequest(this, request);
        GetFeatureType serverRequest = reqParts.getServerRequest();

        Encoder encoder = new Encoder(strategy.getWfsConfiguration());

        // If the typeName is of the form prefix:typeName we better declare the namespace since we
        // don't know how picky the server parser will be
        String typeName = reqParts.getKvpParameters().get("TYPENAME");
        QName fullName = getFeatureTypeName(typeName);
        String prefix = fullName.getPrefix();
        String namespace = fullName.getNamespaceURI();
        if (!XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) {
            encoder.getNamespaces().declarePrefix(prefix, namespace);
        }
        WFSResponse response = issuePostRequest(serverRequest, postURL, encoder);

        return response;
    }
View Full Code Here

     *            the charset to use to encode the request in
     * @throws IOException
     */
    public static void encode(final EObject request, final Configuration configuration,
            final OutputStream out, final Charset charset) throws IOException {
        Encoder encoder = new Encoder(configuration);
        encoder.setEncoding(charset);
        encode(request, encoder, out);
    }
View Full Code Here

            return super.getPostContents(request);
        }

        GetFeatureType requestObject = createGetFeatureRequestPost((GetFeatureRequest) request);

        final Encoder encoder = prepareEncoder(request);
        final QName opName = getOperationName(request.getOperation());

        Document dom;
        try {
            dom = encoder.encodeAsDOM(requestObject, opName);
        } catch (SAXException e) {
            throw new IOException(e);
        } catch (TransformerException e) {
            throw new IOException(e);
        }
View Full Code Here

    if (style == null) {
      JOptionPane.showMessageDialog(this, "Style not defined");
      return;
    }
    org.geotools.sld.v1_1.SLDConfiguration configuration = new org.geotools.sld.v1_1.SLDConfiguration();
    Encoder encoder = new org.geotools.xml.Encoder(configuration);

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    try {
      encoder.encode(style,
          org.geotools.sld.bindings.SLD.FEATURETYPESTYLE,
          outputStream);
      String document = outputStream.toString("UTF-8");

      text.setText(document);
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.