Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| org.netbeans.modules.editor.mimelookup/1 1.3.22
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.netbeans.api.editor.mimelookup
Class MimeLookup

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

    public final class MimeLookup

extends Lookup

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

For obtaining mime-type specific lookup `getMimeLookup(String mimeType)` static method can be used.

Because embeded languages (like JSP) can contain embeded mime types, the mime lookup also provides the functionality of lookup over these embeded mime types.

For obtaining mime-type specific embeded lookup `childLookup(String mimeType)` method can be used.

Clients can listen on the lookup result for lookup changes. Because lookup results are held weakly, client is responsible for reference holding during life-time frame. Listeners added to lookup result should be weak. As a pattern for that requirements, following code snippet can be used:

          public class MyClass {
              private Lookup.Result result;
              private LookupListener weakLookupListener;
              private LookupListener lookupListener

              public MyClass(){
                  MimeLookup lookup = MimeLookup.getMimeLookup("text/x-java"); //use your content type here
                  result = lookup.lookup(new Lookup.Template(YourObjectHere.class));
                  result.allInstances(); // allInstances should be called, otherwise event will
                                         // not be fired - optimalization in ProxyLookup
                  lookupListener = new LookupListener(){
                     public void resultChanged(LookupEvent ev) {
                         // handle your code
                     }
                  };

                  weakLookupListener = (LookupListener) WeakListeners.create(
                          LookupListener.class, lookupListener, result);

                  result.addLookupListener(weakLookupListener);
              }

          }

Nested Class Summary

Nested classes/interfaces inherited from class org.openide.util.Lookup
`Lookup.Item, Lookup.Provider, Lookup.Result, Lookup.Template`

Field Summary

Fields inherited from class org.openide.util.Lookup
`EMPTY`

Method Summary
`MimeLookup` | `childLookup(String mimeType)` Gets mime-type specific child (embeded) lookup.
`static MimeLookup` | `getMimeLookup(String mimeType)` Gets mime-type specific lookup.
`Object` | `lookup(Class clazz)` Look up an object matching a given interface.
`Lookup.Result` | `lookup(Lookup.Template template)` The general lookup method.

Methods inherited from class org.openide.util.Lookup
`getDefault, lookupItem`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getMimeLookup

    public static MimeLookup getMimeLookup(String mimeType)

  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)

  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 Object lookup(Class clazz)

  Look up an object matching a given interface. This is the simplest method to use. If more than one object matches, one will be returned arbitrarily. The template class may be a class or interface; the instance is guaranteed to be assignable to it.

  Specified by:
    `lookup` in class `Lookup`
  Parameters:
    `clazz` - class of the object we are searching for
  Returns:
    an object implementing the given class or `null` if no such implementation is found

### lookup

    public Lookup.Result lookup(Lookup.Template template)

  The general lookup method. Callers can get list of all instances and classes that match the given `template` and attach a listener to this be notified about changes. The general interface does not specify whether subsequent calls with the same template produce new instance of the `Lookup.Result` or return shared instance. The prefered behaviour however is to return shared one.

  Specified by:
    `lookup` in class `Lookup`
  Parameters:
    `template` - a template describing the services to look for
  Returns:
    an object containing the results

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| org.netbeans.modules.editor.mimelookup/1 1.3.22
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Built on December 7 2006. | Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.