KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > core > ITypeHierarchy


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.core;
12
13 import java.io.OutputStream JavaDoc;
14
15 import org.eclipse.core.runtime.IProgressMonitor;
16
17 /**
18  * A type hierarchy provides navigations between a type and its resolved
19  * supertypes and subtypes for a specific type or for all types within a region.
20  * Supertypes may extend outside of the type hierarchy's region in which it was
21  * created such that the root of the hierarchy is always included. For example, if a type
22  * hierarchy is created for a <code>java.io.File</code>, and the region the hierarchy was
23  * created in is the package fragment <code>java.io</code>, the supertype
24  * <code>java.lang.Object</code> will still be included.
25  * <p>
26  * A type hierarchy is static and can become stale. Although consistent when
27  * created, it does not automatically track changes in the model.
28  * As changes in the model potentially invalidate the hierarchy, change notifications
29  * are sent to registered <code>ITypeHierarchyChangedListener</code>s. Listeners should
30  * use the <code>exists</code> method to determine if the hierarchy has become completely
31  * invalid (for example, when the type or project the hierarchy was created on
32  * has been removed). To refresh a hierarchy, use the <code>refresh</code> method.
33  * </p>
34  * <p>
35  * The type hierarchy may contain cycles due to malformed supertype declarations.
36  * Most type hierarchy queries are oblivious to cycles; the <code>getAll* </code>
37  * methods are implemented such that they are unaffected by cycles.
38  * </p>
39  * <p>
40  * This interface is not intended to be implemented by clients.
41  * </p>
42  */

43 public interface ITypeHierarchy {
44 /**
45  * Adds the given listener for changes to this type hierarchy. Listeners are
46  * notified when this type hierarchy changes and needs to be refreshed.
47  * Has no effect if an identical listener is already registered.
48  *
49  * @param listener the listener
50  */

51 void addTypeHierarchyChangedListener(ITypeHierarchyChangedListener listener);
52 /**
53  * Returns whether the given type is part of this hierarchy.
54  *
55  * @param type the given type
56  * @return true if the given type is part of this hierarchy, false otherwise
57  */

58 boolean contains(IType type);
59 /**
60  * Returns whether the type and project this hierarchy was created on exist.
61  * @return true if the type and project this hierarchy was created on exist, false otherwise
62  */

63 boolean exists();
64 /**
65  * Returns all classes in this type hierarchy's graph, in no particular
66  * order. Any classes in the creation region which were not resolved to
67  * have any subtypes or supertypes are not included in the result.
68  *
69  * @return all classes in this type hierarchy's graph
70  */

71 IType[] getAllClasses();
72 /**
73  * Returns all interfaces in this type hierarchy's graph, in no particular
74  * order. Any interfaces in the creation region which were not resolved to
75  * have any subtypes or supertypes are not included in the result.
76  *
77  * @return all interfaces in this type hierarchy's graph
78  */

79 IType[] getAllInterfaces();
80 /**
81  * Returns all resolved subtypes (direct and indirect) of the
82  * given type, in no particular order, limited to the
83  * types in this type hierarchy's graph. An empty array
84  * is returned if there are no resolved subtypes for the
85  * given type.
86  *
87  * @param type the given type
88  * @return all resolved subtypes (direct and indirect) of the given type
89  */

90 IType[] getAllSubtypes(IType type);
91 /**
92  * Returns all resolved superclasses of the
93  * given class, in bottom-up order. An empty array
94  * is returned if there are no resolved superclasses for the
95  * given class.
96  *
97  * <p>NOTE: once a type hierarchy has been created, it is more efficient to
98  * query the hierarchy for superclasses than to query a class recursively up
99  * the superclass chain. Querying an element performs a dynamic resolution,
100  * whereas the hierarchy returns a pre-computed result.
101  *
102  * @param type the given type
103  * @return all resolved superclasses of the given class, in bottom-up order, an empty
104  * array if none.
105  */

106 IType[] getAllSuperclasses(IType type);
107 /**
108  * Returns all resolved superinterfaces (direct and indirect) of the given type.
109  * If the given type is a class, this includes all superinterfaces of all superclasses.
110  * An empty array is returned if there are no resolved superinterfaces for the
111  * given type.
112  *
113  * <p>NOTE: once a type hierarchy has been created, it is more efficient to
114  * query the hierarchy for superinterfaces than to query a type recursively.
115  * Querying an element performs a dynamic resolution,
116  * whereas the hierarchy returns a pre-computed result.
117  *
118  * @param type the given type
119  * @return all resolved superinterfaces (direct and indirect) of the given type, an empty array if none
120  */

121 IType[] getAllSuperInterfaces(IType type);
122 /**
123  * Returns all resolved supertypes of the
124  * given type, in bottom-up order. An empty array
125  * is returned if there are no resolved supertypes for the
126  * given type.
127  * <p>
128  * Note that <code>java.lang.Object</code> is NOT considered to be a supertype
129  * of any interface type.
130  * </p><p>NOTE: once a type hierarchy has been created, it is more efficient to
131  * query the hierarchy for supertypes than to query a type recursively up
132  * the supertype chain. Querying an element performs a dynamic resolution,
133  * whereas the hierarchy returns a pre-computed result.
134  *
135  * @param type the given type
136  * @return all resolved supertypes of the given class, in bottom-up order, an empty array
137  * if none
138  */

139 IType[] getAllSupertypes(IType type);
140 /**
141  * Returns all types in this type hierarchy's graph, in no particular
142  * order. Any types in the creation region which were not resolved to
143  * have any subtypes or supertypes are not included in the result.
144  *
145  * @return all types in this type hierarchy's grap
146  */

147 IType[] getAllTypes();
148
149 /**
150  * Return the flags associated with the given type (would be equivalent to <code>IMember.getFlags()</code>),
151  * or <code>-1</code> if this information wasn't cached on the hierarchy during its computation.
152  *
153  * @param type the given type
154  * @return the modifier flags for this member
155  * @see Flags
156  * @since 2.0
157  */

158 int getCachedFlags(IType type);
159
160 /**
161  * Returns all interfaces resolved to extend the given interface,
162  * in no particular order, limited to the interfaces in this
163  * hierarchy's graph.
164  * Returns an empty collection if the given type is a class, or
165  * if no interfaces were resolved to extend the given interface.
166  *
167  * @param type the given type
168  * @return all interfaces resolved to extend the given interface limited to the interfaces in this
169  * hierarchy's graph, an empty array if none.
170  */

171 IType[] getExtendingInterfaces(IType type);
172 /**
173  * Returns all classes resolved to implement the given interface,
174  * in no particular order, limited to the classes in this type
175  * hierarchy's graph. Returns an empty collection if the given type is a
176  * class, or if no classes were resolved to implement the given
177  * interface.
178  *
179  * @param type the given type
180  * @return all classes resolved to implement the given interface limited to the classes in this type
181  * hierarchy's graph, an empty array if none
182  */

183 IType[] getImplementingClasses(IType type);
184 /**
185  * Returns all classes in the graph which have no resolved superclass,
186  * in no particular order.
187  *
188  * @return all classes in the graph which have no resolved superclass
189  */

190 IType[] getRootClasses();
191 /**
192  * Returns all interfaces in the graph which have no resolved superinterfaces,
193  * in no particular order.
194  *
195  * @return all interfaces in the graph which have no resolved superinterfaces
196  */

197 IType[] getRootInterfaces();
198 /**
199  * Returns the direct resolved subclasses of the given class,
200  * in no particular order, limited to the classes in this
201  * type hierarchy's graph.
202  * Returns an empty collection if the given type is an interface,
203  * or if no classes were resolved to be subclasses of the given
204  * class.
205  *
206  * @param type the given type
207  * @return the direct resolved subclasses of the given class limited to the classes in this
208  * type hierarchy's graph, an empty collection if none.
209  */

210 IType[] getSubclasses(IType type);
211 /**
212  * Returns the direct resolved subtypes of the given type,
213  * in no particular order, limited to the types in this
214  * type hierarchy's graph.
215  * If the type is a class, this returns the resolved subclasses.
216  * If the type is an interface, this returns both the classes which implement
217  * the interface and the interfaces which extend it.
218  *
219  * @param type the given type
220  * @return the direct resolved subtypes of the given type limited to the types in this
221  * type hierarchy's graph
222  */

223 IType[] getSubtypes(IType type);
224 /**
225  * Returns the resolved superclass of the given class,
226  * or <code>null</code> if the given class has no superclass,
227  * the superclass could not be resolved, or if the given
228  * type is an interface.
229  *
230  * @param type the given type
231  * @return the resolved superclass of the given class,
232  * or <code>null</code> if the given class has no superclass,
233  * the superclass could not be resolved, or if the given
234  * type is an interface
235  */

236 IType getSuperclass(IType type);
237 /**
238  * Returns the direct resolved interfaces that the given type implements or extends,
239  * in no particular order, limited to the interfaces in this type
240  * hierarchy's graph.
241  * For classes, this gives the interfaces that the class implements.
242  * For interfaces, this gives the interfaces that the interface extends.
243  *
244  * @param type the given type
245  * @return the direct resolved interfaces that the given type implements or extends limited to the interfaces in this type
246  * hierarchy's graph
247  */

248 IType[] getSuperInterfaces(IType type);
249 /**
250  * Returns the resolved supertypes of the given type,
251  * in no particular order, limited to the types in this
252  * type hierarchy's graph.
253  * For classes, this returns its superclass and the interfaces that the class implements.
254  * For interfaces, this returns the interfaces that the interface extends. As a consequence
255  * <code>java.lang.Object</code> is NOT considered to be a supertype of any interface
256  * type.
257  *
258  * @param type the given type
259  * @return the resolved supertypes of the given type limited to the types in this
260  * type hierarchy's graph
261  */

262 IType[] getSupertypes(IType type);
263 /**
264  * Returns the type this hierarchy was computed for.
265  * Returns <code>null</code> if this hierarchy was computed for a region.
266  *
267  * @return the type this hierarchy was computed for
268  */

269 IType getType();
270 /**
271  * Re-computes the type hierarchy reporting progress.
272  *
273  * @param monitor the given progress monitor
274  * @exception JavaModelException if unable to refresh the hierarchy
275  */

276 void refresh(IProgressMonitor monitor) throws JavaModelException;
277 /**
278  * Removes the given listener from this type hierarchy.
279  * Has no affect if an identical listener is not registered.
280  *
281  * @param listener the listener
282  */

283 void removeTypeHierarchyChangedListener(ITypeHierarchyChangedListener listener);
284 /**
285  * Stores the type hierarchy in an output stream. This stored hierarchy can be load by
286  * IType#loadTypeHierachy(IJavaProject, InputStream, IProgressMonitor).
287  * Listeners of this hierarchy are not stored.
288  *
289  * Only hierarchies created by the following methods can be store:
290  * <ul>
291  * <li>IType#newSupertypeHierarchy(IProgressMonitor)</li>
292  * <li>IType#newTypeHierarchy(IJavaProject, IProgressMonitor)</li>
293  * <li>IType#newTypeHierarchy(IProgressMonitor)</li>
294  * </ul>
295  *
296  * @param outputStream output stream where the hierarchy will be stored
297  * @param monitor the given progress monitor
298  * @exception JavaModelException if unable to store the hierarchy in the ouput stream
299  * @see IType#loadTypeHierachy(java.io.InputStream, IProgressMonitor)
300  * @since 2.1
301  */

302 void store(OutputStream JavaDoc outputStream, IProgressMonitor monitor) throws JavaModelException;
303 }
304
Popular Tags