KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > spi > java > classpath > ClassPathProvider


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.java.classpath;
21
22 import org.netbeans.api.java.classpath.ClassPath;
23 import org.openide.filesystems.FileObject;
24
25 /**
26  * Provider interface for Java classpaths.
27  * <p>
28  * The <code>org.netbeans.modules.java.project</code> module registers an
29  * implementation of this interface to global lookup which looks for the
30  * project which owns a file (if any) and checks its lookup for this interface,
31  * and if it finds an instance, delegates to it. Therefore it is not normally
32  * necessary for a project type provider to register its own instance just to
33  * define the classpaths for files it owns, assuming it depends on the Java
34  * Project module.
35  * </p>
36  * <div class="nonnormative">
37  * <p>
38  * Note that to make editor code completion functionality work for a Java source file the
39  * following classpaths must be available for it:
40  * </p>
41  * <ol>
42  * <li>The {@link ClassPath#BOOT} type of classpath
43  * is required or the source file will not be parsable and
44  * code completion will be disabled. See also
45  * {@link org.netbeans.spi.java.queries.SourceLevelQueryImplementation}.</li>
46  * <li>The {@link ClassPath#SOURCE} type of classpath
47  * is required or code completion will be disabled.
48  * Providing this classpath will enable code completion, but only elements
49  * defined on this classpath will be offered if the compile classpath is missing.</li>
50  * <li>The {@link ClassPath#COMPILE} type of classpath
51  * is recommended to be provide to make code completion work fully
52  * by suggesting all classes against which the source is developed.</li>
53  * </ol>
54  * <p>{@link ClassPath#EXECUTE} is also recommended for e.g. I18N functionality to work.
55  * This should contain the full run-time classpath of the class, including its build
56  * location (bytecode).</p>
57  * <p>You should return these classpaths for the package root folder and any
58  * files or folders inside it.</p>
59  * <p>You should register classpaths for source files of all these types in
60  * {@link org.netbeans.api.java.classpath.GlobalPathRegistry}
61  * when they are to be exposed in the GUI as available for use (e.g. for the editor's Fast Open dialog),
62  * and unregister them when they are no longer to be exposed. Typically this is done as part of
63  * <a HREF="@PROJECTS/PROJECTUIAPI@/org/netbeans/spi/project/ui/ProjectOpenedHook.html">ProjectOpenedHook</a>.
64  * <p>It is also desirable to produce classpath information for compiled class files
65  * (bytecode), including their package roots (whether a disk folder or a JAR root).
66  * This will enable parsing of the class files, which is sometimes needed (e.g. for
67  * expanding the class file node and seeing its members).
68  * Compiled classes should have:</p>
69  * <ol>
70  * <li>{@link ClassPath#BOOT} corresponding to the Java platform to be used with the classes.</li>
71  * <li>{@link ClassPath#EXECUTE} containing the bytecode's package root itself, plus any other
72  * libraries it needs to resolve against. Should normally be the same as the execute classpath
73  * of the corresponding source files.</li>
74  * </ol>
75  * <p>If no specific class path providers are available for a given source file or bytecode file,
76  * i.e. <code>null</code> is returned from all providers, there may be a fallback implementation
77  * which would provide reasonable defaults. For source files, this could mean a boot classpath
78  * corresponding to the default Java platform (i.e. the JDK being used to run the IDE); empty
79  * compile and execute classpaths; and a sourcepath computed based on the package statement in the
80  * source file (if this is possible). For class files, this could mean a boot classpath determined
81  * as for source files, and an execute classpath containing the package root apparently owning the
82  * class file (computed according to the class file's package information, if this is possible).</p>
83  * </div>
84  * @see ClassPath#getClassPath
85  * @see org.netbeans.api.java.classpath.GlobalPathRegistry
86  * @author Jesse Glick
87  * @since org.netbeans.api.java/1 1.4
88  */

89 public interface ClassPathProvider {
90     
91     /**
92      * Find some kind of a classpath for a given file.
93      * @param file a file somewhere, or a source root
94      * @param type a classpath type such as {@link ClassPath#COMPILE}
95      * @return an appropriate classpath, or null for no answer
96      * @see ClassPathFactory
97      * @see org.netbeans.spi.java.classpath.support.ClassPathSupport
98      */

99     ClassPath findClassPath(FileObject file, String JavaDoc type);
100     
101 }
102
Popular Tags