KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > source > engine > JackpotEngine


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.engine;
21
22 import org.netbeans.api.java.source.query.Query;
23 import org.netbeans.api.java.source.query.ResultTableModel;
24 import org.netbeans.api.java.source.transform.ChangeSet;
25 import org.netbeans.api.java.source.transform.Transformer;
26 import org.netbeans.modules.java.source.engine.JavaFormatOptions;
27 import org.netbeans.modules.java.source.engine.PropertySheetInfo;
28
29 import java.io.IOException JavaDoc;
30 import javax.tools.JavaFileObject;
31
32 /**
33  * The interface to the Jackpot engine, which defines methods to build a
34  * model, execute queries and transformer commands, and commit any changes.
35  */

36 public interface JackpotEngine {
37     /**
38      * Creates a Jackpot environment and builds its sources.
39      *
40      * @param sourcepath the path to use for locating source files.
41      * @param classpath the path to use to resolve source file references.
42      * @param source the javac source level, such as "1.5"
43      * @return the number of compilation errors from the build.
44      */

45     int initialize(String JavaDoc sourcepath, String JavaDoc classpath, String JavaDoc source) throws Exception JavaDoc;
46
47     /**
48      * Creates a Jackpot environment and builds its sources.
49      *
50      * @param sourcepath the path to use for locating source files.
51      * @param classpath the path to use to resolve source file references.
52      * @param bootclasspath the boot classpath to use when resolving source file references.
53      * @param source the javac source level, such as "1.5".
54      * @return the number of compilation errors from the build.
55      */

56     int initialize(String JavaDoc sourcepath, String JavaDoc classpath, String JavaDoc bootclasspath, String JavaDoc source) throws Exception JavaDoc;
57
58     /**
59      * Creates a Jackpot environment and builds its sources.
60      *
61      * @param sourcepath the path to use for locating source files.
62      * @param classpath the path to use to resolve source file references.
63      * @param bootclasspath the boot classpath to use when resolving source file references.
64      * @param source the javac source level, such as "1.5".
65      * @param encoding the source file encoding format, such as "UTF-8".
66      * @return the number of compilation errors from the build.
67      */

68     int initialize(String JavaDoc sourcepath, String JavaDoc classpath, String JavaDoc bootclasspath, String JavaDoc source, String JavaDoc encoding) throws Exception JavaDoc;
69     
70     /**
71      * Returns true when engine is ready to run commands.
72      */

73     boolean isInitialized();
74     
75     /**
76      * Returns the property sheet for this class, or null if it has no
77      * editable properties.
78      */

79     PropertySheetInfo getPropertySheetInfo(String JavaDoc className);
80     
81     /**
82      * Creates a Query instance and runs it. Note: a Transformer class
83      * can be successfully run via this command, but its refactoring
84      * description won't be specified.
85      */

86     ResultTableModel runCommand(String JavaDoc queryName, String JavaDoc className) throws Exception JavaDoc;
87     
88     /**
89      * Creates a Transformer instance and runs it.
90      */

91     ResultTableModel runCommand(String JavaDoc queryName, String JavaDoc transformerName, String JavaDoc className) throws Exception JavaDoc;
92     
93     /**
94      * Run multiple queries and transformations.
95      */

96     ResultTableModel runCommands(String JavaDoc queryName, Query[] queries) throws Exception JavaDoc;
97     
98     /**
99      * Creates a Query or Transformer instance but does not run it.
100      */

101     Query createCommand(String JavaDoc queryName, String JavaDoc transformerName, String JavaDoc className) throws Exception JavaDoc;
102     
103     /**
104      * Executes a rules file script.
105      */

106     ResultTableModel runScript(String JavaDoc queryName, String JavaDoc transformerName, String JavaDoc script) throws Exception JavaDoc;
107     
108     /**
109      * Creates a rules file script but does not execute it.
110      */

111     Transformer createScript(String JavaDoc queryName, String JavaDoc transformerName, String JavaDoc script) throws Exception JavaDoc;
112     
113     /**
114      * Undo the last transformation.
115      *
116      * @param erase if true, after undo remove the UndoEntry records from the UndoList.
117      */

118     void undo(boolean erase);
119     
120     /**
121      * Redo the last undone transformation.
122      */

123     void redo();
124     
125     /**
126      * Returns true if an undoable task exists.
127      */

128     boolean canUndo();
129     
130     /**
131      * Returns true if a redoable task exists.
132      */

133     boolean canRedo();
134     
135     /**
136      * Apply a list of changes to the model.
137      */

138     void applyChanges(ChangeSet changes);
139     
140     /**
141      * Returns true if changes need to be committed.
142      */

143     boolean needsCommit();
144     
145     /**
146      * Commits changes to source files. Returns false if operation was canceled.
147      */

148     boolean commit() throws IOException JavaDoc;
149     
150     /**
151      * Returns a copy of the current formatting options.
152      */

153     JavaFormatOptions getFormatOptions();
154
155     /**
156      * Formats source code using a specified set of formatting options.
157      */

158     String JavaDoc format(JavaFileObject source, JavaFormatOptions formatOptions) throws IOException JavaDoc;
159     
160     /**
161      * Closes engine.
162      */

163     void close();
164 }
165
Popular Tags