KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > source > JavaSourceAccessor


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.modules.java.source;
21
22 import com.sun.tools.javac.api.JavacTaskImpl;
23 import java.io.IOException JavaDoc;
24 import javax.tools.DiagnosticListener;
25 import javax.tools.JavaFileObject;
26 import org.netbeans.api.java.source.CancellableTask;
27 import org.netbeans.api.java.source.ClasspathInfo;
28 import org.netbeans.api.java.source.CompilationInfo;
29 import org.netbeans.api.java.source.JavaSource;
30 import org.netbeans.api.java.source.WorkingCopy;
31 import org.netbeans.api.java.source.query.QueryEnvironment;
32 import org.openide.ErrorManager;
33
34 /**
35  *
36  * @author Tomas Zezula
37  */

38 public abstract class JavaSourceAccessor {
39
40
41     static {
42         try {
43             Class.forName("org.netbeans.api.java.source.JavaSource", true, JavaSourceAccessor.class.getClassLoader()); //NOI18N
44
} catch (ClassNotFoundException JavaDoc e) {
45             ErrorManager.getDefault().notify (e);
46         }
47     }
48     
49     public static JavaSourceAccessor INSTANCE;
50     
51     
52     public void runSpecialTask (final CancellableTask<CompilationInfo> task, final JavaSource.Priority priority) {
53         INSTANCE.runSpecialTaskImpl (task, priority);
54     }
55     
56     protected abstract void runSpecialTaskImpl (CancellableTask<CompilationInfo> task, JavaSource.Priority priority);
57         
58     public abstract JavacTaskImpl createJavacTask(ClasspathInfo cpInfo, DiagnosticListener<? super JavaFileObject> diagnosticListener, String JavaDoc sourceLevel);
59     
60     
61     /**
62      * Returns the JavacTaskImpl associated with given {@link CompilationInfo},
63      * when it's not available it's created.
64      * @param compilationInfo which {@link JavacTaskImpl} should be obtained.
65      * @return {@link JavacTaskImpl} never returns null
66      */

67     public abstract JavacTaskImpl getJavacTask (CompilationInfo compilationInfo);
68     
69     /**
70      * Returns {@link QueryEnvironment} associated with the given {@link WorkingCopy}.
71      *
72      * @param copy {@link WorkingCopy} for which {@link QueryEnvironment} should be obtained
73      * @return {@link CQueryEnvironment associated with the given working copy
74      */

75     public abstract QueryEnvironment getCommandEnvironment(WorkingCopy copy);
76     
77     /**
78      * Returns a cached compilation info when available or null
79      * @param js {@link JavaSource} which {@CompilationInfo} should be returned
80      * @param phase to which the compilation info should be moved
81      * Can be called only from the dispatch thread!
82      * @return {@link CompilationInfo} or null
83      */

84     public abstract CompilationInfo getCurrentCompilationInfo (JavaSource js, JavaSource.Phase phase) throws IOException JavaDoc;
85     
86     public abstract void revalidate(JavaSource js);
87     
88     
89     /**
90      * Returns true when the caller is a {@link JavaSource} worker thread
91      * @return boolean
92      */

93     public abstract boolean isDispatchThread ();
94     
95 }
96
Popular Tags