org.openstreetmap.josm.io
Class FileImporter

java.lang.Object
  extended by org.openstreetmap.josm.io.FileImporter
All Implemented Interfaces:
java.lang.Comparable<FileImporter>, MapView.LayerChangeListener
Direct Known Subclasses:
AllFormatsImporter, GpxImporter, JpgImporter, NMEAImporter, OsmChangeImporter, OsmImporter, WMSLayerImporter

public abstract class FileImporter
extends java.lang.Object
implements java.lang.Comparable<FileImporter>, MapView.LayerChangeListener


Field Summary
private  boolean enabled
           
 ExtensionFileFilter filter
           
 
Constructor Summary
FileImporter(ExtensionFileFilter filter)
           
 
Method Summary
 boolean acceptFile(java.io.File pathname)
           
 void activeLayerChange(Layer oldLayer, Layer newLayer)
          Notifies this listener that the active layer has changed.
 int compareTo(FileImporter other)
           
static org.apache.tools.bzip2.CBZip2InputStream getBZip2InputStream(java.io.InputStream in)
           
static java.util.zip.GZIPInputStream getGZipInputStream(java.io.InputStream in)
           
 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 to give meaningful output if things go wrong.
 boolean importDataHandleExceptions(java.util.List<java.io.File> files, ProgressMonitor progressMonitor)
           
 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 this FileImporter.
 void layerAdded(Layer newLayer)
          Notifies this listener that a layer has been added.
 void layerRemoved(Layer oldLayer)
          Notifies this listener that a layer has been removed.
 void setEnabled(boolean enabled)
          Sets the enabled state of the FileImporter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filter

public final ExtensionFileFilter filter

enabled

private boolean enabled
Constructor Detail

FileImporter

public FileImporter(ExtensionFileFilter filter)
Method Detail

acceptFile

public boolean acceptFile(java.io.File pathname)

isBatchImporter

public boolean isBatchImporter()
A batch importer is a file importer that prefers to read multiple files at the same time.


importData

public void importData(java.io.File file,
                       ProgressMonitor progressMonitor)
                throws java.io.IOException,
                       IllegalDataException
Needs to be implemented if isBatchImporter() returns false.

Throws:
java.io.IOException
IllegalDataException

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.

Throws:
java.io.IOException
IllegalDataException

importDataHandleExceptions

public boolean importDataHandleExceptions(java.io.File f,
                                          ProgressMonitor progressMonitor)
Wrapper to give meaningful output if things go wrong.

Returns:
true if data import was successful

importDataHandleExceptions

public boolean importDataHandleExceptions(java.util.List<java.io.File> files,
                                          ProgressMonitor progressMonitor)

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.


compareTo

public int compareTo(FileImporter other)
Specified by:
compareTo in interface java.lang.Comparable<FileImporter>

getBZip2InputStream

public static org.apache.tools.bzip2.CBZip2InputStream getBZip2InputStream(java.io.InputStream in)
                                                                    throws java.io.IOException
Throws:
java.io.IOException

getGZipInputStream

public static java.util.zip.GZIPInputStream getGZipInputStream(java.io.InputStream in)
                                                        throws java.io.IOException
Throws:
java.io.IOException

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

activeLayerChange

public void activeLayerChange(Layer oldLayer,
                              Layer newLayer)
Description copied from interface: MapView.LayerChangeListener
Notifies this listener that the active layer has changed.

Specified by:
activeLayerChange in interface MapView.LayerChangeListener
Parameters:
oldLayer - The previous active layer
newLayer - The new activer layer

layerAdded

public void layerAdded(Layer newLayer)
Description copied from interface: MapView.LayerChangeListener
Notifies this listener that a layer has been added.

Specified by:
layerAdded in interface MapView.LayerChangeListener
Parameters:
newLayer - The new added layer

layerRemoved

public void layerRemoved(Layer oldLayer)
Description copied from interface: MapView.LayerChangeListener
Notifies this listener that a layer has been removed.

Specified by:
layerRemoved in interface MapView.LayerChangeListener
Parameters:
oldLayer - The old removed layer


JOSM