| java.lang.Object org.geotools.xml.Encoder
Encoder | public class Encoder (Code) | | Encodes objects as xml based on a schema.
The function of the encoder is to traverse a tree of objects seializing them
out as xml as it goes. Navigation and serialization of the tree is performed by
instances of
org.geotools.xml.Binding which are bound to types in the
schema.
To execute the encoder, one must have 3 bits of information:
- The root object in the tree to be encoded
- The schema / configuration of the intsance document being encoded.
- A name of the element defined in the schema which corresponds to the
root object in the tree.
As an exmaple, consider the encoding of a
org.opengis.filter.Filter
instance.
//instantiate hte configuration for the filter schmea
Configuration configuration = new OGCConfiguration();
//create the encoder
Encoder encoder = new Encoder( configuration );
//get a filter
Filter filter = ...;
//get the name of the 'filter' element in the schema
QName name = new QName( "http://www.opengis.net/ogc", "Filter" );
//encode
encoder.encode( filter, name );
author: Justin Deoliveira, The Open Planning Project |
Constructor Summary | |
public | Encoder(Configuration configuration) Creates an encoder from a configuration. | public | Encoder(Configuration configuration, XSDSchema schema) Creates an encoder from a configuration and a specific schema
instance. |
Method Summary | |
public void | encode(Object object, QName name, OutputStream out) Encodes an object.
An object is encoded as an object, name pair, where the name is the name
of an element declaration in a schema. | public void | encode(Object object, QName name, ContentHandler handler) Encodes an object.
An object is encoded as an object, name pair, where the name is the name
of an element declaration in a schema. | protected Node | encode(Object object, XSDNamedComponent component) | protected void | end(Element element) | public BindingWalker | getBindingWalker() | public XSDSchema | getSchema() | public SchemaIndex | getSchemaIndex() | public void | setEncodeFullDocument(boolean encodeFullDocument) | public void | setNamespaceAware(boolean namespaceAware) Sets wether the encoder should be namespace aware. | public void | setOutputFormat(OutputFormat outputFormat) Sets hte output format to be used by the encoder. | public void | setSchemaLocation(String namespaceURI, String location) Sets the schema location for a particular namespace uri. | protected void | start(Element element) | public void | write(Object object, QName name, OutputStream out) |
Encoder | public Encoder(Configuration configuration, XSDSchema schema)(Code) | | Creates an encoder from a configuration and a specific schema
instance.
Parameters: configuration - The encoder configuration. Parameters: schema - The schema instance. |
encode | public void encode(Object object, QName name, OutputStream out) throws IOException, SAXException(Code) | | Encodes an object.
An object is encoded as an object, name pair, where the name is the name
of an element declaration in a schema.
Parameters: object - The object being encoded. Parameters: name - The name of the element being encoded in the schema. Parameters: out - The output stream. throws: IOException - throws: SAXException - |
encode | public void encode(Object object, QName name, ContentHandler handler) throws IOException, SAXException(Code) | | Encodes an object.
An object is encoded as an object, name pair, where the name is the name
of an element declaration in a schema.
Parameters: object - The object being encoded. Parameters: name - The name of the element being encoded in the schema. Parameters: handler - true if this encode run is trying to encode a full xml document, false if otherwisethe generated xml is part of a bigger xml file throws: IOException - throws: SAXException - |
getBindingWalker | public BindingWalker getBindingWalker()(Code) | | The walker used to traverse bindings, this method is for internal use only. |
getSchema | public XSDSchema getSchema()(Code) | | the schema. |
getSchemaIndex | public SchemaIndex getSchemaIndex()(Code) | | The index of schema components, this method is for internal use only. |
setEncodeFullDocument | public void setEncodeFullDocument(boolean encodeFullDocument)(Code) | | |
setNamespaceAware | public void setNamespaceAware(boolean namespaceAware)(Code) | | Sets wether the encoder should be namespace aware.
Warning that setting this to false will result in no
namespace prefixes on encoded elements and attributes, and no schema
declarations on the root element.document;
Parameters: namespaces - |
setOutputFormat | public void setOutputFormat(OutputFormat outputFormat)(Code) | | Sets hte output format to be used by the encoder.
Parameters: outputFormat - The output format. |
setSchemaLocation | public void setSchemaLocation(String namespaceURI, String location)(Code) | | Sets the schema location for a particular namespace uri.
Registering a schema location will include it on the "schemaLocation" attribute of the
root element of the encoding.
Parameters: namespaceURI - A namespace uri. Parameters: location - A schema location. |
|
|