Class SessionReader
java.lang.Object
org.openstreetmap.josm.io.session.SessionReader
Reads a .jos session file and loads the layers in the process.
- Since:
- 4668
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classShow Dialog when there is an error for one layer.classA class that provides some context for the individualSessionLayerImporterwhen doing the import.static classA dependency of another layerstatic classData class for projection saved in the session file.static classData class for viewport saved in the session file. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate InputStreamcreateInputStream(File sessionFile, boolean zip) private static voidReturns active layer.private static ElementgetElementByTagName(Element root, String name) Returns list of layers that are later added to the mapview.Returns actions executed in EDT after layers have been added.Returns the projection choice data.static SessionLayerImportergetSessionLayerImporter(String layerType) Returns the session layer importer for the given layer type.Returns the viewport (map position and scale).private static InputStreamgetZipInputStream(ZipFile zipFile) booleanReturns whether plugins loaded additonal dataprivate voidvoidloadSession(File sessionFile, boolean zip, ProgressMonitor progressMonitor) Loads session from the given file.voidloadSession(InputStream josIS, URI sessionFileURI, boolean zip, ProgressMonitor progressMonitor) Loads session from the given input stream.private voidparseJos(Document doc, ProgressMonitor progressMonitor) private static SessionReader.SessionProjectionChoiceDataprivate static SessionReader.SessionViewportDatareadViewportData(Element root) static voidregisterSessionLayerImporter(String layerType, Class<? extends SessionLayerImporter> importer) Register a session layer importer.private static voidsetLayerAttributes(Layer layer, Element e)
-
Field Details
-
sessionLayerImporters
-
sessionFileURI
-
zip
-
pluginData
-
zipFile
-
layers
-
active
-
postLoadTasks
-
viewport
-
projectionChoice
-
-
Constructor Details
-
SessionReader
public SessionReader()
-
-
Method Details
-
registerSessionLayerImporter
public static void registerSessionLayerImporter(String layerType, Class<? extends SessionLayerImporter> importer) Register a session layer importer.- Parameters:
layerType- layer typeimporter- importer for this layer class
-
getSessionLayerImporter
Returns the session layer importer for the given layer type.- Parameters:
layerType- layer type to import- Returns:
- session layer importer for the given layer
-
getLayers
Returns list of layers that are later added to the mapview.- Returns:
- list of layers that are later added to the mapview
-
getActive
Returns active layer.- Returns:
- active layer, or
nullif not set - Since:
- 6271
-
getPostLoadTasks
Returns actions executed in EDT after layers have been added.- Returns:
- actions executed in EDT after layers have been added (message dialog, etc.)
-
getViewport
Returns the viewport (map position and scale).- Returns:
- the viewport; can be null when no viewport info is found in the file
-
getProjectionChoice
Returns the projection choice data.- Returns:
- the projection; can be null when no projection info is found in the file
-
loadedPluginData
Returns whether plugins loaded additonal data- Returns:
trueif at least one plugin loaded additional data- Since:
- 18833
-
error
- Throws:
IllegalDataException
-
parseJos
- Throws:
IllegalDataException
-
setLayerAttributes
-
readViewportData
-
readProjectionChoiceData
-
loadPluginData
-
loadSession
public void loadSession(File sessionFile, boolean zip, ProgressMonitor progressMonitor) throws IllegalDataException, IOException Loads session from the given file.- Parameters:
sessionFile- session file to loadzip-trueif it's a zipped session (.joz)progressMonitor- progress monitor- Throws:
IllegalDataException- if invalid data is detectedIOException- if any I/O error occurs
-
createInputStream
private InputStream createInputStream(File sessionFile, boolean zip) throws IOException, IllegalDataException - Throws:
IOExceptionIllegalDataException
-
getZipInputStream
private static InputStream getZipInputStream(ZipFile zipFile) throws IOException, IllegalDataException - Throws:
IOExceptionIllegalDataException
-
loadSession
public void loadSession(InputStream josIS, URI sessionFileURI, boolean zip, ProgressMonitor progressMonitor) throws IOException, IllegalDataException Loads session from the given input stream.- Parameters:
josIS- session stream to loadzip-trueif it's a zipped session (.joz)sessionFileURI- URI of the underlying session fileprogressMonitor- progress monitor- Throws:
IllegalDataException- if invalid data is detectedIOException- if any I/O error occurs- Since:
- 15070
-
getElementByTagName
-