How is MimeLookup composed?

Apache NetBeans Wiki Index

Note: These pages are being reviewed.

In order to get MimeLookup you have to supply MimePath. With the default MimeLookup implementation provided by Netbeans the contents of MimeLookup is defined by a hierarchical structure of folders on the system FileSystem. The structure starts in the Editors folder and then follows all the components of the MimePath you have supplied.

For example if you ask for MimeLookup for the following MimePath of text/x-java you will get Lookup with contents from the following folders:

    Editors/text/x-java
    Editors

As you can see MimeLookup for text/x-java contains not only editor features registered for the text/x-java mime type itself, but it also inherits general features registered for an empty MimePath (i.e. in the root of the hierarchy).

The inheritence algorithm used for composing MimeLookup for a given MimePath supports more than just simple inheritance from the root. It also supports compound mime types such as text/x-ant+xml and embedded mime types such as text/x-jsp/text/x-java.

Compound mime types

Let’s have a look at the MimeLookup composition for a compound mime type text/x-ant+xml. The resulting Lookup will contain things registered in the following folders:

    Editors/text/x-ant+xml
    Editors/text/xml
    Editors

That’s the reason why editor features provided by XML modules for general XML files work also for specialized, but XML-based, files.

Embedded mime types

The inheritance hierarchy becomes even more complicated when dealing with embedded mime types. Let’s use a java scriplet inside a JSP page as an example of language embedding. The MimePath for the scriplet is text/x-jsp/text/x-java and its MimeLookup will contain features registered in the following folders:

    Editors/text/x-jsp/text/x-java
    Editors/text/x-java
    Editors

The algorithm for computing the inheritance tree for a particular MimePath combines all the above cases together and works always the same way no matter what feature you are going to look for in the resulting MimeLookup.


Applies to: NetBeans 6.x and with some exceptions also to 5.x

Platforms: All