站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

MimeLookup (MIME Lookup API) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.editor.mimelookup/1 1.6

org.netbeans.api.editor.mimelookup
Class MimeLookup

java.lang.Object
  extended by org.openide.util.Lookup
      extended by org.netbeans.api.editor.mimelookup.MimeLookup

public final class MimeLookup
extends Lookup

Mime Lookup provides lookup mechanism for mime type specific objects. It can be used for example for retrieving mime type specific editor settings, actions, etc.

The static method getLookup(MimePath mimePath) can be used to obtain a mime type specific lookup implementation. This lookup can then be searched for objects bound to the specific mime type using the standard Lookup methods.

Please look at the description of the MimePath class to learn more about embedded mime types and how they are represented by the mime path. By using the MimePath the MimeLookup class allows to have different Lookups for a mime type embedded in different other mime types. So, for example there can be different editor settings for the 'text/x-java' mime type and for the 'text/x-java' mime type embedded in the 'text/x-jsp' mime type.

The Lookup instance returned from the getLookup method can be used in the same way as any other Lookup. It is possible to look up class instances, listen on changes in the lookup restults, etc. The following code snippet shows a typical usage of this class for getting instances of the YourSetting class from the 'text/x-java' mime type specific Lookup.

     Lookup lookup = MimeLookup.getLookup(MimePath.get("text/x-java"));
     Lookup.Result result = lookup.lookup(new Lookup.Template(YourSetting.class));
     Collection instances = result.allInstances();
 

Lifecycle: The lifecycle of Lookup instances created by calling the getLookup or getMimeLookup methods is tied to the lifecycle of the MimePath instances they were created for and vice versa. Therefore it is enough to keep reference to either the MimePath or the Lookup created for that mime path or even to the Lookup.Result in order to preserve the other instances in the memory. Clients are strongly encouraged to keep refernce to the Lookups they obtain from this class throughout the whole lifecycle of their component, especially when they need to use that Lookup several times.

See Also:
MimePath

Nested Class Summary
 
Nested classes/interfaces inherited from class org.openide.util.Lookup
Lookup.Item<T>, Lookup.Provider, Lookup.Result<T>, Lookup.Template<T>
 
Field Summary
 
Fields inherited from class org.openide.util.Lookup
EMPTY
 
Method Summary
 MimeLookup childLookup(String mimeType)
          Deprecated. Use getLookup(MimePath) with the MimePath of the embedded mime type instead.
static Lookup getLookup(MimePath mimePath)
          Gets a Lookup implementation that exposes objects specific for the given MimePath.
static MimeLookup getMimeLookup(String mimeType)
          Deprecated. Use getLookup(MimePath.get(mimeType)) instead.
<T> T
lookup(Class<T> clazz)
          Deprecated. Use getLookup(MimePath) and the methods provided by the ordinary Lookup instance returned.
<T> Lookup.Result<T>
lookup(Lookup.Template<T> template)
          Deprecated. Use getLookup(MimePath) and the methods provided by the ordinary Lookup instance returned.
 
Methods inherited from class org.openide.util.Lookup
getDefault, lookupAll, lookupItem, lookupResult
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLookup

public static Lookup getLookup(MimePath mimePath)
Gets a Lookup implementation that exposes objects specific for the given MimePath.

Parameters:
mimePath - The mime path to get the Lookup for.
Returns:
The Lookup containing instances for the MimePath passed in as a parameter.

getMimeLookup

public static MimeLookup getMimeLookup(String mimeType)
Deprecated. Use getLookup(MimePath.get(mimeType)) instead.

Gets mime-type specific lookup.

Parameters:
mimeType - non-null mime-type string representation, e.g. "text/x-java"
Returns:
non-null mime-type specific lookup

childLookup

public MimeLookup childLookup(String mimeType)
Deprecated. Use getLookup(MimePath) with the MimePath of the embedded mime type instead.

Gets mime-type specific child (embeded) lookup. Child mime-type content can be embeded into parent mime-type content in various embeded languages. In this case mime-type lookup child is specified as subelement of parent lookup i.e.: MimeLookup("text/x-jsp") can have a child MimeLookup("text/x-java") in a case of a jsp scriplet.

Parameters:
mimeType - non-null mime-type string representation
Returns:
non-null mime-type specific child (embeded) lookup

lookup

public <T> T lookup(Class<T> clazz)
Deprecated. Use getLookup(MimePath) and the methods provided by the ordinary Lookup instance returned.

Looks up an object in this mime path lookup.

Specified by:
lookup in class Lookup
Parameters:
clazz - The class of the object to search for.
Returns:
An object implementing the given class or null if no such implementation is found.

lookup

public <T> Lookup.Result<T> lookup(Lookup.Template<T> template)
Deprecated. Use getLookup(MimePath) and the methods provided by the ordinary Lookup instance returned.

Looks up objects in this mime path lookup.

Specified by:
lookup in class Lookup
Parameters:
template - The template describing the objects to look for.
Returns:
The search result.

org.netbeans.modules.editor.mimelookup/1 1.6

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.