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
Abstract file importer.
- Since:
- 1637, 10386 (signature)
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFileImporter(ExtensionFileFilter filter) Constructs a newFileImporterwith the given extension file filter. -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptFile(File pathname) Determines if this file importer accepts the given file.intcompareTo(FileImporter other) private static voidprivate static voiddisplayError(File f, Exception e) doubleIf multiple files (with multiple file formats) are selected, they are opened in the order of their priorities.voidimportData(File file, ProgressMonitor progressMonitor) Needs to be implemented if isBatchImporter() returns false.voidimportData(List<File> files, ProgressMonitor progressMonitor) Needs to be implemented if isBatchImporter() returns true.booleanimportDataHandleExceptions(File f, ProgressMonitor progressMonitor) Wrapper toimportData(File, ProgressMonitor)to give meaningful output if things go wrong.booleanimportDataHandleExceptions(List<File> files, ProgressMonitor progressMonitor) Wrapper toimportData(List, ProgressMonitor)to give meaningful output if things go wrong.booleanA batch importer is a file importer that prefers to read multiple files at the same time.final booleanReturns the enabled state of thisFileImporter.final voidsetEnabled(boolean enabled) Sets the enabled state of theFileImporter.final voidsetOptions(Options[] options) Set the options for theFileImporter.
-
Field Details
-
filter
The extension file filter used to accept files. -
enabled
-
options
-
-
Constructor Details
-
FileImporter
Constructs a newFileImporterwith the given extension file filter.- Parameters:
filter- The extension file filter
-
-
Method Details
-
acceptFile
Determines if this file importer accepts the given file.- Parameters:
pathname- The file to test- Returns:
trueif this file importer accepts the given file,falseotherwise
-
isBatchImporter
A batch importer is a file importer that prefers to read multiple files at the same time.- Returns:
trueif 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 importprogressMonitor- progress monitor- Throws:
IOException- if any I/O error occursIllegalDataException- 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 importprogressMonitor- progress monitor- Throws:
IOException- if any I/O error occursIllegalDataException- if invalid data is read
-
importDataHandleExceptions
Wrapper toimportData(File, ProgressMonitor)to give meaningful output if things go wrong.- Parameters:
f- data file to importprogressMonitor- progress monitor- Returns:
- true if data import was successful
-
displayError
-
displayCancel
-
importDataHandleExceptions
Wrapper toimportData(List, ProgressMonitor)to give meaningful output if things go wrong.- Parameters:
files- data files to importprogressMonitor- progress monitor- Returns:
- true if data import was successful
-
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
- Specified by:
compareToin interfaceComparable<FileImporter>
-
isEnabled
Returns the enabled state of thisFileImporter. When enabled, it is listed and usable in "File → Open" dialog.- Returns:
- true if this
FileImporteris enabled - Since:
- 5459
-
setEnabled
Sets the enabled state of theFileImporter. When enabled, it is listed and usable in "File → Open" dialog.- Parameters:
enabled- true to enable thisFileImporter, false to disable it- Since:
- 5459
-
setOptions
Set the options for theFileImporter.- Parameters:
options- The options to set- Since:
- 17534
-