File DataSource Notes

From OpenJUMP Wiki
Jump to navigation Jump to search

Metadata: I created these notes after a question about implementing a DataSource for OpenJUMP asked on the OpenJUMP development mailing list. I made these notes before I realized Stefan already has an excellent tutorial on creating a DataSource. These notes should really be added to or merged with How to write a new driver tutorial at some point.

It appears that a new framework for implementing input and output of Feature objects was introduced into JUMP. In the old framework support for input and output of a new file format was added using a JUMPReader or JUMPWriter class. In the new framework the DataSource and Connection classes should be used to implement input/output support for a new file type.

I suggest the following steps to implement input/output support for a new file type:

  • [1] Create your own reader/and writer for the file type. Ideally these objects would allow low-level access to the contents of the file type through a public API.
  • [2] If appropriate, create a FeatureInputStream for your file type. This will be especially important for files that are extremely large, or for a DataSource that might serve as a proxy for not just files, but other types of “streams”.
  • [3] Implement the Connection interface for your file type. The most important methods are the executeQuery methods that will return a FeatureCollection from the DataSource the Connection “connects” to.
  • [4] Extend the DataSource class for your file type, using the Connection implementation created in step #3.
  • [5] Create a plug-in that allows the user to activate input and output to and from your file type via the GUI. This will allow you to (for example) obtain the Layer that is created when the FeatureCollection is imported from your DataSource. (As an alternative to this you can try to implement the AbstractLoadDatasetPlugIn and AbstractSaveDatasetPlugIn.)