Ignore:
Timestamp:
2014-09-19T01:04:08+02:00 (10 years ago)
Author:
Don-vip
Message:

see #9704 - code refactorization for easier inheritance in pbf plugin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmExporter.java

    r7082 r7561  
    2222import org.openstreetmap.josm.tools.Utils;
    2323
     24/**
     25 * Exports data to an .Osm file.
     26 * @since 1949
     27 */
    2428public class OsmExporter extends FileExporter {
    2529
     
    3135    }
    3236
     37    /**
     38     * Constructs a new {@code OsmExporter}.
     39     * @param filter The extension file filter
     40     */
    3341    public OsmExporter(ExtensionFileFilter filter) {
    3442        super(filter);
     
    4755    }
    4856
     57    /**
     58     * Exports OSM data to the given file.
     59     * @param file Output file
     60     * @param layer Data layer. Must be an instance of {@link OsmDataLayer}.
     61     * @param noBackup if {@code true}, the potential backup file created if the output file already exists will be deleted
     62     *                 after a successful export
     63     * @throws IllegalArgumentException if {@code layer} is not an instance of {@code OsmDataLayer}
     64     */
    4965    public void exportData(File file, Layer layer, boolean noBackup) throws IllegalArgumentException {
    50         if (layer instanceof OsmDataLayer) {
    51             save(file, (OsmDataLayer) layer, noBackup);
    52         } else
     66        checkOsmDataLayer(layer);
     67        save(file, (OsmDataLayer) layer, noBackup);
     68    }
     69
     70    protected static final void checkOsmDataLayer(Layer layer) throws IllegalArgumentException {
     71        if (!(layer instanceof OsmDataLayer)) {
    5372            throw new IllegalArgumentException(MessageFormat.format("Expected instance of OsmDataLayer. Got ''{0}''.", layer
    5473                    .getClass().getName()));
     74        }
    5575    }
    5676
    57     protected OutputStream getOutputStream(File file) throws FileNotFoundException, IOException {
     77    protected static OutputStream getOutputStream(File file) throws FileNotFoundException, IOException {
    5878        return Compression.getCompressedFileOutputStream(file);
    5979    }
Note: See TracChangeset for help on using the changeset viewer.