站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

AbstractLookup (Utilities API) - NetBeans API Javadoc (Current Development Version)

org.openide.util 7.9.0 1

org.openide.util.lookup
Class AbstractLookup

java.lang.Object
  extended by org.openide.util.Lookup
      extended by org.openide.util.lookup.AbstractLookup
All Implemented Interfaces:
Serializable

public class AbstractLookup
extends Lookup
implements Serializable

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.

Serializable since 3.27.

Since:
1.9
See Also:
Serialized Form

Nested 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<T>
          Extension to the default lookup item that offers additional information for the data structures use in AbstractLookup
 
Nested classes/interfaces inherited from class org.openide.util.Lookup
Lookup.Item<T>, Lookup.Provider, Lookup.Result<T>, Lookup.Template<T>
 
Field Summary
 
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.
<T> T
lookup(Class<T> clazz)
          Look up an object matching a given interface.
<T> Lookup.Result<T>
lookup(Lookup.Template<T> template)
          The general lookup method.
<T> Lookup.Item<T>
lookupItem(Lookup.Template<T> template)
          Look up the first item matching a given template.
protected  void removePair(AbstractLookup.Pair<?> pair)
          Remove instance.
protected  void setPairs(Collection<? extends AbstractLookup.Pair> collection)
          Changes all pairs in the lookup to new values.
 String toString()
           
 
Methods inherited from class org.openide.util.Lookup
getDefault, lookupAll, lookupResult
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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

toString

public String toString()
Overrides:
toString in class Object

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<? extends AbstractLookup.Pair> collection)
Changes all pairs in the lookup to new values.

Parameters:
collection - the collection of (Pair) objects

lookup

public final <T> T lookup(Class<T> clazz)
Description copied from class: Lookup
Look up an object matching a given interface. This is the simplest method to use. If more than one object matches, the first will be returned. 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

lookupItem

public final <T> Lookup.Item<T> lookupItem(Lookup.Template<T> template)
Description copied from class: Lookup
Look up the first item matching a given template. Includes not only the instance but other associated information.

Overrides:
lookupItem in class Lookup
Parameters:
template - the template to check
Returns:
a matching item or null

lookup

public final <T> Lookup.Result<T> lookup(Lookup.Template<T> template)
Description copied from class: Lookup
The general lookup method. Callers can get list of all instances and classes that match the given template, request more info about them in form of Lookup.Item 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

org.openide.util 7.9.0 1

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.