org.openide.util.lookup
Class SimpleLookup

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

 class SimpleLookup
extends Lookup

Simple lookup implementation. It can be used to create temporary lookups that do not change over time. The result stores references to all objects passed in the constructor. Those objecst are the only ones returned as result.

Author:
David Strupl

Nested Class Summary
 
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
SimpleLookup(java.util.Collection<java.lang.Object> instances)
          Creates new Result object with supplied instances parameter.
SimpleLookup(java.util.Collection<T> keys, InstanceContent.Convertor<? super T,R> conv)
           
 
Method Summary
<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.
 java.lang.String toString()
           
 
Methods inherited from class org.openide.util.Lookup
getDefault, lookupAll, lookupItem, lookupResult
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleLookup

SimpleLookup(java.util.Collection<java.lang.Object> instances)
Creates new Result object with supplied instances parameter.

Parameters:
instances - to be used to return from the lookup

SimpleLookup

SimpleLookup(java.util.Collection<T> keys,
             InstanceContent.Convertor<? super T,R> conv)
Method Detail

toString

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

lookup

public <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

lookup

public <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