blob: 3bf7885b0d23ab1587f34d1b941ad7dbe6f2c813 [file] [log] [blame]
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
= DevFaqEditorHowIsMimeLookupComposed
:jbake-type: wiki
:jbake-tags: wiki, devfaq, needsreview
:jbake-status: published
:keywords: Apache NetBeans wiki DevFaqEditorHowIsMimeLookupComposed
:description: Apache NetBeans wiki DevFaqEditorHowIsMimeLookupComposed
:toc: left
:toc-title:
:syntax: true
=== How is MimeLookup composed?
In order to get link:DevFaqEditorWhatIsMimeLookup.asciidoc[MimeLookup] you have to supply
link:DevFaqEditorWhatIsMimePath.asciidoc[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:
[source,java]
----
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:
[source,java]
----
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:
[source,java]
----
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
See also:
link:DevFaqEditorWhatIsMimeLookup.asciidoc[What is MimeLookup?],
link:DevFaqEditorWhatIsMimePath.asciidoc[What is MimePath?],
link:http://www.netbeans.org/download/dev/javadoc/org-netbeans-modules-editor-mimelookup/index.html[MimeLookup API]
=== Apache Migration Information
The content in this page was kindly donated by Oracle Corp. to the
Apache Software Foundation.
This page was exported from link:http://wiki.netbeans.org/DevFaqEditorHowIsMimeLookupComposed[http://wiki.netbeans.org/DevFaqEditorHowIsMimeLookupComposed] ,
that was last modified by NetBeans user Vstejskal
on 2010-06-16T14:05:24Z.
*NOTE:* This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.