Note: These pages are being reviewed.
What is a DataLoader?
As of NetBeans 6.8, it is usually not necessary to implement DataLoader directly - today it is usually an implementation detail of writing file support, and you can simply write a DataObject subclass and register it as follows:
<folder name="Loaders"> <folder name="text"> <folder name="x-foo"> <folder name="Factories"> <file name="FooDataLoader.instance"> <attr name="dataObjectClass" stringvalue="com.foo.modules.foofile.FooDataObject"/> <attr name="instanceCreate" methodvalue="org.openide.loaders.DataLoaderPool.factory"/> <attr name="mimeType" stringvalue="text/x-foo"/> </file> </folder> </folder> </folder> </folder>
This registers the DataObject subclass
com.modules.foofile.FooDataObject against the MIME type
DataLoaders are factories for DataObjects. A DataLoader is typically associated with one or more MIME types (such as
text/x-java), and is allowed to be the system-wide factory for DataObjects for individual files of that MIME type.
MIME type is typically determined by the file extension, though it can depend on content for things like XML files. (more about how NetBeans recognizes files).
DataLoaders are factories for DataObjects. Typically there is a 1:1 mapping between file-type:DataLoader-subclass and a 1:1 mapping from file:DataObject. When a file is first encountered, and something calls [http://bits.netbeans.org/dev/javadoc/org-openide-loaders/org/openide/loaders/DataObject.html#find(org.openide.filesystems.FileObject)
DataObject.find(theFileObject)], the correct DataLoader is found and used to asked to create DataObject for that file.
Modules that provide the ability the system to open (or otherwise use) files of a particular type will register DataLoaders for those types. So typically for each file type (as defined by MIME type, which in practice usually means file name extension, or XML subtype) there is a matching DataObject subclass.
Note that DataLoaders do not have to be tied to MIME types — you can still write a DataLoader subclass, registered the old-fashioned way via the JAR manifest, which gets the first chance in the system to claim any file in the system. However this is rarely wise or useful to do.
Apache Migration Information
The content in this page was kindly donated by Oracle Corp. to the Apache Software Foundation.
This page was exported from http://wiki.netbeans.org/DevFaqDataLoader , that was last modified by NetBeans user Jtulach on 2010-07-24T19:48:10Z.
NOTE: This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.