org.openide.util.lookup
Class ProxyLookup

java.lang.Object
  extended by org.openide.util.Lookup
      extended by org.openide.util.lookup.ProxyLookup

public class ProxyLookup
extends Lookup

Implementation of lookup that can delegate to others.

Since:
1.9
Author:
Jaroslav Tulach

Nested Class Summary
(package private) static class ProxyLookup.ImmutableInternalData
           
 
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 ProxyLookup()
          Create a lookup initially proxying to no others.
  ProxyLookup(Lookup... lookups)
          Create a proxy to some other lookups.
 
Method Summary
protected  void beforeLookup(Lookup.Template<?> template)
          Notifies subclasses that a query is about to be processed.
protected  Lookup[] getLookups()
          Getter for the delegates.
<T> T
lookup(java.lang.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 setLookups(Lookup... lookups)
          Changes the delegates.
 java.lang.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

ProxyLookup

public ProxyLookup(Lookup... lookups)
Create a proxy to some other lookups.

Parameters:
lookups - the initial delegates

ProxyLookup

protected ProxyLookup()
Create a lookup initially proxying to no others. Permits serializable subclasses.

Since:
3.27
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getLookups

protected final Lookup[] getLookups()
Getter for the delegates.

Returns:
the array of lookups we delegate to
Since:
1.19

setLookups

protected final void setLookups(Lookup... lookups)
Changes the delegates.

Parameters:
lookups - the new lookups to delegate to
Since:
1.19 protected

beforeLookup

protected void beforeLookup(Lookup.Template<?> template)
Notifies subclasses that a query is about to be processed. Subclasses can update its state before the actual processing begins. It is allowed to call setLookups method to change/update the set of objects the proxy delegates to.

Parameters:
template - the template of the query
Since:
1.31

lookup

public final <T> T lookup(java.lang.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