Class SessionWriter
- java.lang.Object
-
- org.openstreetmap.josm.io.session.SessionWriter
-
public class SessionWriter extends java.lang.Object
Writes a .jos session file from current supported layers.- Since:
- 4685
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
SessionWriter.ExportSupport
A class that provides some context for the individualSessionLayerExporter
when doing the export.static class
SessionWriter.SessionWriterFlags
SessionWriter
options
-
Field Summary
Fields Modifier and Type Field Description private int
active
private MultiMap<Layer,Layer>
dependencies
private java.util.Map<Layer,SessionLayerExporter>
exporters
private java.util.List<Layer>
layers
private boolean
plugins
private static java.util.Map<java.lang.Class<? extends Layer>,java.lang.Class<? extends SessionLayerExporter>>
sessionLayerExporters
private boolean
zip
private java.util.zip.ZipOutputStream
zipOut
-
Constructor Summary
Constructors Constructor Description SessionWriter(java.util.List<Layer> layers, int active, java.util.Map<Layer,SessionLayerExporter> exporters, MultiMap<Layer,Layer> dependencies, boolean zip)
Constructs a newSessionWriter
.SessionWriter(java.util.List<Layer> layers, int active, java.util.Map<Layer,SessionLayerExporter> exporters, MultiMap<Layer,Layer> dependencies, SessionWriter.SessionWriterFlags... flags)
Constructs a newSessionWriter
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.w3c.dom.Document
createJosDocument()
Creates XML (.jos) session document.static SessionLayerExporter
getSessionLayerExporter(Layer layer)
Returns the session layer exporter for the given layer.static void
registerSessionLayerExporter(java.lang.Class<? extends Layer> layerClass, java.lang.Class<? extends SessionLayerExporter> exporter)
Register a session layer exporter.void
write(java.io.File f)
Writes session to given file.void
write(java.io.OutputStream out)
Writes session to given output stream.void
writeJos(org.w3c.dom.Document doc, java.io.OutputStream out)
Writes given .jos document to an output stream.private static void
writeProjection(org.w3c.dom.Element root)
private static void
writeViewPort(org.w3c.dom.Element root)
-
-
-
Field Detail
-
sessionLayerExporters
private static final java.util.Map<java.lang.Class<? extends Layer>,java.lang.Class<? extends SessionLayerExporter>> sessionLayerExporters
-
active
private final int active
-
exporters
private final java.util.Map<Layer,SessionLayerExporter> exporters
-
dependencies
private final MultiMap<Layer,Layer> dependencies
-
zip
private final boolean zip
-
plugins
private final boolean plugins
-
zipOut
private java.util.zip.ZipOutputStream zipOut
-
-
Constructor Detail
-
SessionWriter
public SessionWriter(java.util.List<Layer> layers, int active, java.util.Map<Layer,SessionLayerExporter> exporters, MultiMap<Layer,Layer> dependencies, boolean zip)
Constructs a newSessionWriter
.- Parameters:
layers
- The ordered list of layers to saveactive
- The index of active layer inlayers
(starts at 0). Ignored if set to -1exporters
- The exporters to use to save layersdependencies
- layer dependencieszip
-true
if a joz archive has to be created,false otherwise
- Since:
- 6271
-
SessionWriter
public SessionWriter(java.util.List<Layer> layers, int active, java.util.Map<Layer,SessionLayerExporter> exporters, MultiMap<Layer,Layer> dependencies, SessionWriter.SessionWriterFlags... flags)
Constructs a newSessionWriter
.- Parameters:
layers
- The ordered list of layers to saveactive
- The index of active layer inlayers
(starts at 0). Ignored if set to -1exporters
- The exporters to use to save layersdependencies
- layer dependenciesflags
- The flags to use when writing data- Since:
- 18833
-
-
Method Detail
-
registerSessionLayerExporter
public static void registerSessionLayerExporter(java.lang.Class<? extends Layer> layerClass, java.lang.Class<? extends SessionLayerExporter> exporter)
Register a session layer exporter.The exporter class must have a one-argument constructor with layerClass as formal parameter type.
- Parameters:
layerClass
- layer classexporter
- exporter for this layer class
-
getSessionLayerExporter
public static SessionLayerExporter getSessionLayerExporter(Layer layer)
Returns the session layer exporter for the given layer.- Parameters:
layer
- layer to export- Returns:
- session layer exporter for the given layer
- Throws:
java.lang.IllegalArgumentException
- if layer cannot be exported
-
createJosDocument
public org.w3c.dom.Document createJosDocument() throws java.io.IOException
Creates XML (.jos) session document.- Returns:
- new document
- Throws:
java.io.IOException
- if any I/O error occurs
-
writeViewPort
private static void writeViewPort(org.w3c.dom.Element root)
-
writeProjection
private static void writeProjection(org.w3c.dom.Element root)
-
writeJos
public void writeJos(org.w3c.dom.Document doc, java.io.OutputStream out) throws java.io.IOException
Writes given .jos document to an output stream.- Parameters:
doc
- session documentout
- output stream- Throws:
java.io.IOException
- if any I/O error occurs
-
write
public void write(java.io.File f) throws java.io.IOException
Writes session to given file.- Parameters:
f
- output file- Throws:
java.io.IOException
- if any I/O error occurs
-
write
public void write(java.io.OutputStream out) throws java.io.IOException
Writes session to given output stream.- Parameters:
out
- output stream- Throws:
java.io.IOException
- if any I/O error occurs
-
-