public final class MimeLookup
extends org.openide.util.Lookup
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.
MimePath| Modifier and Type | Method | Description |
|---|---|---|
MimeLookup |
childLookup(java.lang.String mimeType) |
Deprecated.
Use
getLookup(MimePath) with the MimePath
of the embedded mime type instead. |
static org.openide.util.Lookup |
getLookup(java.lang.String mimePath) |
Gets a
Lookup implementation that exposes objects specific
for the given MimePath for the given mime-type
or mime-path given as string. |
static org.openide.util.Lookup |
getLookup(MimePath mimePath) |
Gets a
Lookup implementation that exposes objects specific
for the given MimePath. |
static MimeLookup |
getMimeLookup(java.lang.String mimeType) |
Deprecated.
Use
getLookup(MimePath.get(mimeType)) instead. |
<T> T |
lookup(java.lang.Class<T> clazz) |
Deprecated.
Use
getLookup(MimePath) and the methods provided by
the ordinary Lookup instance returned. |
<T> org.openide.util.Lookup.Result<T> |
lookup(org.openide.util.Lookup.Template<T> template) |
Deprecated.
Use
getLookup(MimePath) and the methods provided by
the ordinary Lookup instance returned. |
public static org.openide.util.Lookup getLookup(MimePath mimePath)
Lookup implementation that exposes objects specific
for the given MimePath.mimePath - The mime path to get the Lookup for.Lookup containing instances for the MimePath
passed in as a parameter.public static org.openide.util.Lookup getLookup(java.lang.String mimePath)
Lookup implementation that exposes objects specific
for the given MimePath for the given mime-type
or mime-path given as string.
MimePath
by using MimePath.parse(String) and then calls
getLookup(MimePath).mimePath - non-null string which is either a mime-type e.g. "text/plain"
or mime-path (multiple mime-types separated by slash) e.g.
"text/x-jsp/text/x-java".Lookup containing instances for the given mime-path.getLookup(MimePath)public static MimeLookup getMimeLookup(java.lang.String mimeType)
getLookup(MimePath.get(mimeType)) instead.mimeType - non-null mime-type string representation, e.g. "text/x-java"public MimeLookup childLookup(java.lang.String mimeType)
getLookup(MimePath) with the MimePath
of the embedded mime type instead.mimeType - non-null mime-type string representationpublic <T> T lookup(java.lang.Class<T> clazz)
getLookup(MimePath) and the methods provided by
the ordinary Lookup instance returned.lookup in class org.openide.util.Lookupclazz - The class of the object to search for.null if no such
implementation is found.public <T> org.openide.util.Lookup.Result<T> lookup(org.openide.util.Lookup.Template<T> template)
getLookup(MimePath) and the methods provided by
the ordinary Lookup instance returned.lookup in class org.openide.util.Lookuptemplate - The template describing the objects to look for.Built on April 24 2018. | Portions Copyright 1997-2018 Oracle. All rights reserved.