KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > java > source > query > QueryEnvironment


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.api.java.source.query;
21
22 import org.netbeans.api.java.source.ElementUtilities;
23 import org.netbeans.api.java.source.query.CommentHandler;
24 import org.netbeans.api.java.source.transform.UndoList;
25 import com.sun.source.tree.CompilationUnitTree;
26 import com.sun.source.tree.Tree;
27 import com.sun.source.util.Trees;
28 import javax.lang.model.util.Elements;
29 import javax.lang.model.util.Types;
30 import javax.tools.JavaFileManager;
31 import java.io.IOException JavaDoc;
32 import java.io.PrintWriter JavaDoc;
33 import org.netbeans.modules.java.source.engine.TreeMakerInt;
34
35 /**
36  * Defines the working environment for Jackpot's commands. This
37  * has two benefits. First, it helps avoid pinning javac memory
38  * so that it can be garbage-collected. Second, it
39  * defines the mechanisms for communicating status, log and error
40  * information back to its caller, so that application dependencies
41  * in commands are not required.
42  */

43 public interface QueryEnvironment {
44     
45     /**defaultenv
46      * Returns the Trees utility class initialized for this environment.
47      *
48      * @see com.sun.source.util.Trees
49      */

50     Trees getTrees();
51
52     /**
53      * Returns the shared CommentHandler of this environment.
54      * @see org.netbeans.jackpot.model.CommentHandler
55      */

56     CommentHandler getCommentHandler();
57
58     /**
59      * Returns the TreeMaker for this environment.
60      * @see org.netbeans.api.java.source.TreeMaker
61      */

62     TreeMakerInt getTreeMaker();
63
64     /**
65      * Returns the application's UndoList instance for this environment.
66      * @see org.netbeans.api.java.source.transform.UndoList
67      */

68     UndoList getUndoList();
69
70     /**
71      * Returns the root node of the abstract syntax tree. This is
72      * equivalent to (although it may be implemented differently)
73      * "<code>getModel().getRoot()</code>".
74      */

75     Tree getRootNode();
76     
77     /**
78      * Returns the Types instance for this environment.
79      * @see javax.lang.model.util.Types
80      */

81     Types getTypes();
82     
83     /**
84      * Returns the ElementUtilities instance for this environment.
85      *
86      * @see org.netbeans.jackpot.model.ElementUtilities
87      */

88     Elements getElements();
89     
90     /**
91      * Returns the ElementUtilities instance for this environment.
92      * @see org.netbeans.jackpot.model.ElementUtilities
93      */

94     ElementUtilities getElementUtilities();
95     
96     /**
97      * Returns the JavaFileManager implementation.
98      */

99     JavaFileManager getJavaFileManager();
100     
101     /**
102      * Returns the current source for a specified CompilationUnitTree.
103      * Any modifications will be applied to the result, so that the source
104      * code may not match the original source.
105      */

106     String JavaDoc toSource(CompilationUnitTree unit) throws IOException JavaDoc;
107     
108    /**
109      * Send the application the result object from the completion
110      * of an operator execution. This object is usually a ResultTableModel
111      * instance, but if not then its toString() method will be used. The
112      * title is optionally used when displaying the result, depending upon
113      * the client.
114      *
115      * @param result a status object
116      * @param title the title for the result pane
117      */

118     void setResult(Object JavaDoc result, String JavaDoc title);
119
120     /**
121      * Send the application an engine status message. A status message should
122      * normally be short enough to be displayed in an application status bar.
123      * Multiple status messages may be sent during a engine operation.
124      */

125     void setStatusMessage(String JavaDoc message);
126     
127     /**
128      * Send the application an error message regarding an operator
129      * execution. A long message may be sent, and normally a single
130      * error message is sent during a single execution.
131      */

132     void setErrorMessage(String JavaDoc message, String JavaDoc title);
133
134     /**
135      * Opens an output writer for log-type messages similar to what
136      * javac sends to System.out.
137      */

138     PrintWriter JavaDoc getOutputWriter(String JavaDoc title);
139 }
140
Popular Tags