Class FileImporter

java.lang.Object
org.openstreetmap.josm.gui.io.importexport.FileImporter
All Implemented Interfaces:
Comparable<FileImporter>
Direct Known Subclasses:
AllFormatsImporter, GpxImporter, GpxLikeImporter, ImageImporter, NoteImporter, OsmChangeImporter, OsmImporter, SessionImporter, WMSLayerImporter

public abstract class FileImporter extends Object implements Comparable<FileImporter>
Abstract file importer.
Since:
1637, 10386 (signature)
  • Field Details

  • Constructor Details

    • FileImporter

      protected FileImporter(ExtensionFileFilter filter)
      Constructs a new FileImporter with the given extension file filter.
      Parameters:
      filter - The extension file filter
  • Method Details

    • acceptFile

      public boolean acceptFile(File pathname)
      Determines if this file importer accepts the given file.
      Parameters:
      pathname - The file to test
      Returns:
      true if this file importer accepts the given file, false otherwise
    • isBatchImporter

      public boolean isBatchImporter()
      A batch importer is a file importer that prefers to read multiple files at the same time.
      Returns:
      true if this importer is a batch importer
    • importData

      public void importData(File file, ProgressMonitor progressMonitor) throws IOException, IllegalDataException
      Needs to be implemented if isBatchImporter() returns false.
      Parameters:
      file - file to import
      progressMonitor - progress monitor
      Throws:
      IOException - if any I/O error occurs
      IllegalDataException - if invalid data is read
    • importData

      public void importData(List<File> files, ProgressMonitor progressMonitor) throws IOException, IllegalDataException
      Needs to be implemented if isBatchImporter() returns true.
      Parameters:
      files - files to import
      progressMonitor - progress monitor
      Throws:
      IOException - if any I/O error occurs
      IllegalDataException - if invalid data is read
    • importDataHandleExceptions

      public boolean importDataHandleExceptions(File f, ProgressMonitor progressMonitor)
      Wrapper to importData(File, ProgressMonitor) to give meaningful output if things go wrong.
      Parameters:
      f - data file to import
      progressMonitor - progress monitor
      Returns:
      true if data import was successful
    • displayError

      private static void displayError(File f, Exception e)
    • displayCancel

      private static void displayCancel(Throwable t)
    • importDataHandleExceptions

      public boolean importDataHandleExceptions(List<File> files, ProgressMonitor progressMonitor)
      Wrapper to importData(List, ProgressMonitor) to give meaningful output if things go wrong.
      Parameters:
      files - data files to import
      progressMonitor - progress monitor
      Returns:
      true if data import was successful
    • getPriority

      public double getPriority()
      If multiple files (with multiple file formats) are selected, they are opened in the order of their priorities. Highest priority comes first.
      Returns:
      priority
    • compareTo

      public int compareTo(FileImporter other)
      Specified by:
      compareTo in interface Comparable<FileImporter>
    • isEnabled

      public final boolean isEnabled()
      Returns the enabled state of this FileImporter. When enabled, it is listed and usable in "File → Open" dialog.
      Returns:
      true if this FileImporter is enabled
      Since:
      5459
    • setEnabled

      public final void setEnabled(boolean enabled)
      Sets the enabled state of the FileImporter. When enabled, it is listed and usable in "File → Open" dialog.
      Parameters:
      enabled - true to enable this FileImporter, false to disable it
      Since:
      5459
    • setOptions

      public final void setOptions(Options[] options)
      Set the options for the FileImporter.
      Parameters:
      options - The options to set
      Since:
      17534