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
MimeLookup.getLookup(MimePath) 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.
author: Miloslav Metelka, Martin Roskanin, Vita Stejskal See Also: MimePath |