Package com.luciad.format.gml31.xml
Class TLcdGML31ModelEncoder
java.lang.Object
com.luciad.format.xml.bind.schema.ALcdXMLModelEncoder
com.luciad.format.gml31.xml.TLcdGML31ModelEncoder
- All Implemented Interfaces:
ILcdOutputStreamFactoryCapable
,ILcdModelEncoder
,Serializable
@LcdService(service=ILcdModelEncoder.class,
priority=20000)
public class TLcdGML31ModelEncoder
extends ALcdXMLModelEncoder
This model encoder encodes Geography Markup Language (GML) version 3.1.
Output files
File | Description |
---|---|
*.gml, *.gml31, *.xml | GML 3.1 data file |
*.xsd | Application schema (XML Schema) |
Supported file transfer protocols
- This model encoder supports all transfer protocols that are supported by
the
outputStreamFactory
of this encoder.
Supported models for saving
- This model encoder can save all models decoded by the
TLcdGML31ModelDecoder
and models having aTLcdGML31ModelDescriptor
. These models are instances ofTLcdGML31Model
orTLcdGML31AbstractFeatureCollection
. Model elements are instances ofTLcdGML31AbstractFeature
.
Supported models for exporting
- This model encoder can save all models having
ILcdShape/ILcdDataObject
elements. Nested features are also supported. - The following shapes are supported:
Java class GML geometry type ILcdPoint gml:PointType ILcdPolyline gml:LineStringType ILcdCircle gml:CurveType ILcdCircleBy3Points gml:CurveType ILcdCircularArcBy3Points gml:CurveType ILcdCircularArcByBulge gml:CurveType ILcdCircularArcByCenterPoint gml:CurveType ILcdCircularArc gml:CurveType ILcdCompositeCurve gml:CompositeCurveType ILcdPolygon gml:PolygonType ILcdComplexPolygon gml:SurfaceType ILcdSurface gml:SurfaceType ILcdShapeList gml:MultiGeometryType - The following feature classes are supported:
Java class XSD type Boolean xsd:boolean Byte xsd:byte Short xsd:short Integer xsd:int Long xsd:long Float xsd:float Double xsd:double
Supported model references
- This model encoder supports all model references which can be formatted by the
TLcdOGCModelReferenceFormatter
.
Useful settings
- A default target namespace can be configured on this model encoder. This namespace will be the namespace of all the application schemas that are generated during export of non-GML31 models.
Sample code
ILcdModelEncoder encoder = new TLcdGML31ModelEncoder();
encoder.export(model, "world.gml31");
Thread safety
- The encoding of models is thread-safe, as long as no properties are changed during the encoding.
Supported versions and specifications
- GML 3.1.1
Known limitations
- Since:
- 9.0
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether this encoder can export the specified model to the specified destination.boolean
Returns whether this model encoder can save the specified model to the location it originally came from.protected String
createSchemaLocation
(String aNamespaceURI, String aDefaultSchemaLocation, String aDestinationName) Returns a schema location for the specified namespace URI to be encoded in the "xsi:schemaLocations" attribute in the generated XML documents.void
Exports the specified model to the specified destination.void
Exports the given model to a destination result.void
exportSchema
(ILcdModel aModel, String aDestinationName) Exports the XML schema for the specified model to the specified destination.Returns the default target application schema namespace.Returns a short, displayable name for the format thisILcdModelEncoder
encodes to.Returns theorg.xml.sax.ext.EntityResolver2
that is used for creating input sources for XSD schemas.Returns the model reference formatter that is used to formatILcdModelReference
instances when encoding an srsName.Returns theILcdOutputStreamFactory
that is used for creating output streams.Returns thejavax.xml.stream.XMLOutputFactory
that is used by this encoder for creatingjavax.xml.stream.XMLStreamWriter
instances.boolean
Returnstrue
if the schema is automatically encoded when a model is encoded,false
otherwise.void
Saves the model to the location where it originally came from.void
setAutoEncodeSchema
(boolean aAutoEncodeSchema) Sets whether a schema is to be encoded automatically when a model is encoded.void
setDefaultTargetNamespace
(String aTargetNamespace) Sets the default target application schema namespace.void
setEntityResolver
(EntityResolver2 aEntityResolver) Sets theorg.xml.sax.ext.EntityResolver2
to be used for creating input sources for XSD schemas.void
setModelReferenceFormatter
(ILcdModelReferenceFormatter aModelReferenceFormatter) Sets the formatter that is used to formatILcdModelReference
instances when encoding an srsName.void
setOutputStreamFactory
(ILcdOutputStreamFactory aOutputStreamFactory) Sets theILcdOutputStreamFactory
to be used for creating output streams.void
setXMLOutputFactory
(XMLOutputFactory aXMLOutputFactory) Sets thejavax.xml.stream.XMLOutputFactory
to be used by this encoder for creatingjavax.xml.stream.XMLStreamWriter
instances.toString()
-
Constructor Details
-
TLcdGML31ModelEncoder
public TLcdGML31ModelEncoder()Creates a newTLcdGML31ModelEncoder
, ready to use.
-
-
Method Details
-
canSave
Description copied from interface:ILcdModelEncoder
Returns whether this model encoder can save the specified model to the location it originally came from. Often this will only be a simple test, for example checking the type of the model's model descriptor.- Parameters:
aModel
- the model to be verified.- Returns:
true
if this encoder can save the model in the location where it originally came from,false
otherwise.- See Also:
-
getDisplayName
Description copied from interface:ILcdModelEncoder
Returns a short, displayable name for the format thisILcdModelEncoder
encodes to.- Returns:
- the displayable name of this
ILcdModelEncoder
.
-
getEntityResolver
Description copied from class:ALcdXMLModelEncoder
Returns theorg.xml.sax.ext.EntityResolver2
that is used for creating input sources for XSD schemas.- Specified by:
getEntityResolver
in classALcdXMLModelEncoder
- Returns:
- the entity resolver to be used for creating input sources for XSD schemas.
-
getOutputStreamFactory
Description copied from class:ALcdXMLModelEncoder
Returns theILcdOutputStreamFactory
that is used for creating output streams.- Specified by:
getOutputStreamFactory
in interfaceILcdOutputStreamFactoryCapable
- Specified by:
getOutputStreamFactory
in classALcdXMLModelEncoder
- Returns:
- the
ILcdOutputStreamFactory
that is used for creating output streams. - See Also:
-
getXMLOutputFactory
Description copied from class:ALcdXMLModelEncoder
Returns thejavax.xml.stream.XMLOutputFactory
that is used by this encoder for creatingjavax.xml.stream.XMLStreamWriter
instances.- Specified by:
getXMLOutputFactory
in classALcdXMLModelEncoder
- Returns:
- the
javax.xml.stream.XMLOutputFactory
that is used by this encoder for creatingjavax.xml.stream.XMLStreamWriter
instances.
-
save
Description copied from interface:ILcdModelEncoder
Saves the model to the location where it originally came from.- Parameters:
aModel
- the model to be saved.- Throws:
IllegalArgumentException
- if the model cannot be saved by this encoder (!canSave(aModel)
).IOException
- if an I/O error occurs during encoding.
-
setEntityResolver
Description copied from class:ALcdXMLModelEncoder
Sets theorg.xml.sax.ext.EntityResolver2
to be used for creating input sources for XSD schemas. This entity resolver is only used for retrieving runtime extension schemas.- Specified by:
setEntityResolver
in classALcdXMLModelEncoder
- Parameters:
aEntityResolver
- the entity resolver to be used for creating input sources for XSD schemas.
-
setOutputStreamFactory
Description copied from class:ALcdXMLModelEncoder
Sets theILcdOutputStreamFactory
to be used for creating output streams. This output stream factory is used for output streams for both the data files and the XSD schemas.- Specified by:
setOutputStreamFactory
in interfaceILcdOutputStreamFactoryCapable
- Specified by:
setOutputStreamFactory
in classALcdXMLModelEncoder
- Parameters:
aOutputStreamFactory
- the output stream factory to be used by this model encoder.- See Also:
-
setXMLOutputFactory
Description copied from class:ALcdXMLModelEncoder
Sets thejavax.xml.stream.XMLOutputFactory
to be used by this encoder for creatingjavax.xml.stream.XMLStreamWriter
instances.- Specified by:
setXMLOutputFactory
in classALcdXMLModelEncoder
- Parameters:
aXMLOutputFactory
- thejavax.xml.stream.XMLOutputFactory
to be used by this encoder for creatingjavax.xml.stream.XMLStreamWriter
instances.
-
toString
-
getDefaultTargetNamespace
Returns the default target application schema namespace. This is the namespace in which all generated elements and types generated specifically for the exported document will be declared. If null (the default), a namespace will be generated.- Returns:
- the default namespace for generated application schemas, or null if a namespace is generated.
-
setDefaultTargetNamespace
Sets the default target application schema namespace. This is the namespace in which all generated elements and types generated specifically for the exported document will be declared. If null (the default), a namespace will be generated.- Parameters:
aTargetNamespace
- the default namespace for generated application schemas.
-
isAutoEncodeSchema
public boolean isAutoEncodeSchema()Returnstrue
if the schema is automatically encoded when a model is encoded,false
otherwise.- Returns:
true
if the schema is automatically encoded when a model is encoded,false
otherwise.
-
setAutoEncodeSchema
public void setAutoEncodeSchema(boolean aAutoEncodeSchema) Sets whether a schema is to be encoded automatically when a model is encoded. When set totrue
, this means that two output streams will be created when thesave
orexport
method is called, one for the destination file and one for the schema.- Parameters:
aAutoEncodeSchema
- whether a schema is to be encoded automatically when a model is encoded.
-
createSchemaLocation
protected String createSchemaLocation(String aNamespaceURI, String aDefaultSchemaLocation, String aDestinationName) Returns a schema location for the specified namespace URI to be encoded in the "xsi:schemaLocations" attribute in the generated XML documents. The default implementation just returns the default location which is passed. This might be a local source however, which can be unwanted in some cases (e.g. a WFS server).- Parameters:
aNamespaceURI
- the namespace URI for which to create a schema location.aDefaultSchemaLocation
- the default schema location, if known by the encoder.aDestinationName
- the name of the document being saved or exported, which will refer in its "xsi:schemaLocations" attribute to this schema location.- Returns:
- a schema location for the specified namespace URI, which has a useful meaning in the encoded document.
-
canExport
Description copied from interface:ILcdModelEncoder
Returns whether this encoder can export the specified model to the specified destination. This method will typically check whether the contents of the specified model are compatible with the format this encoder is written for.- Parameters:
aModel
- the model to be verified.aDestinationName
- the location where the model should be exported to.- Returns:
true
if this encoder can export the specified model to the specified location,false
otherwise.- See Also:
-
export
Description copied from interface:ILcdModelEncoder
Exports the specified model to the specified destination.- Parameters:
aModel
- the model to be exported.aDestinationName
- the location where the model should be saved. Typically, this is a name for the output file, but it can also point to a file containing the required properties to create a set of data files.- Throws:
IOException
- if an I/O error occurs during encoding.
-
export
Exports the given model to a destination result.
- Overrides:
export
in classALcdXMLModelEncoder
- Parameters:
aModel
- the model to exportaDestination
- the destination- Throws:
IOException
- if an I/O error occurs during encoding.UnsupportedOperationException
- in case the encoder is not able to write to the given result- See Also:
-
exportSchema
Exports the XML schema for the specified model to the specified destination.- Parameters:
aModel
- the model for which to generate and export an XML Schema.aDestinationName
- the destination to which the XML schema should be saved.- Throws:
IOException
- if an exception occurs during exporting.
-
getModelReferenceFormatter
Returns the model reference formatter that is used to formatILcdModelReference
instances when encoding an srsName.- Returns:
- the model reference formatter of this encoder
-
setModelReferenceFormatter
Sets the formatter that is used to formatILcdModelReference
instances when encoding an srsName.- Parameters:
aModelReferenceFormatter
- the model reference formatter for this encoder
-