Class FileImporter
- java.lang.Object
-
- org.openstreetmap.josm.gui.io.importexport.FileImporter
-
- All Implemented Interfaces:
java.lang.Comparable<FileImporter>
- Direct Known Subclasses:
AllFormatsImporter
,GpxImporter
,GpxLikeImporter
,ImageImporter
,NoteImporter
,OsmChangeImporter
,OsmImporter
,SessionImporter
,WMSLayerImporter
public abstract class FileImporter extends java.lang.Object implements java.lang.Comparable<FileImporter>
Abstract file importer.- Since:
- 1637, 10386 (signature)
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
enabled
ExtensionFileFilter
filter
The extension file filter used to accept files.protected java.util.EnumSet<Options>
options
-
Constructor Summary
Constructors Modifier Constructor Description protected
FileImporter(ExtensionFileFilter filter)
Constructs a newFileImporter
with the given extension file filter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acceptFile(java.io.File pathname)
Determines if this file importer accepts the given file.int
compareTo(FileImporter other)
private static void
displayCancel(java.lang.Throwable t)
private static void
displayError(java.io.File f, java.lang.Exception e)
double
getPriority()
If multiple files (with multiple file formats) are selected, they are opened in the order of their priorities.void
importData(java.io.File file, ProgressMonitor progressMonitor)
Needs to be implemented if isBatchImporter() returns false.void
importData(java.util.List<java.io.File> files, ProgressMonitor progressMonitor)
Needs to be implemented if isBatchImporter() returns true.boolean
importDataHandleExceptions(java.io.File f, ProgressMonitor progressMonitor)
Wrapper toimportData(File, ProgressMonitor)
to give meaningful output if things go wrong.boolean
importDataHandleExceptions(java.util.List<java.io.File> files, ProgressMonitor progressMonitor)
Wrapper toimportData(List, ProgressMonitor)
to give meaningful output if things go wrong.boolean
isBatchImporter()
A batch importer is a file importer that prefers to read multiple files at the same time.boolean
isEnabled()
Returns the enabled state of thisFileImporter
.void
setEnabled(boolean enabled)
Sets the enabled state of theFileImporter
.void
setOptions(Options[] options)
Set the options for theFileImporter
.
-
-
-
Field Detail
-
filter
public final ExtensionFileFilter filter
The extension file filter used to accept files.
-
enabled
private boolean enabled
-
-
Constructor Detail
-
FileImporter
protected FileImporter(ExtensionFileFilter filter)
Constructs a newFileImporter
with the given extension file filter.- Parameters:
filter
- The extension file filter
-
-
Method Detail
-
acceptFile
public boolean acceptFile(java.io.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(java.io.File file, ProgressMonitor progressMonitor) throws java.io.IOException, IllegalDataException
Needs to be implemented if isBatchImporter() returns false.- Parameters:
file
- file to importprogressMonitor
- progress monitor- Throws:
java.io.IOException
- if any I/O error occursIllegalDataException
- if invalid data is read
-
importData
public void importData(java.util.List<java.io.File> files, ProgressMonitor progressMonitor) throws java.io.IOException, IllegalDataException
Needs to be implemented if isBatchImporter() returns true.- Parameters:
files
- files to importprogressMonitor
- progress monitor- Throws:
java.io.IOException
- if any I/O error occursIllegalDataException
- if invalid data is read
-
importDataHandleExceptions
public boolean importDataHandleExceptions(java.io.File f, ProgressMonitor progressMonitor)
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
private static void displayError(java.io.File f, java.lang.Exception e)
-
displayCancel
private static void displayCancel(java.lang.Throwable t)
-
importDataHandleExceptions
public boolean importDataHandleExceptions(java.util.List<java.io.File> files, ProgressMonitor progressMonitor)
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
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 interfacejava.lang.Comparable<FileImporter>
-
isEnabled
public final boolean isEnabled()
Returns the enabled state of thisFileImporter
. 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 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
public final void setOptions(Options[] options)
Set the options for theFileImporter
.- Parameters:
options
- The options to set- Since:
- 17534
-
-