API contains only two classes:1. org.netbeans.api.editor.mimelookup.MimeLookup with public methods:
static MimeLookup getMimeLookup(String mime)- gets mime specific lookup.
static Lookup getLookup(MimePath mimePath)- gets the lookup for the particular mime-path.
MimeLookup childLookup(String mime)- gets mime specific child (embeded) lookup. The method was deprecated in favour of static Lookup getLookup(MimePath mimePath)
Object lookup(Class clazz)- Look up an object matching a given interface.
Result lookup(Lookup.Template template)- The general lookup method. Callers can get list of all instances and classes that match the given
templateand attach a listener to this be notified about changes.
static MimePath get(String mimeType)- gets root mime-path for the given mime-type.
static MimePath get(MimePath prefix, String mimeType)- gets mime-path corresponding to the mime-type used in the given context mime-path.
static MimePath parse(String path)- parses the given mime-path string e.g. "text/x-jsp/text/x-java" and get the corresponding mime-path.
String getPath()- gets string path represented by this mime-path.
int size()-gets total number of mime-types in the mime-path.
String getMimeType(int index)- gets mime type of this mime-path at the given index.
MimePath getPrefix(int size)- returns prefix mime-path with the given number of mime-type components ranging from zero till the size of this mime-path.
MimeLookupis represented via ProxyLookup that collects registered lookups. Particular lookups, responsible for looking up their objects can be registered using interface
MimeDataProviderinto default lookup by META-INF/services registration. Previously used registration via interface
MimeLookupInitializerwas deprecated. In addition to this basic registration, xml layer folder registration is also available. It is provided by registering implemented interface
Class2LayerFolderinto default lookup via META-INF/services registration. This approach provides a mapping of class to specific subfolder. Using this mapping one can achieve the convenient way of using
Using this, an instance of FoldManagerFactory is retrieved from the folder with path
"Editors/text/x-java/FoldManager" provided that FoldManagerFactory.class is registered to
a subfolder "FoldManager" via
InstanceProvidercan be used if there are files of various types in the layer folder that need additional handling before becoming and instance of certain class. For more details look at use case of PopupActions creation.
The Javadoc documentation can be generated by using
cd /cvs/editor/mimelookup ant javadocQuestion (arch-usecases): Describe the main use cases of the new API. Who will use it under what circumstances? What kind of code would typically need to be written to use the module? Answer:
org.openide.util.Lookupallowing to provide the registered instances as a
Lookup.Resultallowing to listen for changes (e.g. caused by the module enabling/disabling).
class MimeLookup extends Lookupcontaining
static MimeLookup getMimeLookup(String mimeType).
static Lookup getLookup(MimePath mimePath)method in
javax.swing.Actionclasses or names of actions (i.e. value of Action.NAME attribute) present in editor kit e.g. "goto-source").
MimeLookup lookup = MimeLookup.getMimeLookup("text/x-java");can be used for getting the mime specific lookup. Having this we can lookup class or template:
Object obj = lookup.lookup(LookedUpClass.class);or
Lookup.Result result = lookup.lookup(new Lookup.Template(LookedUpClass.class));
MimePath scriptletPath = MimePath.parse("text/x-jsp/text/x-java"); Lookup lookup = MimeLookup.getLookup(scriptletPath);
MimeLookup. Implementation of
MimeLookupInitializershould be created and registered to default lookup via
META-INF/servicesregistration. For details, please look at the simplified
LayerMimeLookupInitializer. Usage of MimeLookupInitializer is deprecated, please use MimeDataProvider instead in similar way Question (arch-time): What are the time estimates of the work? Answer: Done. Question (arch-quality): How will the quality of your code be tested and how are future regressions going to be prevented? Answer: Unit tests are available. There are several testing areas covered:
Class2LayerFolder. It should be found in the appropriate mime-type specific folder
MimeLookupis not recursive (see issue #58991 for more details)
MimeLookupInitializercreation, registration and performing a lookup
The default answer to this question is:
The sources for the module are in the NetBeans Mercurial repositories.
MimeDataProviderthat serves data from the folder hierarchy underneath the Editors/ folder on the system filesystem is provided by the editor/mimelookup/impl module. This module also provides the token mentioned earlier.
The default answer to this question is:
These modules are required in project.xml:
MimeLookupQuestion (compat-deprecation): How the introduction of your project influences functionality provided by previous version of the product? Answer: As the module's API/SPI has been naturaly evolving over the time the module contains several deprecated classes. All of them are still fully supported and the module remains backward compatible.
java.io.Filedirectly? Answer: Only in tests. Question (resources-layer): Does your module provide own layer? Does it create any files or folders in it? What it is trying to communicate by that and with which components? Answer: No. Question (resources-read): Does your module read any resources from layers? For what purpose? Answer: No. Question (resources-mask): Does your module mask/hide/override any resources provided by other modules in their layers? Answer: No. Question (resources-preferences): Does your module uses preferences via Preferences API? Does your module use NbPreferences or or regular JDK Preferences ? Does it read, write or both ? Does it share preferences with other modules ? If so, then why ? WARNING: Question with id="resources-preferences" has not been answered!
org.openide.util.Lookupor any similar technology to find any components to communicate with? Which ones? Answer: Yes. MimeLookup in API extends Lookup and it searches the default lookup for instances of
MimeLookupInitializer(this is already deprecated) and
MimeDataProvider. Question (lookup-register): Do you register anything into lookup for other code to find? Answer: No. Question (lookup-remove): Do you remove entries of other modules from lookup? Answer: No.
System.getProperty) property? On a similar note, is there something interesting that you pass to
java.util.logging.Logger? Or do you observe what others log? Answer: org.openide.awt.ActionReference.completion - The annotation processor for MimeRegistration annotation reuses API defined by UI Utilities API and reads System.getProperty("org.openide.awt.ActionReference.completion") property. If it is specified, then the processor tries to load such class, casts it to Processor and asks it for additional completion items for annotation's
mimeTypeattribute. By default, when running inside NetBeans IDE,
apisupport.projectregisters such class and provides items representing valid paths in current project. Question (exec-component): Is execution of your code influenced by any (string) property of any of your components? Answer: No. Question (exec-ant-tasks): Do you define or register any ant tasks that other can use? Answer: No. Question (exec-classloader): Does your code create its own class loader(s)? Answer: No. Question (exec-reflection): Does your code use Java Reflection to execute other code? Answer: No. Question (exec-privateaccess): Are you aware of any other parts of the system calling some of your methods by reflection? Answer: No. Question (exec-process): Do you execute an external process from your module? How do you ensure that the result is the same on different platforms? Do you parse output? Do you depend on result code? Answer: No. Question (exec-introspection): Does your module use any kind of runtime type information (
instanceof, work with
java.lang.Class, etc.)? Answer: No. Question (exec-threading): What threading models, if any, does your module adhere to? How the project behaves with respect to threading? Answer: No special threading models used. Question (security-policy): Does your functionality require modifications to the standard policy file? Answer: No. Question (security-grant): Does your code grant additional rights to some other code? Answer: No.
java.awt.datatransfer.Transferable? Answer: No clipboard support.
MimeLookupdelegates to ProxyLookup performance during lookup depends on the performance of ProxyLookup.
LayerMimeLookupInitializerinstantiates the object found in the layer only during direct lookup of the particular class using LazyLookup (inner class defined in
LayerMimeLookupInitializer). Question (perf-limit): Are there any hard-coded or practical limits in the number or size of elements your code can handle? Answer: No limits. Question (perf-mem): How much memory does your component consume? Estimate with a relation to the number of windows, etc. Answer:
MimeLookupcaches instances of mime sensitive MimeLookups in static Map, instances of children MimeLookups in Map, InitializerListeners and Initializers in Lists.
LayerMimeLookupInitializeralso caches mime sensitive LayerMimeLookupInitializers and LazyLookups. Question (perf-wakeup): Does any piece of your code wake up periodically and do something even when the system is otherwise idle (no user interaction)? Answer: No. Question (perf-progress): Does your module execute any long-running tasks? Answer: No. Question (perf-huge_dialogs): Does your module contain any dialogs or wizards with a large number of GUI controls such as combo boxes, lists, trees, or text areas? Answer: No. Question (perf-menus): Does your module use dynamically updated context menus, or context-sensitive actions with complicated and slow enablement logic? Answer: No. Question (perf-spi): How the performance of the plugged in code will be enforced? Answer: Pluggins are just clients lookups that are installed into
MimeLookup. The performance should be influenced by the lookupable object gathering by clients lookups.
LayerMimeLookupInitializer(client lookup provided by mimelookup module) provides a LazyLookup, it instantiates the object found in the layer only during direct lookup of the particular class. Otherwise performance should be similar as ProxyLookup.
Built on August 25 2014. | Portions Copyright 1997-2014 Oracle. All rights reserved.