org.openide.util.lookup
Class AbstractLookup

java.lang.Object
  |
  +--org.openide.util.Lookup
        |
        +--org.openide.util.lookup.AbstractLookup

public class AbstractLookup
extends Lookup

Implementation of the lookup from OpenAPIs that is based on the introduction of Item. This class should provide the default way of how to store (Class, Object) pairs in the lookups. It offers protected methods for subclasses to register the pairs.

Since:
1.9

Inner Class Summary
static class AbstractLookup.Content
          A class that can be used by the creator of the AbstractLookup to control its content.
static class AbstractLookup.Pair
          Extension to the default lookup item that offers additional information for the data structures use in AbstractLookup
 
Inner classes inherited from class org.openide.util.Lookup
Lookup.Item, Lookup.Result, Lookup.Template
 
Fields inherited from class org.openide.util.Lookup
EMPTY
 
Constructor Summary
protected AbstractLookup()
          Default constructor for subclasses that do not need to provide a content
  AbstractLookup(AbstractLookup.Content content)
          Constructor to create this lookup and associate it with given Content.
 
Method Summary
protected  void addPair(AbstractLookup.Pair pair)
          The method to add instance to the lookup with.
protected  void beforeLookup(Lookup.Template template)
          Notifies subclasses that a query is about to be processed.
protected  void initialize()
          Method for subclasses to initialize them selves.
 Object lookup(Class clazz)
          Lookups an object of given interface.
 Lookup.Result lookup(Lookup.Template template)
          The general lookup method.
 Lookup.Item lookupItem(Lookup.Template template)
          Lookups just one item.
protected  void removePair(AbstractLookup.Pair pair)
          Remove instance.
protected  void setPairs(Collection collection)
          Changes all pairs in the lookup to new values.
 
Methods inherited from class org.openide.util.Lookup
getDefault
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractLookup

public AbstractLookup(AbstractLookup.Content content)
Constructor to create this lookup and associate it with given Content. The content than allows the creator to invoke protected methods which are not accessible for any other user of the lookup.
Parameters:
content - the content to assciate with
Since:
1.25

AbstractLookup

protected AbstractLookup()
Default constructor for subclasses that do not need to provide a content
Method Detail

initialize

protected void initialize()
Method for subclasses to initialize them selves.

beforeLookup

protected void beforeLookup(Lookup.Template template)
Notifies subclasses that a query is about to be processed.
Parameters:
template - the template

addPair

protected final void addPair(AbstractLookup.Pair pair)
The method to add instance to the lookup with.
Parameters:
pair - class/instance pair

removePair

protected final void removePair(AbstractLookup.Pair pair)
Remove instance.
Parameters:
pair - class/instance pair

setPairs

protected final void setPairs(Collection collection)
Changes all pairs in the lookup to new values.
Parameters:
collection - the collection of (Pair) objects

lookup

public final Object lookup(Class clazz)
Lookups an object of given interface. This is the simplest method for the lookuping, if more registered objects implement the given class any of them can be returned.
Overrides:
lookup in class Lookup
Parameters:
clazz - class of the object we are searching for
Returns:
the object implementing given class or null if no such has been found

lookupItem

public final Lookup.Item lookupItem(Lookup.Template template)
Lookups just one item.
Overrides:
lookupItem in class Lookup
Parameters:
t - template
Returns:
item or null

lookup

public final Lookup.Result lookup(Lookup.Template template)
The general lookup method.
Overrides:
lookup in class Lookup
Parameters:
template - the template describing the services we are looking for
Returns:
object containing the results


Built on December 12 2001.  |  Portions Copyright 1997-2001 Sun Microsystems, Inc. All rights reserved.