Source code: javax/ide/model/java/source/tree/FileT.java
1 /*
2 * @(#)FileT.java
3 */
4
5 package javax.ide.model.java.source.tree;
6
7 import java.net.URI;
8 import java.util.List;
9 import java.util.Set;
10 import javax.ide.model.java.JavaModel;
11 import javax.ide.model.java.source.write.SingleTreeTransaction;
12 import javax.ide.model.java.source.write.TreeFactory;
13
14 /**
15 * The root of a source file, also called a compilation unit. From
16 * the root, a client may retrieve the package declaration, the import
17 * declarations, and all top-level type declarations. <p/>
18 *
19 * @author Andy Yu
20 * */
21 public interface FileT
22 extends Tree
23 {
24 // ----------------------------------------------------------------------
25
26 /**
27 * Gets the package declaration.
28 *
29 * @return The package symbol. Null if none.
30 */
31 public PackageT getPackage();
32
33 /**
34 * Gets the package name, empty if none.
35 *
36 * @return The name of the package declaration. An empty string, if none.
37 */
38 public String getPackageName();
39
40 /**
41 * Attempts to set the package declaration.
42 */
43 public void setPackage( PackageT packageD );
44
45 /**
46 * Attempts to set the name of the package declaration.
47 */
48 public void setPackageName( String packageName );
49
50 /**
51 * Gets the list of import declarations.
52 *
53 * @return The array of import symbols. Returns a collection of
54 * ImportT's. <p/>
55 *
56 * List of ImportTs.
57 */
58 public List getImports();
59
60 /**
61 * Gets the set of import strings.
62 *
63 * @return The set (of String's) of fully qualified import names. If
64 * you add a String value that does not already exist in the set,
65 * then an import will be generated for that value. If you add a
66 * String value that already does exist in the set, it will be
67 * ignored. <p/>
68 *
69 * Set of Strings.
70 */
71 public Set getImportNames();
72
73 /**
74 * Gets the list of top-level source classes.
75 *
76 * @return The array of class symbols. Returns a collection of ClassT's. <p/>
77 *
78 * List of ClassTs.
79 */
80 public List getClasses();
81
82 /**
83 * Gets the matching top-level source class.
84 *
85 * @return The matching class symbol. Null if none.
86 */
87 public ClassT getClassT( String name );
88
89 /**
90 * @return a Tree for the sql context. Null if none.
91 */
92 //public SourceName getSqlContext();
93
94 /**
95 * Gets the primary class. Here, "primary class" means the class
96 * that bears the same name as the compilation unit (file). If no
97 * class is defined with the same name as the compilation unit, then
98 * no class will be returned. If the compilation unit has no name,
99 * then the first class is returned. <p/>
100 *
101 * The term "primary class" is not actually used in any reference I
102 * tried: JLS, JPL, or Effective Java. It does see some usage on the
103 * web. The term "main class" could be confused with the run-time
104 * class whose "main(...)" method is being run.
105 *
106 * @return The primary class defined by this source file. Null if
107 * none.
108 */
109 public ClassT getPrimaryClass();
110
111
112 // ----------------------------------------------------------------------
113
114 /**
115 * Traverses the entire parse tree, calling
116 * <code>setProperty(key, null)</code> on each element.
117 */
118 public void clearAllProperties( String key );
119
120
121 // ----------------------------------------------------------------------
122
123 /**
124 * Gets the factory to create Tree objects in this FileT.
125 *
126 * @return The factory used to create Tree objects in this FileT.
127 */
128 public TreeFactory getFactory();
129
130 /**
131 * Gets the URI of this file, null if none.
132 *
133 * @return The URI of this file, null if none.
134 */
135 public URI getURI();
136
137 /**
138 * Gets the owning JavaModel.
139 *
140 * @return The owning JavaModel.
141 */
142 public JavaModel getOwningModel();
143
144 /**
145 * Begins a single-tree transaction.
146 *
147 * @return The transaction object.
148 */
149 public SingleTreeTransaction beginTransaction();
150
151 /**
152 * Gets the in-progress single-tree transaction, null if none. <p/>
153 *
154 * TODO: Should this be able to get the multi-tree transaction if
155 * one is open? <p/>
156 *
157 * @return The in-progress single-tree transaction, null if none.
158 */
159 public SingleTreeTransaction getTransaction();
160
161
162 // ----------------------------------------------------------------------
163 }