Package org.geotools.xml

Examples of org.geotools.xml.Encoder$DOMAttributes


    }

    public void postDiff(PostDiffType postDiff)
            throws IOException {
        // prepare the encoder
        Encoder encoder = buildEncoderForTransaction(postDiff.getTransaction());

        // prepare POST request
        PostMethod method = new PostMethod(address.toExternalForm());
        method.setContentChunked(true);
        method.setRequestEntity(new XMLEntity(postDiff, GSS.PostDiff, encoder));
View Full Code Here


    /**
     * Builds a XML encoder for the specified transaction. The code will declare all
     * prefix/namespace URI associations necessary for the elements in the transaction
     */
    Encoder buildEncoderForTransaction(TransactionType changes) throws IOException {
        Encoder encoder = new Encoder(configuration, configuration.getXSD().getSchema());

        // try to declare all namespace prefixes properly
        NamespaceSupport namespaces = encoder.getNamespaces();
        List<DeleteElementType> deletes = changes.getDelete();
        List<UpdateElementType> updates = changes.getUpdate();
        List<InsertElementType> inserts = changes.getInsert();
        for (DeleteElementType delete : deletes) {
            QName typeName = delete.getTypeName();
            namespaces.declarePrefix(typeName.getPrefix(), typeName.getNamespaceURI());
        }
        for (UpdateElementType update : updates) {
            QName typeName = update.getTypeName();
            namespaces.declarePrefix(typeName.getPrefix(), typeName.getNamespaceURI());
        }
        for (InsertElementType insert : inserts) {
            List<SimpleFeature> features = insert.getFeature();
            for (SimpleFeature feature : features) {
                Name typeName = feature.getType().getName();
                NamespaceInfo nsi = catalog.getNamespaceByURI(typeName.getNamespaceURI());
                if (nsi != null) {
                    namespaces.declarePrefix(nsi.getPrefix(), nsi.getURI());
                }
            }
        }

        encoder.setEncoding(Charset.forName("UTF-8"));
        return encoder;
    }
View Full Code Here

       
        //grab the metadata
        FeatureTypeInfo meta = catalog.getFeatureTypeByName(featureType.getName());
       
        //create teh encoder
        Encoder encoder = new Encoder( configuration );
        encoder.setEncoding(Charset.forName( getInfo().getGeoServer().getGlobal().getCharset() ) );
        encoder.encode( feature,
            new QName( meta.getNamespace().getURI(), meta.getName()), output );
    }
View Full Code Here

        writer.flush();
    }

    void write1_1(LockFeatureResponseType lockResponse, OutputStream output, Operation operation)
        throws IOException {
        Encoder encoder = new Encoder(configuration, configuration.schema());
        encoder.setEncoding(Charset.forName( getInfo().getGeoServer().getGlobal().getCharset()) );
       
        LockFeatureType req = (LockFeatureType)operation.getParameters()[0];
       
        encoder.setSchemaLocation(org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE,
                buildSchemaURL(req.getBaseUrl(), "schemas/wfs/1.1.0/wfs.xsd"));

        encoder.encode(lockResponse, org.geoserver.wfs.xml.v1_1_0.WFS.LOCKFEATURERESPONSE,
                output);
        output.flush();
    }
View Full Code Here

     * @throws IOException
     */
    protected void writeFilter(Filter filter, ObjectOutputStream out) throws IOException {
        if (filter != null) {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            Encoder encoder = new Encoder(CONFIGURATION);
            encoder.encode(filter, OGC.Filter, bos);
            out.writeObject(bos.toByteArray());
        } else {
            out.writeObject(null);
        }
    }
View Full Code Here

            ActionType action = (ActionType) response.getTransactionResults().getAction().iterator()
                                                     .next();
            throw new WFSException(action.getMessage(), action.getCode(), action.getLocator());
        }

        Encoder encoder = new Encoder(configuration, configuration.schema());
        encoder.setEncoding(Charset.forName( getInfo().getGeoServer().getGlobal().getCharset()) );

        TransactionType req = (TransactionType)operation.getParameters()[0];
       
        encoder.setSchemaLocation(org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE,
                buildSchemaURL(req.getBaseUrl(), "wfs/1.1.0/wfs.xsd"));
        encoder.encode(response, org.geoserver.wfs.xml.v1_1_0.WFS.TRANSACTIONRESPONSE, output);
      
    }
View Full Code Here

        } else {
            hits.setNumberOfFeatures(featureCollection.getNumberOfFeatures());
        }
        hits.setTimeStamp(featureCollection.getTimeStamp());

        Encoder encoder = new Encoder(configuration, configuration.schema());
        encoder.setEncoding(Charset.forName( wfs.getGeoServer().getGlobal().getCharset()) );
        encoder.setSchemaLocation(org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE,
            ResponseUtils.appendPath(wfs.getSchemaBaseURL(), "wfs/1.1.0/wfs.xsd"));

        encoder.encode(hits, org.geoserver.wfs.xml.v1_1_0.WFS.FEATURECOLLECTION, output);
    }
View Full Code Here

        SimpleFeatureType featureType = (SimpleFeatureType) features.getSchema();
       
        FeatureCollectionType fc = WfsFactory.eINSTANCE.createFeatureCollectionType();
        fc.getFeature().add( features );
       
        Encoder e = new Encoder(configuration);
        e.getNamespaces().declarePrefix( "feature", featureType.getName().getNamespaceURI() );
        e.encode( fc, getElement(), handler );
    }
View Full Code Here

    }

    public void write(Object value, OutputStream output, Operation operation)
            throws IOException, ServiceException {
   
        Encoder encoder = new Encoder( new GMLConfiguration() );
        encoder.setEncoding(Charset.forName( getInfo().getGeoServer().getGlobal().getCharset() ));
       
        if ( value instanceof Point ) {
            encoder.encode( value, GML.Point, output );
        }
        else if ( value instanceof MultiPoint ) {
            encoder.encode( value, GML.MultiPoint, output );
        }
        else if ( value instanceof LineString ) {
            encoder.encode( value, GML.LineString, output );
        }
        else if ( value instanceof MultiLineString ) {
            encoder.encode( value, GML.MultiLineString, output );
        }
        else if ( value instanceof Polygon ) {
            encoder.encode( value, GML.Polygon, output );
        }
        else if ( value instanceof MultiPolygon ) {
            encoder.encode( value, GML.MultiPolygon, output );
        }
        else {
            throw new WFSException( "Cannot encode geometry of type: " + value.getClass() );
        }
     }
View Full Code Here

                    elementName = org.geotools.wfs.v1_0.WFS.GetFeature;
                }
                FileOutputStream fos = null;
                try {
                    fos = new FileOutputStream(target);
                    Encoder encoder = new Encoder(cfg);
                    encoder.setIndenting(true);
                    encoder.setIndentSize(2);
                    encoder.encode(gft, elementName, fos);
                } finally {
                    if(fos != null)
                        fos.close();
                }
            }
View Full Code Here

TOP

Related Classes of org.geotools.xml.Encoder$DOMAttributes

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.