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 a TLcdGML31ModelDescriptor. These models are instances of TLcdGML31Model or TLcdGML31AbstractFeatureCollection. Model elements are instances of TLcdGML31AbstractFeature.

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

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 Details

    • TLcdGML31ModelEncoder

      public TLcdGML31ModelEncoder()
      Creates a new TLcdGML31ModelEncoder, ready to use.
  • Method Details

    • canSave

      public boolean canSave(ILcdModel aModel)
      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

      public String getDisplayName()
      Description copied from interface: ILcdModelEncoder
      Returns a short, displayable name for the format this ILcdModelEncoder encodes to.
      Returns:
      the displayable name of this ILcdModelEncoder.
    • getEntityResolver

      public EntityResolver2 getEntityResolver()
      Description copied from class: ALcdXMLModelEncoder
      Returns the org.xml.sax.ext.EntityResolver2 that is used for creating input sources for XSD schemas.
      Specified by:
      getEntityResolver in class ALcdXMLModelEncoder
      Returns:
      the entity resolver to be used for creating input sources for XSD schemas.
    • getOutputStreamFactory

      public ILcdOutputStreamFactory getOutputStreamFactory()
      Description copied from class: ALcdXMLModelEncoder
      Returns the ILcdOutputStreamFactory that is used for creating output streams.
      Specified by:
      getOutputStreamFactory in interface ILcdOutputStreamFactoryCapable
      Specified by:
      getOutputStreamFactory in class ALcdXMLModelEncoder
      Returns:
      the ILcdOutputStreamFactory that is used for creating output streams.
      See Also:
    • getXMLOutputFactory

      public XMLOutputFactory getXMLOutputFactory()
      Description copied from class: ALcdXMLModelEncoder
      Returns the javax.xml.stream.XMLOutputFactory that is used by this encoder for creating javax.xml.stream.XMLStreamWriter instances.
      Specified by:
      getXMLOutputFactory in class ALcdXMLModelEncoder
      Returns:
      the javax.xml.stream.XMLOutputFactory that is used by this encoder for creating javax.xml.stream.XMLStreamWriter instances.
    • save

      public void save(ILcdModel aModel) throws IllegalArgumentException, IOException
      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

      public void setEntityResolver(EntityResolver2 aEntityResolver)
      Description copied from class: ALcdXMLModelEncoder
      Sets the org.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 class ALcdXMLModelEncoder
      Parameters:
      aEntityResolver - the entity resolver to be used for creating input sources for XSD schemas.
    • setOutputStreamFactory

      public void setOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory)
      Description copied from class: ALcdXMLModelEncoder
      Sets the ILcdOutputStreamFactory 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 interface ILcdOutputStreamFactoryCapable
      Specified by:
      setOutputStreamFactory in class ALcdXMLModelEncoder
      Parameters:
      aOutputStreamFactory - the output stream factory to be used by this model encoder.
      See Also:
    • setXMLOutputFactory

      public void setXMLOutputFactory(XMLOutputFactory aXMLOutputFactory)
      Description copied from class: ALcdXMLModelEncoder
      Sets the javax.xml.stream.XMLOutputFactory to be used by this encoder for creating javax.xml.stream.XMLStreamWriter instances.
      Specified by:
      setXMLOutputFactory in class ALcdXMLModelEncoder
      Parameters:
      aXMLOutputFactory - the javax.xml.stream.XMLOutputFactory to be used by this encoder for creating javax.xml.stream.XMLStreamWriter instances.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getDefaultTargetNamespace

      public String 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

      public void setDefaultTargetNamespace(String aTargetNamespace)
      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()
      Returns true 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 to true, this means that two output streams will be created when the save or export 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

      public boolean canExport(ILcdModel aModel, String aDestinationName)
      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

      public void export(ILcdModel aModel, String aDestinationName) throws IOException
      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

      public void export(ILcdModel aModel, Result aDestination) throws IOException

      Exports the given model to a destination result.

      Overrides:
      export in class ALcdXMLModelEncoder
      Parameters:
      aModel - the model to export
      aDestination - 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

      public void exportSchema(ILcdModel aModel, String aDestinationName) throws IOException
      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

      public ILcdModelReferenceFormatter getModelReferenceFormatter()
      Returns the model reference formatter that is used to format ILcdModelReference instances when encoding an srsName.
      Returns:
      the model reference formatter of this encoder
    • setModelReferenceFormatter

      public void setModelReferenceFormatter(ILcdModelReferenceFormatter aModelReferenceFormatter)
      Sets the formatter that is used to format ILcdModelReference instances when encoding an srsName.
      Parameters:
      aModelReferenceFormatter - the model reference formatter for this encoder