Java Doc for FolderInstance.java in  » IDE-Netbeans » openide » org » openide » loaders » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » openide » org.openide.loaders 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.openide.util.Task
      org.openide.loaders.FolderInstance

All known Subclasses:   org.openide.loaders.DataLdrActions,  org.openide.loaders.FolderLookup,
FolderInstance
abstract public class FolderInstance extends Task implements InstanceCookie(Code)
Support class for creation of an object from the content of a DataObject.Container . It implements InstanceCookie , so it can be used as a cookie for a node or data object.

When created on a container and started by invoking run method, it scans its content (in a separate thread) and creates a list of instances from which the new instance of this object should be composed. The object automatically listens to changes of components in the container, and if some change occurs, it allows the subclass to create a new object.

Subclasses shall override the following methods:

  1. FolderInstance.createInstance(InstanceCookie[]) (required): this method is called whenever the content has been changed. Its implementation shall build up the data structures and perform the actions required by this implementation.
  2. The filter methods FolderInstance.acceptDataObject(DataObject) , FolderInstance.acceptCookie(InstanceCookie) , FolderInstance.acceptFolder(DataFolder) and FolderInstance.acceptContainer(DataObject.Container) (optional): the standard way is to override one or several of the latter methods. Overriding FolderInstance.acceptDataObject(DataObject) more deeply modifies the default behavior, because the default implementation of FolderInstance.acceptDataObject(DataObject) calls the other 3 filter methods. See the method documentation for details.
  3. The InstanceCookie methods FolderInstance.instanceClass() (optional but recommended) to inform about the class implemented by the return value of FolderInstance.instanceCreate() .
  4. Advanced subclasses may need to override FolderInstance.postCreationTask and/or FolderInstance.instanceForCookie , but it is not common to need these.

author:
   Jaroslav Tulach


Field Summary
protected  DataFolderfolder
     Folder to work with.

Constructor Summary
public  FolderInstance(DataFolder df)
     Create new folder instance.
public  FolderInstance(DataObject.Container container)
     A new object that listens on changes in a container.

Method Summary
protected  InstanceCookieacceptContainer(DataObject.Container container)
     Allows subclasses to decide how they want to work with an object that implements a DataObject.Container.
protected  InstanceCookieacceptCookie(InstanceCookie cookie)
     Allows subclasses to decide whether they want to work with the specified InstanceCookie or not.
protected  InstanceCookieacceptDataObject(DataObject dob)
     Allows subclasses to decide whether they want to work with the specified DataObject or not.

The default implementation roughly performs the following steps:

  1. if dob has an InstanceCookie FolderInstance.acceptCookie(InstanceCookie) is called on that cookie
  2. if dob has a DataFolder cookie, FolderInstance.acceptFolder(DataFolder) is called on that folder
  3. if dob has a DataObject.Container cookie, FolderInstance.acceptContainer(DataObject.Container) is called on that container

The first of the aforementioned steps which returns a non-null cookie and does not throw an exception determines the return value.

protected  InstanceCookieacceptFolder(DataFolder df)
     Allows subclasses to decide how they want to work with a provided folder.
final  voidcheckRecreate()
     Checks whether recreation of this instance is running already and in that case does nothing, otherwise calls FolderInstance.recreate() recreate method. This prevents from redundant recreation tasks of this instance caused by first creation of underlying items which are also of org.openide.util.Task Task type (e.g.
abstract protected  ObjectcreateInstance(InstanceCookie[] cookies)
     Notifies subclasses that the set of cookies for this folder has changed. A new object representing the folder should be created (or the old one updated). Called both upon initialization of the class, and change of its cookies.

It may be poor style for this method to have side-effects.

final  Loggererr()
     Access to error manager for FolderLookup.
public  ClassinstanceClass()
     Returns the root class of all objects.
public  ObjectinstanceCreate()
     Creates instance.
final public  voidinstanceFinished()
     Wait for instance initialization to finish.
protected  ObjectinstanceForCookie(DataObject obj, InstanceCookie cookie)
     Method that is called when a the folder instance really wants to create an object from provided cookie.
public  StringinstanceName()
     The name of the class that we create.
protected  TaskpostCreationTask(Runnable run)
     Invokes the creation of objects in a "safe" thread.
final  voidprocessObjects(Collection<DataObject> arr)
     A method that starts creationTask, the task which really creates the instances from given objects.
public synchronized  voidrecreate()
     Starts recreation of the instance in special thread.
public  voidrun()
     Synchronously starts the creation of the instance.
public  StringtoString()
    
public  voidwaitFinished()
     Overrides the instance finished to deal with internal state correctly.

Field Detail
folder
protected DataFolder folder(Code)
Folder to work with. Non null only if a constructor with DataFolder is used to construct this object.




Constructor Detail
FolderInstance
public FolderInstance(DataFolder df)(Code)
Create new folder instance.
Parameters:
  df - data folder to create instances from



FolderInstance
public FolderInstance(DataObject.Container container)(Code)
A new object that listens on changes in a container.
Parameters:
  container - the object to associate with
since:
   1.11




Method Detail
acceptContainer
protected InstanceCookie acceptContainer(DataObject.Container container)(Code)
Allows subclasses to decide how they want to work with an object that implements a DataObject.Container.

By default this returns null to indicated that subfolders (as well as DataShadow s, etc.) should be ignored.

A common override of this method is to return a new FolderInstance based on the subfolder, permitting recursion.

Compare FolderInstance.acceptDataObject(DataObject) to learn when this method is called.


Parameters:
  container - the container to accept or not cookie for this container or null if this object shouldbe ignored
since:
   1.11



acceptCookie
protected InstanceCookie acceptCookie(InstanceCookie cookie) throws java.io.IOException, ClassNotFoundException(Code)
Allows subclasses to decide whether they want to work with the specified InstanceCookie or not.

The default implementation simply returns the same cookie, but subclasses may decide to return null or a different cookie.

Compare FolderInstance.acceptDataObject(DataObject) to learn when this method is called.


Parameters:
  cookie - the instance cookie to test the cookie to use or null if this cookie should notbe used
exception:
  IOException - if an I/O error occurred calling a cookie method
exception:
  ClassNotFoundException - if a class is not found in a call to a cookie method



acceptDataObject
protected InstanceCookie acceptDataObject(DataObject dob)(Code)
Allows subclasses to decide whether they want to work with the specified DataObject or not.

The default implementation roughly performs the following steps:

  1. if dob has an InstanceCookie FolderInstance.acceptCookie(InstanceCookie) is called on that cookie
  2. if dob has a DataFolder cookie, FolderInstance.acceptFolder(DataFolder) is called on that folder
  3. if dob has a DataObject.Container cookie, FolderInstance.acceptContainer(DataObject.Container) is called on that container

The first of the aforementioned steps which returns a non-null cookie and does not throw an exception determines the return value. If none of the steps succeeds, null is returned.


Parameters:
  dob - a DataObject to test the cookie for the DataObject or nullif it should not be used



acceptFolder
protected InstanceCookie acceptFolder(DataFolder df)(Code)
Allows subclasses to decide how they want to work with a provided folder.

The default implementation simply calls FolderInstance.acceptContainer(DataObject.Container) .

A common override of this method is to return a new FolderInstance based on the subfolder, permitting recursion.

Compare FolderInstance.acceptDataObject(DataObject) to learn when this method is called.


Parameters:
  df - data folder to create cookie for the cookie for this folder or null if this folder should notbe used



checkRecreate
final void checkRecreate()(Code)
Checks whether recreation of this instance is running already and in that case does nothing, otherwise calls FolderInstance.recreate() recreate method. This prevents from redundant recreation tasks of this instance caused by first creation of underlying items which are also of org.openide.util.Task Task type (e.g. sub-FolderInstances, sub-FolderLookups etc.).



createInstance
abstract protected Object createInstance(InstanceCookie[] cookies) throws java.io.IOException, ClassNotFoundException(Code)
Notifies subclasses that the set of cookies for this folder has changed. A new object representing the folder should be created (or the old one updated). Called both upon initialization of the class, and change of its cookies.

It may be poor style for this method to have side-effects. A common way to use FolderInstance is to have this method set some global state which is then used as the resulting instance. Better is to treat the FolderInstance as pure SPI and assign it to a variable of type InstanceCookie. Then use the FolderInstance.instanceCreate method to get the final result. However in some cases there is a singleton live object which must be updated in-place, and it only makes sense to do so here (in which case the InstanceCookie methods are unused).


Parameters:
  cookies - updated array of instance cookies for the folder object to represent these cookies
exception:
  IOException - an I/O error occured
exception:
  ClassNotFoundException - a class has not been found



err
final Logger err()(Code)
Access to error manager for FolderLookup.



instanceClass
public Class instanceClass() throws java.io.IOException, ClassNotFoundException(Code)
Returns the root class of all objects. Supposed to be overriden in subclasses. Object.class
exception:
  IOException - an I/O error occured
exception:
  ClassNotFoundException - the class has not been found



instanceCreate
public Object instanceCreate() throws java.io.IOException, ClassNotFoundException(Code)
Creates instance. an object to work with
exception:
  IOException - an I/O error occured
exception:
  ClassNotFoundException - the class has not been found



instanceFinished
final public void instanceFinished()(Code)
Wait for instance initialization to finish.



instanceForCookie
protected Object instanceForCookie(DataObject obj, InstanceCookie cookie) throws IOException, ClassNotFoundException(Code)
Method that is called when a the folder instance really wants to create an object from provided cookie. It allows subclasses to overwrite the default behaviour (which is to call InstanceCookie.instanceCreate ).
Parameters:
  obj - the data object that is the source of the cookie
Parameters:
  cookie - the instance cookie to read the instance from
exception:
  IOException - when there I/O error
exception:
  ClassNotFoundException - if the class cannot be found



instanceName
public String instanceName()(Code)
The name of the class that we create. the name



postCreationTask
protected Task postCreationTask(Runnable run)(Code)
Invokes the creation of objects in a "safe" thread. This method is for expert subclasses that want to control the thread that the instance is created in.

The default implementation invokes the creation logic in the request processor in non-blocking mode (no other tasks will block on this).


Parameters:
  run - runnable to run task to control the execution of the runnable or null if the runnable is run immediatelly
since:
   1.5



processObjects
final void processObjects(Collection<DataObject> arr)(Code)
A method that starts creationTask, the task which really creates the instances from given objects. The task is started by a call to FolderInstance.postCreationTask(Runnable) .
Parameters:
  arr - collection of DataObjects



recreate
public synchronized void recreate()(Code)
Starts recreation of the instance in special thread.



run
public void run()(Code)
Synchronously starts the creation of the instance.



toString
public String toString()(Code)



waitFinished
public void waitFinished()(Code)
Overrides the instance finished to deal with internal state correctly.



Fields inherited from org.openide.util.Task
final public static Task EMPTY(Code)(Java Doc)

Methods inherited from org.openide.util.Task
public synchronized void addTaskListener(TaskListener l)(Code)(Java Doc)
final public boolean isFinished()(Code)(Java Doc)
final protected void notifyFinished()(Code)(Java Doc)
final protected void notifyRunning()(Code)(Java Doc)
public synchronized void removeTaskListener(TaskListener l)(Code)(Java Doc)
public void run()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
public void waitFinished()(Code)(Java Doc)
public boolean waitFinished(long milliseconds) throws InterruptedException(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.