Class Writer
java.lang.Object
org.apache.sis.internal.storage.xml.stream.StaxStreamIO
org.apache.sis.internal.storage.xml.stream.StaxStreamWriter
org.apache.sis.internal.storage.gpx.Writer
- All Implemented Interfaces:
AutoCloseable,Consumer<AbstractFeature>
Writer for GPX 1.0 and 1.1 files.
- Since:
- 0.8
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MetadataThe metadata to write, ornullif none.private final intThe GPX file version: 0 for GPX 1.0 or 1 for GPX 1.1.Fields inherited from class org.apache.sis.internal.storage.xml.stream.StaxStreamWriter
writerFields inherited from class org.apache.sis.internal.storage.xml.stream.StaxStreamIO
owner -
Constructor Summary
ConstructorsConstructorDescriptionWriter(WritableStore owner, Metadata metadata, OutputStream temporary) Creates a new GPX writer for the given data store. -
Method Summary
Modifier and TypeMethodDescriptionvoidwrite(AbstractFeature feature) Writes the given feature.private voidwriteLinks(Collection<?> links) Writes multiple links.private voidwriteSingle(Fix fix) Writes the value of the given enumeration.voidWrites the XML declaration followed by GPX metadata.private voidwriteWayPoint(AbstractFeature feature, String tagName) Writes a way point, which may be standalone or part of a route or a track segment.Methods inherited from class org.apache.sis.internal.storage.xml.stream.StaxStreamWriter
accept, close, marshal, writeEndDocument, writeList, writeSingle, writeSingleValueMethods inherited from class org.apache.sis.internal.storage.xml.stream.StaxStreamIO
errors
-
Field Details
-
version
private final int versionThe GPX file version: 0 for GPX 1.0 or 1 for GPX 1.1. -
metadata
The metadata to write, ornullif none.
-
-
Constructor Details
-
Writer
Writer(WritableStore owner, Metadata metadata, OutputStream temporary) throws DataStoreException, XMLStreamException, IOException Creates a new GPX writer for the given data store.- Parameters:
owner- the data store for which this writer is created.metadata- the metadata to write, ornullif none.temporary- the temporary stream where to write, ornullfor the main storage.- Throws:
DataStoreException- if the output type is not recognized or the data store is closed.XMLStreamException- if an error occurred while opening the XML file.IOException- if an error occurred while preparing the output stream.
-
-
Method Details
-
writeStartDocument
Writes the XML declaration followed by GPX metadata. This method shall be invoked exactly once beforewrite(Feature).- Overrides:
writeStartDocumentin classStaxStreamWriter- Throws:
Exception- if an error occurred while writing to the XML file.
-
write
public void write(AbstractFeature feature) throws DataStoreException, XMLStreamException, JAXBException Writes the given feature.- Specified by:
writein classStaxStreamWriter- Parameters:
feature- the feature to write, ornullif none.- Throws:
DataStoreException- if the given feature is not a recognized type.XMLStreamException- if underlying STAX writer encounter an error.JAXBException- if underlying JAXB marshaller encounter an error.
-
writeWayPoint
private void writeWayPoint(AbstractFeature feature, String tagName) throws XMLStreamException, JAXBException Writes a way point, which may be standalone or part of a route or a track segment.- Parameters:
feature- feature to write, ornullif none.tagName- way point tag name (cannot benull).- Throws:
XMLStreamException- if underlying STAX writer encounter an error.JAXBException- if underlying JAXB marshaller encounter an error.
-
writeSingle
Writes the value of the given enumeration. This method does nothing if the given value is null.- Throws:
XMLStreamException
-
writeLinks
Writes multiple links. This method does nothing if the given list is null.- Parameters:
links- the links to write.- Throws:
XMLStreamException- if underlying STAX writer encounter an error.JAXBException- if underlying JAXB marshaller encounter an error.
-