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 Metadata
The metadata to write, ornull
if none.private final int
The 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
writer
Fields 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 TypeMethodDescriptionvoid
write
(AbstractFeature feature) Writes the given feature.private void
writeLinks
(Collection<?> links) Writes multiple links.private void
writeSingle
(Fix fix) Writes the value of the given enumeration.void
Writes the XML declaration followed by GPX metadata.private void
writeWayPoint
(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, writeSingleValue
Methods 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, ornull
if 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, ornull
if none.temporary
- the temporary stream where to write, ornull
for 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:
writeStartDocument
in 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:
write
in classStaxStreamWriter
- Parameters:
feature
- the feature to write, ornull
if 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, ornull
if 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.
-