Class OsmExporter
- java.lang.Object
-
- org.openstreetmap.josm.gui.io.importexport.FileExporter
-
- org.openstreetmap.josm.gui.io.importexport.OsmExporter
-
- All Implemented Interfaces:
MainLayerManager.ActiveLayerChangeListener
- Direct Known Subclasses:
OsmBzip2Exporter
,OsmGzipExporter
,OsmXzExporter
public class OsmExporter extends FileExporter
Exports data to an .osm file.- Since:
- 1949
-
-
Field Summary
-
Fields inherited from class org.openstreetmap.josm.gui.io.importexport.FileExporter
filter
-
-
Constructor Summary
Constructors Constructor Description OsmExporter()
Constructs a newOsmExporter
.OsmExporter(ExtensionFileFilter filter)
Constructs a newOsmExporter
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acceptFile(java.io.File pathname, Layer layer)
Check if this exporter can export a certain layer to a certain file.protected void
doSave(java.io.File file, OsmDataLayer layer)
void
exportData(java.io.File file, Layer layer)
Execute the data export.void
exportData(java.io.File file, Layer layer, boolean isAutosave)
Exports OSM data to the given file.protected static java.io.OutputStream
getOutputStream(java.io.File file)
private void
save(java.io.File file, OsmDataLayer layer, boolean isAutosave)
-
Methods inherited from class org.openstreetmap.josm.gui.io.importexport.FileExporter
activeOrEditLayerChanged, exportDataQuiet, isCanceled, isEnabled, setCanceled, setEnabled
-
-
-
-
Constructor Detail
-
OsmExporter
public OsmExporter()
Constructs a newOsmExporter
.
-
OsmExporter
public OsmExporter(ExtensionFileFilter filter)
Constructs a newOsmExporter
.- Parameters:
filter
- The extension file filter
-
-
Method Detail
-
acceptFile
public boolean acceptFile(java.io.File pathname, Layer layer)
Description copied from class:FileExporter
Check if this exporter can export a certain layer to a certain file. Most exporters support just a single layer type.- Overrides:
acceptFile
in classFileExporter
- Parameters:
pathname
- the target file name (check file extension using theFileExporter.filter
layer
- the layer requested for export- Returns:
- true, if the exporter can handle the layer and filename is okay
-
exportData
public void exportData(java.io.File file, Layer layer) throws java.io.IOException
Description copied from class:FileExporter
Execute the data export. (To be overridden by subclasses.)- Overrides:
exportData
in classFileExporter
- Parameters:
file
- target filelayer
- the layer to export- Throws:
java.io.IOException
- in case of an IO error
-
exportData
public void exportData(java.io.File file, Layer layer, boolean isAutosave) throws java.io.IOException
Exports OSM data to the given file.- Parameters:
file
- Output filelayer
- Data layer. Must be an instance ofOsmDataLayer
.isAutosave
- iftrue
, the potential backup file created if the output file already exists will be deleted after a successful export and post-save events won't be fired- Throws:
java.io.IOException
- in case of IO errorsjava.nio.file.InvalidPathException
- when file name cannot be converted into a Pathjava.lang.IllegalArgumentException
- iflayer
is not an instance ofOsmDataLayer
-
getOutputStream
protected static java.io.OutputStream getOutputStream(java.io.File file) throws java.io.IOException
- Throws:
java.io.IOException
-
save
private void save(java.io.File file, OsmDataLayer layer, boolean isAutosave) throws java.io.IOException
- Throws:
java.io.IOException
-
doSave
protected void doSave(java.io.File file, OsmDataLayer layer) throws java.io.IOException
- Throws:
java.io.IOException
-
-