org.openide.loaders 5.9.22

org.openide.loaders
Class FolderLookup

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

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

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.openide.cookies.InstanceCookie
InstanceCookie.Of
 
Field Summary
 
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, toString, waitFinished
 
Methods inherited from class org.openide.util.Task
addTaskListener, isFinished, notifyFinished, notifyRunning, removeTaskListener, waitFinished
 
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.

Specified by:
instanceClass in interface InstanceCookie
Overrides:
instanceClass in class FolderInstance
Returns:
Proxy.Lkp class.

getLookup

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

Serializable since 3.27.

Returns:
a lookup

createInstance

protected final Object createInstance(InstanceCookie[] cookies)
                               throws IOException,
                                      ClassNotFoundException
Updates the content of the lookup.

Specified by:
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:
dobj - 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

org.openide.loaders 5.9.22

Built on July 11 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.