| // |
| // 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. |
| // |
| |
| = DevFaqMIMEResolver |
| :jbake-type: wiki |
| :jbake-tags: wiki, devfaq, needsreview |
| :jbake-status: published |
| |
| === How can I create declarative MIMEResolver and add new file type? |
| |
| There is a wizard available for NetBeans modules which does this for you. Just run *New File | Module Development | File Type*. Fill in the *MIME Type* text field and choose whether to recognize file by extension or XML root element. If you want more sophisticated recognition, choose "*by Filename Extension*" and edit created resolver xml after you finish the wizard. In the next step type in "*Class Name Prefix*" your preferred prefix and finish the wizard. |
| |
| Description of declarative MIME resolve can be found in link:http://bits.netbeans.org/dev/javadoc/org-openide-filesystems/org/openide/filesystems/doc-files/HOWTO-MIME.html[this document]. In most cases it should be enough to resolve files only by their extensions as the wizard does (see link:http://bits.netbeans.org/dev/javadoc/org-openide-filesystems/org/openide/filesystems/doc-files/resolverDocumentation.html#ext[ext element]). Other types of resolution can be more time expensive, so use them only exceptionally. Useful can be link:http://bits.netbeans.org/dev/javadoc/org-openide-filesystems/org/openide/filesystems/doc-files/resolverDocumentation.html#name[file name matching], link:http://bits.netbeans.org/dev/javadoc/org-openide-filesystems/org/openide/filesystems/doc-files/resolverDocumentation.html#pattern[file content matching] or link:http://bits.netbeans.org/dev/javadoc/org-openide-filesystems/org/openide/filesystems/doc-files/resolverDocumentation.html#magic[magic matching] for binary files. Also consider existence of link:http://bits.netbeans.org/dev/javadoc/org-openide-filesystems/org/openide/filesystems/doc-files/resolverDocumentation.html#exit[exit element] intended for negative matching which can skips next conditions. |
| |
| --- |
| |
| [source,java] |
| ---- |
| |
| Applies to: NetBeans 6.1+, pattern and name elements to 6.7+ |
| ---- |
| [source,java] |
| ---- |
| |
| Related: link:DevFaqFileRecognition.html[DevFaqFileRecognition] |
| ---- |
| |
| === 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/DevFaqMIMEResolver[http://wiki.netbeans.org/DevFaqMIMEResolver] , |
| that was last modified by NetBeans user Admin |
| on 2009-11-06T15:53:24Z. |
| |
| |
| *NOTE:* This document was automatically converted to the AsciiDoc format on 2018-01-10, and needs to be reviewed. |