Humboldt Alignment Editor 2.5.0

eu.esdihumboldt.hale.io.gml.writer.internal
Class StreamGmlWriter

java.lang.Object
  extended by eu.esdihumboldt.hale.common.core.io.impl.AbstractIOProvider
      extended by eu.esdihumboldt.hale.common.core.io.impl.AbstractExportProvider
          extended by eu.esdihumboldt.hale.common.core.io.impl.GZipEnabledExport
              extended by eu.esdihumboldt.hale.common.instance.io.impl.AbstractInstanceWriter
                  extended by eu.esdihumboldt.hale.io.gml.writer.internal.StreamGmlWriter
All Implemented Interfaces:
ExportProvider, IOProvider, InstanceWriter, XmlWriterBase
Direct Known Subclasses:
GmlInstanceWriter, XmlInstanceWriter

public class StreamGmlWriter
extends AbstractInstanceWriter
implements XmlWriterBase

Writes GML/XML using a XMLStreamWriter

Author:
Simon Templer
Partner:
01 / Fraunhofer Institute for Computer Graphics Research

Nested Class Summary
 
Nested classes/interfaces inherited from class eu.esdihumboldt.hale.common.core.io.impl.GZipEnabledExport
GZipEnabledExport.GZipOutputSupplier
 
Field Summary
static String PARAM_SIMPLIFY_GEOMETRY
          The parameter name for the flag specifying if a geometry should be simplified before writing it, if possible.
static String SCHEMA_INSTANCE_NS
          Schema instance namespace (for specifying schema locations)
 
Fields inherited from interface eu.esdihumboldt.hale.io.gml.writer.XmlWriterBase
PARAM_ROOT_ELEMENT_NAME, PARAM_ROOT_ELEMENT_NAMESPACE
 
Fields inherited from interface eu.esdihumboldt.hale.common.core.io.IOProvider
PARAM_CONTENT_TYPE
 
Fields inherited from interface eu.esdihumboldt.hale.common.core.io.ExportProvider
PARAM_TARGET
 
Constructor Summary
StreamGmlWriter(boolean useFeatureCollection)
          Create a GML writer
 
Method Summary
 void checkCompatibility()
          Validate the basic InstanceWriter configuration, to determine if the target schema (and instances if set) are compatible to the writer.
protected  IOReport execute(ProgressIndicator progress, IOReporter reporter)
          Execute the I/O provider.
protected  XmlElement findDefaultContainter(XmlIndex targetIndex, IOReporter reporter)
          Find the default container element.
protected  DefinitionPath findMemberAttribute(TypeDefinition container, QName containerName, TypeDefinition memberType)
          Find a matching attribute for the given member type in the given container type
static XmlElement getConfiguredContainerElement(IOProvider provider, XmlIndex targetIndex)
          Get the for an I/O provider configured target container element, assuming the I/O provider uses the XmlWriterBase.PARAM_ROOT_ELEMENT_NAMESPACE and parameters for this.
protected  String getDefaultTypeName()
          Get the default type name if no content type is provided
protected  StreamGeometryWriter getGeometryWriter()
          Get the geometry writer
protected  XmlIndex getXMLIndex()
          Get the XML type index.
static XmlIndex getXMLIndex(SchemaSpace schemas)
          Get the XML index from the given schema space
 boolean isCancelable()
          States if the execution of the provider is cancelable
protected  boolean requiresDefaultContainer()
          States if the instance writer in all cases requires that the default container is being found.
 void validate()
          Additionally checks for instances.
 void write(InstanceCollection instances, ProgressIndicator progress, IOReporter reporter)
          Write the given instances.
protected  void writeMember(Instance instance, TypeDefinition type)
          Write a given instance
 
Methods inherited from class eu.esdihumboldt.hale.common.instance.io.impl.AbstractInstanceWriter
getInstances, getTargetSchema, getValidationSchemas, setInstances, setTargetSchema
 
Methods inherited from class eu.esdihumboldt.hale.common.core.io.impl.GZipEnabledExport
getTarget
 
Methods inherited from class eu.esdihumboldt.hale.common.core.io.impl.AbstractExportProvider
createReporter, setParameter, setTarget, storeConfiguration
 
Methods inherited from class eu.esdihumboldt.hale.common.core.io.impl.AbstractIOProvider
addSupportedParameter, execute, fail, getContentType, getParameter, getSupportedParameters, getTypeName, loadConfiguration, setContentType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface eu.esdihumboldt.hale.io.gml.writer.XmlWriterBase
getTargetSchema
 
Methods inherited from interface eu.esdihumboldt.hale.common.core.io.IOProvider
createReporter, execute, getContentType, getParameter, getSupportedParameters, loadConfiguration, setContentType, setParameter, storeConfiguration
 
Methods inherited from interface eu.esdihumboldt.hale.common.core.io.ExportProvider
getTarget, setTarget
 

Field Detail

SCHEMA_INSTANCE_NS

public static final String SCHEMA_INSTANCE_NS
Schema instance namespace (for specifying schema locations)

See Also:
Constant Field Values

PARAM_SIMPLIFY_GEOMETRY

public static final String PARAM_SIMPLIFY_GEOMETRY
The parameter name for the flag specifying if a geometry should be simplified before writing it, if possible. Defaults to true.

See Also:
Constant Field Values
Constructor Detail

StreamGmlWriter

public StreamGmlWriter(boolean useFeatureCollection)
Create a GML writer

Parameters:
useFeatureCollection - if a GML feature collection shall be used to store the instances (if possible)
Method Detail

execute

protected IOReport execute(ProgressIndicator progress,
                           IOReporter reporter)
                    throws IOProviderConfigurationException,
                           IOException
Description copied from class: AbstractIOProvider
Execute the I/O provider.

Specified by:
execute in class AbstractIOProvider
Parameters:
progress - the progress indicator
reporter - the reporter to use for the execution report
Returns:
the execution report
Throws:
IOProviderConfigurationException - if the I/O provider was not configured properly
IOException - if an I/O operation fails
See Also:
AbstractIOProvider.execute(ProgressIndicator, IOReporter)

validate

public void validate()
              throws IOProviderConfigurationException
Description copied from class: AbstractInstanceWriter
Additionally checks for instances.

Specified by:
validate in interface IOProvider
Overrides:
validate in class AbstractInstanceWriter
Throws:
IOProviderConfigurationException - if the I/O provider was not configured properly
See Also:
AbstractInstanceWriter.validate()

checkCompatibility

public void checkCompatibility()
                        throws IOProviderConfigurationException
Description copied from interface: InstanceWriter
Validate the basic InstanceWriter configuration, to determine if the target schema (and instances if set) are compatible to the writer. Other parameters should be ignored for the check.

Specified by:
checkCompatibility in interface InstanceWriter
Overrides:
checkCompatibility in class AbstractInstanceWriter
Throws:
IOProviderConfigurationException - if the I/O provider was not configured properly
See Also:
AbstractInstanceWriter.checkCompatibility()

requiresDefaultContainer

protected boolean requiresDefaultContainer()
States if the instance writer in all cases requires that the default container is being found.

Returns:
if the default container must be present in the target schema

getXMLIndex

protected XmlIndex getXMLIndex()
Get the XML type index.

Returns:
the target type index

getXMLIndex

public static XmlIndex getXMLIndex(SchemaSpace schemas)
Get the XML index from the given schema space

Parameters:
schemas - the schema space
Returns:
the XML index or null

isCancelable

public boolean isCancelable()
Description copied from interface: IOProvider
States if the execution of the provider is cancelable

Specified by:
isCancelable in interface IOProvider
Returns:
if the execution is cancelable
See Also:
IOProvider.isCancelable()

getDefaultTypeName

protected String getDefaultTypeName()
Description copied from class: AbstractIOProvider
Get the default type name if no content type is provided

Specified by:
getDefaultTypeName in class AbstractIOProvider
Returns:
the default content type
See Also:
AbstractIOProvider.getDefaultTypeName()

write

public void write(InstanceCollection instances,
                  ProgressIndicator progress,
                  IOReporter reporter)
           throws XMLStreamException
Write the given instances.

Parameters:
instances - the instance collection
reporter - the reporter
progress - the progress
Throws:
XMLStreamException - if writing the feature collection fails

getConfiguredContainerElement

public static XmlElement getConfiguredContainerElement(IOProvider provider,
                                                       XmlIndex targetIndex)
Get the for an I/O provider configured target container element, assuming the I/O provider uses the XmlWriterBase.PARAM_ROOT_ELEMENT_NAMESPACE and parameters for this.

Parameters:
provider - the I/O provider
targetIndex - the target XML index
Returns:
the container element or null if it was not found

findDefaultContainter

protected XmlElement findDefaultContainter(XmlIndex targetIndex,
                                           IOReporter reporter)
Find the default container element.

Parameters:
targetIndex - the target type index
reporter - the reporter, may be null
Returns:
the container XML element or null

findMemberAttribute

protected DefinitionPath findMemberAttribute(TypeDefinition container,
                                             QName containerName,
                                             TypeDefinition memberType)
Find a matching attribute for the given member type in the given container type

Parameters:
container - the container type
containerName - the container element name
memberType - the member type
Returns:
the attribute definition or null

writeMember

protected void writeMember(Instance instance,
                           TypeDefinition type)
                    throws XMLStreamException
Write a given instance

Parameters:
instance - the instance to writer
type - the feature type definition
Throws:
XMLStreamException - if writing the feature fails

getGeometryWriter

protected StreamGeometryWriter getGeometryWriter()
Get the geometry writer

Returns:
the geometry writer instance to use

Humboldt Alignment Editor 2.5.0

Build 2012-12-03_12-30-59
Revision 9d2dd4b0318cda9f1393b1ddd390f7f792d70a2d