public final class MimeLookup extends 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 Lookup
s 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
Lookup
s they obtain from this class throughout the whole lifecycle
of their component, especially when they need to use that Lookup
several times.
MimePath
Lookup.Item<T>, Lookup.Provider, Lookup.Result<T>, Lookup.Template<T>
Modifier and Type | Method and Description |
---|---|
MimeLookup |
childLookup(String mimeType)
Deprecated.
Use
MimeLookup.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 Lookup |
getLookup(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 MimeLookup |
getMimeLookup(String mimeType)
Deprecated.
Use
getLookup(MimePath.get(mimeType)) instead. |
<T> T |
lookup(Class<T> clazz)
Deprecated.
Use
MimeLookup.getLookup(MimePath) and the methods provided by
the ordinary Lookup instance returned. |
<T> Lookup.Result<T> |
lookup(Lookup.Template<T> template)
Deprecated.
Use
MimeLookup.getLookup(MimePath) and the methods provided by
the ordinary Lookup instance returned. |
getDefault, lookupAll, lookupItem, lookupResult
public static 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 Lookup getLookup(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
MimeLookup.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.MimeLookup.getLookup(MimePath)
@Deprecated public static MimeLookup getMimeLookup(String mimeType)
getLookup(MimePath.get(mimeType))
instead.mimeType
- non-null mime-type string representation, e.g. "text/x-java"@Deprecated public MimeLookup childLookup(String mimeType)
MimeLookup.getLookup(MimePath)
with the MimePath
of the embedded mime type instead.mimeType
- non-null mime-type string representation@Deprecated public <T> T lookup(Class<T> clazz)
MimeLookup.getLookup(MimePath)
and the methods provided by
the ordinary Lookup
instance returned.@Deprecated public <T> Lookup.Result<T> lookup(Lookup.Template<T> template)
MimeLookup.getLookup(MimePath)
and the methods provided by
the ordinary Lookup
instance returned.