org.openide.loaders
Class FolderLookup

java.lang.Object
  |
  +--org.openide.util.Task
        |
        +--org.openide.loaders.FolderInstance
              |
              +--org.openide.loaders.FolderLookup
All Implemented Interfaces:
InstanceCookie, Node.Cookie, Runnable

public class FolderLookup
extends FolderInstance

Implements a lookup, that scans a content of a folder for its data objects and asks them for instance cookie, the created objects are then used to for the content of the lookup.

Any instances which are in fact instances of Lookup will be proxied to, permitting one file to generate many instances in the lookup system easily.

Since:
1.11

Inner classes inherited from class org.openide.cookies.InstanceCookie
InstanceCookie.Of, InstanceCookie.Origin
 
Fields inherited from class org.openide.loaders.FolderInstance
folder
 
Fields inherited from class org.openide.util.Task
EMPTY
 
Constructor Summary
FolderLookup(DataObject.Container df)
          Constructs the FolderLookup for given container.
FolderLookup(DataObject.Container df, String prefix)
          Constructs the FolderLookup for given container.
 
Method Summary
protected  InstanceCookie acceptContainer(DataObject.Container df)
          Container is recognized as underlying FolderLookup which passes its items to parent FolderLookup.
protected  InstanceCookie acceptFolder(DataFolder df)
          Folder is recognized as underlying FolderLookup which passes its items to parent FolderLookup.
protected  Object createInstance(InstanceCookie[] cookies)
          Updates the content of the lookup.
 Lookup getLookup()
          Getter for the lookup, that should be used.
 Class instanceClass()
          The correct class that this folder recognizes.
protected  Object instanceForCookie(DataObject dobj, InstanceCookie cookie)
          Overrides superclass method.
protected  Task postCreationTask(Runnable run)
          Starts the creation of the object in the Folder recognizer thread.
 
Methods inherited from class org.openide.loaders.FolderInstance
acceptCookie, acceptDataObject, instanceCreate, instanceFinished, instanceName, recreate, run, waitFinished
 
Methods inherited from class org.openide.util.Task
addTaskListener, isFinished, notifyFinished, notifyRunning, removeTaskListener, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FolderLookup

public FolderLookup(DataObject.Container df)
Constructs the FolderLookup for given container. A default ID prefix is used for identification of located items.
Parameters:
df - container (or folder) to work on

FolderLookup

public FolderLookup(DataObject.Container df,
                    String prefix)
Constructs the FolderLookup for given container.
Parameters:
df - container (or folder) to work on
prefix - the prefix to use
Method Detail

instanceClass

public final Class instanceClass()
The correct class that this folder recognizes.
Overrides:
instanceClass in class FolderInstance
Returns:
Proxy.Lkp class.

getLookup

public final Lookup getLookup()
Getter for the lookup, that should be used.

createInstance

protected final Object createInstance(InstanceCookie[] cookies)
                               throws IOException,
                                      ClassNotFoundException
Updates the content of the lookup.
Overrides:
createInstance in class FolderInstance
Parameters:
cookies - updated array of instance cookies for the folder
Returns:
object to represent these cookies
Throws:
IOException - an I/O error occured
ClassNotFoundException - a class has not been found

instanceForCookie

protected Object instanceForCookie(DataObject dobj,
                                   InstanceCookie cookie)
                            throws IOException,
                                   ClassNotFoundException
Overrides superclass method. It returns instance for DataObject&InstanceCookie 'pair'. If the instance is of FolderLookup.Lkp class it is created otherwise new Lkp.ICItem created and returned.
Overrides:
instanceForCookie in class FolderInstance
Parameters:
obj - the data object that is the source of the cookie
cookie - the instance cookie to read the instance from
Throws:
IOException - when there I/O error
ClassNotFoundException - if the class cannot be found

acceptFolder

protected InstanceCookie acceptFolder(DataFolder df)
Folder is recognized as underlying FolderLookup which passes its items to parent FolderLookup.
Overrides:
acceptFolder in class FolderInstance
Parameters:
df - the folder found
Returns:
new FolderLookup

acceptContainer

protected InstanceCookie acceptContainer(DataObject.Container df)
Container is recognized as underlying FolderLookup which passes its items to parent FolderLookup.
Overrides:
acceptContainer in class FolderInstance
Parameters:
df - the container found
Returns:
new FolderLookup

postCreationTask

protected final Task postCreationTask(Runnable run)
Starts the creation of the object in the Folder recognizer thread. Doing all the lookup stuff in one thread should prevent deadlocks, but because we call unknown data loaders, they obviously must be implemented in correct way.
Overrides:
postCreationTask in class FolderInstance
Parameters:
run - runable to start
Returns:
null, because the runnable is started immediatelly


Built on December 12 2001.  |  Portions Copyright 1997-2001 Sun Microsystems, Inc. All rights reserved.