KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > spi > project > ProjectFactory


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.spi.project;
21
22 import java.io.IOException JavaDoc;
23 import org.netbeans.api.project.Project;
24 import org.openide.filesystems.FileObject;
25
26 /**
27  * Create in-memory projects from disk directories.
28  * Instances should be registered into default lookup.
29  * @author Jesse Glick
30  */

31 public interface ProjectFactory {
32
33     /**
34      * Test whether a given directory probably refers to a project recognized by this factory
35      * without actually trying to create it.
36      * <p>Should be as fast as possible as it might be called sequentially on a
37      * lot of directories.</p>
38      * <p>Need not be definite; it is permitted to return null or throw an exception
39      * from {@link #loadProject} even when returning <code>true</code> from this
40      * method, in case the directory looked like a project directory but in fact
41      * had something wrong with it.</p>
42      * <p>Will be called inside read access.</p>
43      * @param projectDirectory a directory which might refer to a project
44      * @return true if this factory recognizes it
45      */

46     boolean isProject(FileObject projectDirectory);
47     
48     /**
49      * Create a project that resides on disk.
50      * If this factory does not
51      * in fact recognize the directory, it should just return null.
52      * <p>Will be called inside read access.
53      * <p>Do not do your own caching! The project manager caches projects for you, properly.
54      * <p>Do not attempt to recognize subdirectories of your project directory (just return null),
55      * unless they are distinct nested projects.
56      * @param projectDirectory some directory on disk
57      * @param state a callback permitting the project to indicate when it is modified
58      * @return a matching project implementation, or null if this factory does not recognize it
59      */

60     Project loadProject(FileObject projectDirectory, ProjectState state) throws IOException JavaDoc;
61
62     /**
63      * Save a project to disk.
64      * <p>Will be called inside write access.
65      * @param project a project created with this factory's {@link #loadProject} method
66      * @throws IOException if there is a problem saving
67      * @throws ClassCastException if this factory did not create this project
68      */

69     void saveProject(Project project) throws IOException JavaDoc, ClassCastException JavaDoc;
70     
71 }
72
Popular Tags