org.openide.util.lookup
Class ExcludingLookup

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

final class ExcludingLookup
extends Lookup

Allows exclusion of certain instances from lookup.

Author:
Jaroslav Tulach

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
ExcludingLookup(Lookup delegate, java.lang.Class[] classes)
          Creates new Result object with supplied instances parameter.
 
Method Summary
(package private)  java.lang.Class<?>[] classes()
          Returns the array of classes this lookup filters.
(package private)
<E,T extends java.util.Collection<E>>
T
filter(java.lang.Class<?>[] arr, java.lang.Class<?> from, T c, int type, T prototype)
          Filters collection accroding to set of given filters.
(package private) static boolean isObjectAccessible(java.lang.Class[] barriers, java.lang.Class from, java.lang.Object to, int type)
          based on type decides whether the class accepts or not anObject
<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.
 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

ExcludingLookup

ExcludingLookup(Lookup delegate,
                java.lang.Class[] classes)
Creates new Result object with supplied instances parameter.

Parameters:
instances - to be used to return from the lookup
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

lookupItem

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

classes

final java.lang.Class<?>[] classes()
Returns the array of classes this lookup filters.


isObjectAccessible

static final boolean isObjectAccessible(java.lang.Class[] barriers,
                                        java.lang.Class from,
                                        java.lang.Object to,
                                        int type)
based on type decides whether the class accepts or not anObject

Parameters:
barriers - classes to avoid when testing reachability
from - the base type of the query
to - depending on value of type either Object, Class or Item
type - 0,1,2 for Object, Class or Item
Returns:
true if we can access the to from from by walking around the bariers

filter

final <E,T extends java.util.Collection<E>> T filter(java.lang.Class<?>[] arr,
                                                     java.lang.Class<?> from,
                                                     T c,
                                                     int type,
                                                     T prototype)
Filters collection accroding to set of given filters.