org.openide.util.lookup
Class InstanceContent.ConvertingItem<T,R>

java.lang.Object
  extended by org.openide.util.Lookup.Item<T>
      extended by org.openide.util.lookup.AbstractLookup.Pair<R>
          extended by org.openide.util.lookup.InstanceContent.ConvertingItem<T,R>
All Implemented Interfaces:
java.io.Serializable
Enclosing class:
InstanceContent

static final class InstanceContent.ConvertingItem<T,R>
extends AbstractLookup.Pair<R>

Instance of one item registered in the map.


Constructor Summary
InstanceContent.ConvertingItem(T obj, InstanceContent.Convertor<? super T,R> conv)
          Create an item.
 
Method Summary
protected  boolean creatorOf(java.lang.Object obj)
          Method that can test whether an instance of a class has been created by this item.
 boolean equals(java.lang.Object o)
           
 java.lang.String getDisplayName()
          Getter for display name of the item.
 java.lang.String getId()
          An identity of the item.
 R getInstance()
          Get instance of registered object.
 java.lang.Class<? extends R> getType()
          The class of this item.
 int hashCode()
           
 boolean instanceOf(java.lang.Class<?> c)
          Tests whether this item can produce object of class c.
 
Methods inherited from class org.openide.util.lookup.AbstractLookup.Pair
getIndex, setIndex
 
Methods inherited from class org.openide.util.Lookup.Item
toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InstanceContent.ConvertingItem

public InstanceContent.ConvertingItem(T obj,
                                      InstanceContent.Convertor<? super T,R> conv)
Create an item.

Method Detail

instanceOf

public boolean instanceOf(java.lang.Class<?> c)
Tests whether this item can produce object of class c.

Specified by:
instanceOf in class AbstractLookup.Pair<R>

getInstance

public R getInstance()
Get instance of registered object. If convertor is specified then method InstanceLookup.Convertor.convertor is used and weak reference to converted object is saved.

Specified by:
getInstance in class Lookup.Item<R>
Returns:
the instance of the object.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getId

public java.lang.String getId()
An identity of the item.

Specified by:
getId in class Lookup.Item<R>
Returns:
string representing the item, that can be used for persistance purposes to locate the same item next time

getDisplayName

public java.lang.String getDisplayName()
Getter for display name of the item.

Specified by:
getDisplayName in class Lookup.Item<R>
Returns:
the string suitable for presenting the object to a user

creatorOf

protected boolean creatorOf(java.lang.Object obj)
Method that can test whether an instance of a class has been created by this item.

Specified by:
creatorOf in class AbstractLookup.Pair<R>
Parameters:
obj - the instance
Returns:
if the item has already create an instance and it is the same as obj.

getType

public java.lang.Class<? extends R> getType()
The class of this item.

Specified by:
getType in class Lookup.Item<R>
Returns:
the correct class