Wednesday, April 15, 2009

Multiple inheritence for content types?

Bioclipse is an environment for handling and processing life sciences data. This data is present in files with a wide variety of formats, each of which can contain a particular data type. For example, a we can have a single molecule in MDL molfile and in CML.

The latter is particularly interesting, as I do not know how to work that out... Firstly, I want the CML (Single Molecule) content type extend the CML content type, so that a validating CML editor can open it with the proper schema, but at the same time I would like to extend it a content type representation a Single Molecule. Hence, the multiple inheritance.

This is what the plugin.xml currently looks like:

name="CML (Single 2D Molecule)"
<describer class="net.bioclipse.cml.contenttypes.CmlFileDescriber">

Very clearly, a single base-type. Is there any option of multiple inheritance?


  1. Nope.

    But is this new "CML (Single Molecule)" content type file format truly a specialization of the "Single Molecule" content type file format?

    I have a hard time thinking how can a file format specialize two other unrelated file formats. Bear in mind that content types are about syntax before semantics. For example, jar can be a subtype of zip, but there is no point in having a common ancestor "compressed archive" between zip and gzip as there is no common format between them.

    IOW, it doesn't make sense to think of abstract content types. All content types must correspond to some specific concrete file format.

    Note that you can associate an editor with multiple content types, if it is able to handle multiple file fomats. So in the archive example, one could associate an editor that can handle different archive formats (let's say, 7-zip) to both zip and gzip content types.

  2. If they are the same content type, and you want to know which grammar to load. You may need to use the WTP's custom URI resolver to first look at the XML being loaded, and determine from there which of the grammars to load if they are in the same namespace. The XSL Tools (wst.xsl) component uses this to determine between xsl 1.0 and xsl 2.0 grammars which to load.

  3. Rafael, I can always tie actions for a certain concept (e.g. Single Molecule) to all formats supporting that, I guess... but that is a lot of plugin.xml code replication... it would be much easier if that action would be tied to just the Single Molecule data type, and a file format inheritic from both a parent file format (e.g. CML) and from this concept type...

  4. David, in the CML world it is more difficult, and a concept conventions are used... CML is like a general grammar allowing to markup a wide variety of chemistry... but it is all using one XML schema...

  5. I just saw this commit:

    + <visibleWhen>
    + <iterate operator="and" ifEmpty="false">
    + <adapt type="org.eclipse.core.resources.IResource">
    + <or>
    + <test property="org.eclipse.core.resources.contentTypeId"
    + value="net.bioclipse.contenttypes.cml.singleMolecule3d"/>
    + <test property="org.eclipse.core.resources.contentTypeId"
    + value="net.bioclipse.contenttypes.cml.singleMolecule5d"/>
    + <test property="org.eclipse.core.resources.contentTypeId"
    + value="net.bioclipse.contenttypes.cml.singleMolecule2d"/>
    + <test property="org.eclipse.core.resources.contentTypeId"
    + value="net.bioclipse.contenttypes.mdlMolFile2D"/>
    + <test property="org.eclipse.core.resources.contentTypeId"
    + value="net.bioclipse.contenttypes.mdlMolFile3D"/>
    + <test property="org.eclipse.core.resources.contentTypeId"
    + value="net.bioclipse.contenttypes.pdb"/>
    + </or>
    + </adapt>
    + </iterate>
    + </visibleWhen>

    If we did have multiple inheritance and a net.bioclipse.Molecule concent super type, then this code would become a whole lot more maintainable...