KickJava   Java API By Example, From Geeks To Geeks.

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


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  * IBM Corporation - added J2SE 1.5 support
11  *******************************************************************************/

12 package org.eclipse.jdt.core;
13
14 import java.io.InputStream JavaDoc;
15
16 import org.eclipse.core.runtime.IProgressMonitor;
17
18 /**
19  * Represents either a source type in a compilation unit (either a top-level
20  * type, a member type, a local type or an anonymous type)
21  * or a binary type in a class file. Enumeration classes and annotation
22  * types are subkinds of classes and interfaces, respectively.
23  * <p>
24  * Note that the element name of an anonymous source type is always empty.
25  * </p><p>
26  * If a binary type cannot be parsed, its structure remains unknown.
27  * Use <code>IJavaElement.isStructureKnown</code> to determine whether this
28  * is the case.
29  * </p>
30  * <p>
31  * The children are of type <code>IMember</code>, which includes <code>IField</code>,
32  * <code>IMethod</code>, <code>IInitializer</code> and <code>IType</code>.
33  * The children are listed in the order in which they appear in the source or class file.
34  * </p>
35  * <p>
36  * This interface is not intended to be implemented by clients.
37  * </p>
38  */

39 public interface IType extends IMember {
40     /**
41      * Do code completion inside a code snippet in the context of the current type.
42      *
43      * If the type can access to his source code and the insertion position is valid,
44      * then completion is performed against source. Otherwise the completion is performed
45      * against type structure and given locals variables.
46      *
47      * @param snippet the code snippet
48      * @param insertion the position with in source where the snippet
49      * is inserted. This position must not be in comments.
50      * A possible value is -1, if the position is not known.
51      * @param position the position within snippet where the user
52      * is performing code assist.
53      * @param localVariableTypeNames an array (possibly empty) of fully qualified
54      * type names of local variables visible at the current scope
55      * @param localVariableNames an array (possibly empty) of local variable names
56      * that are visible at the current scope
57      * @param localVariableModifiers an array (possible empty) of modifiers for
58      * local variables
59      * @param isStatic whether the current scope is in a static context
60      * @param requestor the completion requestor
61      * @exception JavaModelException if this element does not exist or if an
62      * exception occurs while accessing its corresponding resource.
63      * @since 2.0
64      * @deprecated Use {@link #codeComplete(char[],int,int,char[][],char[][],int[],boolean,CompletionRequestor)} instead.
65      */

66     void codeComplete(
67         char[] snippet,
68         int insertion,
69         int position,
70         char[][] localVariableTypeNames,
71         char[][] localVariableNames,
72         int[] localVariableModifiers,
73         boolean isStatic,
74         ICompletionRequestor requestor)
75         throws JavaModelException;
76
77     /**
78      * Do code completion inside a code snippet in the context of the current type.
79      * It considers types in the working copies with the given owner first. In other words,
80      * the owner's working copies will take precedence over their original compilation units
81      * in the workspace.
82      * <p>
83      * Note that if a working copy is empty, it will be as if the original compilation
84      * unit had been deleted.
85      * </p><p>
86      * If the type can access to his source code and the insertion position is valid,
87      * then completion is performed against source. Otherwise the completion is performed
88      * against type structure and given locals variables.
89      * </p>
90      *
91      * @param snippet the code snippet
92      * @param insertion the position with in source where the snippet
93      * is inserted. This position must not be in comments.
94      * A possible value is -1, if the position is not known.
95      * @param position the position with in snippet where the user
96      * is performing code assist.
97      * @param localVariableTypeNames an array (possibly empty) of fully qualified
98      * type names of local variables visible at the current scope
99      * @param localVariableNames an array (possibly empty) of local variable names
100      * that are visible at the current scope
101      * @param localVariableModifiers an array (possible empty) of modifiers for
102      * local variables
103      * @param isStatic whether the current scope is in a static context
104      * @param requestor the completion requestor
105      * @param owner the owner of working copies that take precedence over their original compilation units
106      * @exception JavaModelException if this element does not exist or if an
107      * exception occurs while accessing its corresponding resource.
108      * @since 3.0
109      * @deprecated Use {@link #codeComplete(char[],int,int,char[][],char[][],int[],boolean,CompletionRequestor,WorkingCopyOwner)} instead.
110      */

111     void codeComplete(
112         char[] snippet,
113         int insertion,
114         int position,
115         char[][] localVariableTypeNames,
116         char[][] localVariableNames,
117         int[] localVariableModifiers,
118         boolean isStatic,
119         ICompletionRequestor requestor,
120         WorkingCopyOwner owner)
121         throws JavaModelException;
122     
123     /**
124      * Do code completion inside a code snippet in the context of the current type.
125      *
126      * If the type can access to his source code and the insertion position is valid,
127      * then completion is performed against source. Otherwise the completion is performed
128      * against type structure and given locals variables.
129      *
130      * @param snippet the code snippet
131      * @param insertion the position with in source where the snippet
132      * is inserted. This position must not be in comments.
133      * A possible value is -1, if the position is not known.
134      * @param position the position within snippet where the user
135      * is performing code assist.
136      * @param localVariableTypeNames an array (possibly empty) of fully qualified
137      * type names of local variables visible at the current scope
138      * @param localVariableNames an array (possibly empty) of local variable names
139      * that are visible at the current scope
140      * @param localVariableModifiers an array (possible empty) of modifiers for
141      * local variables
142      * @param isStatic whether the current scope is in a static context
143      * @param requestor the completion requestor
144      * @exception JavaModelException if this element does not exist or if an
145      * exception occurs while accessing its corresponding resource.
146      * @since 3.1
147      */

148     void codeComplete(
149         char[] snippet,
150         int insertion,
151         int position,
152         char[][] localVariableTypeNames,
153         char[][] localVariableNames,
154         int[] localVariableModifiers,
155         boolean isStatic,
156         CompletionRequestor requestor)
157         throws JavaModelException;
158
159     /**
160      * Do code completion inside a code snippet in the context of the current type.
161      * It considers types in the working copies with the given owner first. In other words,
162      * the owner's working copies will take precedence over their original compilation units
163      * in the workspace.
164      * <p>
165      * Note that if a working copy is empty, it will be as if the original compilation
166      * unit had been deleted.
167      * </p><p>
168      * If the type can access to his source code and the insertion position is valid,
169      * then completion is performed against source. Otherwise the completion is performed
170      * against type structure and given locals variables.
171      * </p>
172      *
173      * @param snippet the code snippet
174      * @param insertion the position with in source where the snippet
175      * is inserted. This position must not be in comments.
176      * A possible value is -1, if the position is not known.
177      * @param position the position with in snippet where the user
178      * is performing code assist.
179      * @param localVariableTypeNames an array (possibly empty) of fully qualified
180      * type names of local variables visible at the current scope
181      * @param localVariableNames an array (possibly empty) of local variable names
182      * that are visible at the current scope
183      * @param localVariableModifiers an array (possible empty) of modifiers for
184      * local variables
185      * @param isStatic whether the current scope is in a static context
186      * @param requestor the completion requestor
187      * @param owner the owner of working copies that take precedence over their original compilation units
188      * @exception JavaModelException if this element does not exist or if an
189      * exception occurs while accessing its corresponding resource.
190      * @since 3.1
191      */

192     void codeComplete(
193         char[] snippet,
194         int insertion,
195         int position,
196         char[][] localVariableTypeNames,
197         char[][] localVariableNames,
198         int[] localVariableModifiers,
199         boolean isStatic,
200         CompletionRequestor requestor,
201         WorkingCopyOwner owner)
202         throws JavaModelException;
203
204
205     /**
206      * Creates and returns a field in this type with the
207      * given contents.
208      * <p>
209      * Optionally, the new element can be positioned before the specified
210      * sibling. If no sibling is specified, the element will be inserted
211      * as the last field declaration in this type.</p>
212      *
213      * <p>It is possible that a field with the same name already exists in this type.
214      * The value of the <code>force</code> parameter effects the resolution of
215      * such a conflict:<ul>
216      * <li> <code>true</code> - in this case the field is created with the new contents</li>
217      * <li> <code>false</code> - in this case a <code>JavaModelException</code> is thrown</li>
218      * </ul></p>
219      *
220      * @param contents the given contents
221      * @param sibling the given sibling
222      * @param force a flag in case the same name already exists in this type
223      * @param monitor the given progress monitor
224      * @exception JavaModelException if the element could not be created. Reasons include:
225      * <ul>
226      * <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
227      * <li> A <code>CoreException</code> occurred while updating an underlying resource
228      * <li> The specified sibling is not a child of this type (INVALID_SIBLING)
229      * <li> The contents could not be recognized as a field declaration (INVALID_CONTENTS)
230      * <li> This type is read-only (binary) (READ_ONLY)
231      * <li> There was a naming collision with an existing field (NAME_COLLISION)
232      * </ul>
233      * @return a field in this type with the given contents
234      */

235     IField createField(String JavaDoc contents, IJavaElement sibling, boolean force, IProgressMonitor monitor)
236         throws JavaModelException;
237         
238     /**
239      * Creates and returns a static initializer in this type with the
240      * given contents.
241      * <p>
242      * Optionally, the new element can be positioned before the specified
243      * sibling. If no sibling is specified, the new initializer is positioned
244      * after the last existing initializer declaration, or as the first member
245      * in the type if there are no initializers.</p>
246      *
247      * @param contents the given contents
248      * @param sibling the given sibling
249      * @param monitor the given progress monitor
250      * @exception JavaModelException if the element could not be created. Reasons include:
251      * <ul>
252      * <li> This element does not exist
253      * <li> A <code>CoreException</code> occurred while updating an underlying resource
254      * <li> The specified sibling is not a child of this type (INVALID_SIBLING)
255      * <li> The contents could not be recognized as an initializer declaration (INVALID_CONTENTS)
256      * <li> This type is read-only (binary) (READ_ONLY)
257      * </ul>
258      * @return a static initializer in this type with the given contents
259      */

260     IInitializer createInitializer(String JavaDoc contents, IJavaElement sibling, IProgressMonitor monitor)
261         throws JavaModelException;
262         
263     /**
264      * Creates and returns a method or constructor in this type with the
265      * given contents.
266      * <p>
267      * Optionally, the new element can be positioned before the specified
268      * sibling. If no sibling is specified, the element will be appended
269      * to this type.
270      *
271      * <p>It is possible that a method with the same signature already exists in this type.
272      * The value of the <code>force</code> parameter effects the resolution of
273      * such a conflict:<ul>
274      * <li> <code>true</code> - in this case the method is created with the new contents</li>
275      * <li> <code>false</code> - in this case a <code>JavaModelException</code> is thrown</li>
276      * </ul></p>
277      *
278      * @param contents the given contents
279      * @param sibling the given sibling
280      * @param force a flag in case the same name already exists in this type
281      * @param monitor the given progress monitor
282      * @exception JavaModelException if the element could not be created. Reasons include:
283      * <ul>
284      * <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
285      * <li> A <code>CoreException</code> occurred while updating an underlying resource
286      * <li> The specified sibling is not a child of this type (INVALID_SIBLING)
287      * <li> The contents could not be recognized as a method or constructor
288      * declaration (INVALID_CONTENTS)
289      * <li> This type is read-only (binary) (READ_ONLY)
290      * <li> There was a naming collision with an existing method (NAME_COLLISION)
291      * </ul>
292      * @return a method or constructor in this type with the given contents
293      */

294     IMethod createMethod(String JavaDoc contents, IJavaElement sibling, boolean force, IProgressMonitor monitor)
295         throws JavaModelException;
296         
297     /**
298      * Creates and returns a type in this type with the
299      * given contents.
300      * <p>
301      * Optionally, the new type can be positioned before the specified
302      * sibling. If no sibling is specified, the type will be appended
303      * to this type.</p>
304      *
305      * <p>It is possible that a type with the same name already exists in this type.
306      * The value of the <code>force</code> parameter effects the resolution of
307      * such a conflict:<ul>
308      * <li> <code>true</code> - in this case the type is created with the new contents</li>
309      * <li> <code>false</code> - in this case a <code>JavaModelException</code> is thrown</li>
310      * </ul></p>
311      *
312      * @param contents the given contents
313      * @param sibling the given sibling
314      * @param force a flag in case the same name already exists in this type
315      * @param monitor the given progress monitor
316      * @exception JavaModelException if the element could not be created. Reasons include:
317      * <ul>
318      * <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
319      * <li> A <code>CoreException</code> occurred while updating an underlying resource
320      * <li> The specified sibling is not a child of this type (INVALID_SIBLING)
321      * <li> The contents could not be recognized as a type declaration (INVALID_CONTENTS)
322      * <li> This type is read-only (binary) (READ_ONLY)
323      * <li> There was a naming collision with an existing field (NAME_COLLISION)
324      * </ul>
325      * @return a type in this type with the given contents
326      */

327     IType createType(String JavaDoc contents, IJavaElement sibling, boolean force, IProgressMonitor monitor)
328         throws JavaModelException;
329         
330     /**
331      * Finds the methods in this type that correspond to
332      * the given method.
333      * A method m1 corresponds to another method m2 if:
334      * <ul>
335      * <li>m1 has the same element name as m2.
336      * <li>m1 has the same number of arguments as m2 and
337      * the simple names of the argument types must be equals.
338      * <li>m1 exists.
339      * </ul>
340      * @param method the given method
341      * @return the found method or <code>null</code> if no such methods can be found.
342      *
343      * @since 2.0
344      */

345     IMethod[] findMethods(IMethod method);
346     
347     /**
348      * Returns the children of this type that have the given category as a <code>@category</code> tag.
349      * Returns an empty array if no children with this category exist.
350      *
351      * @return the children for the given category.
352      * @exception JavaModelException if this element does not exist or if an
353      * exception occurs while accessing its corresponding resource.
354      * @since 3.2
355      */

356     IJavaElement[] getChildrenForCategory(String JavaDoc category) throws JavaModelException;
357
358     /**
359      * Returns the simple name of this type, unqualified by package or enclosing type.
360      * This is a handle-only method.
361      *
362      * @return the simple name of this type
363      */

364     String JavaDoc getElementName();
365     
366     /**
367      * Returns the field with the specified name
368      * in this type (for example, <code>"bar"</code>).
369      * This is a handle-only method. The field may or may not exist.
370      *
371      * @param name the given name
372      * @return the field with the specified name in this type
373      */

374     IField getField(String JavaDoc name);
375     
376     /**
377      * Returns the fields declared by this type.
378      * If this is a source type, the results are listed in the order
379      * in which they appear in the source, otherwise, the results are
380      * in no particular order. For binary types, this includes synthetic fields.
381      *
382      * @exception JavaModelException if this element does not exist or if an
383      * exception occurs while accessing its corresponding resource.
384      * @return the fields declared by this type
385      */

386     IField[] getFields() throws JavaModelException;
387     
388     /**
389      * Returns the fully qualified name of this type,
390      * including qualification for any containing types and packages.
391      * This is the name of the package, followed by <code>'.'</code>,
392      * followed by the type-qualified name.
393      * This is a handle-only method.
394      *
395      * @see IType#getTypeQualifiedName()
396      * @return the fully qualified name of this type
397      */

398     String JavaDoc getFullyQualifiedName();
399     
400     /**
401      * Returns the fully qualified name of this type,
402      * including qualification for any containing types and packages.
403      * This is the name of the package, followed by <code>'.'</code>,
404      * followed by the type-qualified name using the <code>enclosingTypeSeparator</code>.
405      *
406      * For example:
407      * <ul>
408      * <li>the fully qualified name of a class B defined as a member of a class A in a compilation unit A.java
409      * in a package x.y using the '.' separator is "x.y.A.B"</li>
410      * <li>the fully qualified name of a class B defined as a member of a class A in a compilation unit A.java
411      * in a package x.y using the '$' separator is "x.y.A$B"</li>
412      * <li>the fully qualified name of a binary type whose class file is x/y/A$B.class
413      * using the '.' separator is "x.y.A.B"</li>
414      * <li>the fully qualified name of a binary type whose class file is x/y/A$B.class
415      * using the '$' separator is "x.y.A$B"</li>
416      * <li>the fully qualified name of an anonymous binary type whose class file is x/y/A$1.class
417      * using the '.' separator is "x.y.A$1"</li>
418      * </ul>
419      *
420      * This is a handle-only method.
421      *
422      * @param enclosingTypeSeparator the given enclosing type separator
423      * @return the fully qualified name of this type, including qualification for any containing types and packages
424      * @see IType#getTypeQualifiedName(char)
425      * @since 2.0
426      */

427     String JavaDoc getFullyQualifiedName(char enclosingTypeSeparator);
428     
429     /**
430      * Returns this type's fully qualified name followed by its type parameters between angle brakets if it is a generic type.
431      * For example, "p.X&lt;T&gt;", "java.util.Map&lt;java.lang.String, p.X&gt;"
432      *
433      * @exception JavaModelException if this element does not exist or if an
434      * exception occurs while accessing its corresponding resource.
435      * @return the fully qualified parameterized representation of this type
436      * @since 3.1
437      */

438     String JavaDoc getFullyQualifiedParameterizedName() throws JavaModelException;
439
440     /**
441      * Returns the initializer with the specified position relative to
442      * the order they are defined in the source.
443      * Numbering starts at 1 (thus the first occurrence is occurrence 1, not occurrence 0).
444      * This is a handle-only method. The initializer may or may not be present.
445      *
446      * @param occurrenceCount the specified position
447      * @return the initializer with the specified position relative to the order they are defined in the source
448      */

449     IInitializer getInitializer(int occurrenceCount);
450     
451     /**
452      * Returns the initializers declared by this type.
453      * For binary types this is an empty collection.
454      * If this is a source type, the results are listed in the order
455      * in which they appear in the source.
456      *
457      * @exception JavaModelException if this element does not exist or if an
458      * exception occurs while accessing its corresponding resource.
459      * @return the initializers declared by this type
460      */

461     IInitializer[] getInitializers() throws JavaModelException;
462     
463     /**
464      * Returns the binding key for this type. A binding key is a key that uniquely
465      * identifies this type. It allows access to generic info for parameterized
466      * types.
467      *
468      * @return the binding key for this type
469      * @see org.eclipse.jdt.core.dom.IBinding#getKey()
470      * @see BindingKey
471      * @since 3.1
472      */

473     String JavaDoc getKey();
474     
475     /**
476      * Returns the method with the specified name and parameter types
477      * in this type (for example, <code>"foo", {"I", "QString;"}</code>).
478      * To get the handle for a constructor, the name specified must be the
479      * simple name of the enclosing type.
480      * This is a handle-only method. The method may or may not be present.
481      * <p>
482      * The type signatures may be either unresolved (for source types)
483      * or resolved (for binary types), and either basic (for basic types)
484      * or rich (for parameterized types). See {@link Signature} for details.
485      * </p>
486      *
487      * @param name the given name
488      * @param parameterTypeSignatures the given parameter types
489      * @return the method with the specified name and parameter types in this type
490      */

491     IMethod getMethod(String JavaDoc name, String JavaDoc[] parameterTypeSignatures);
492     
493     /**
494      * Returns the methods and constructors declared by this type.
495      * For binary types, this may include the special <code>&lt;clinit&gt;</code>; method
496      * and synthetic methods.
497      * If this is a source type, the results are listed in the order
498      * in which they appear in the source, otherwise, the results are
499      * in no particular order.
500      *
501      * @exception JavaModelException if this element does not exist or if an
502      * exception occurs while accessing its corresponding resource.
503      * @return the methods and constructors declared by this type
504      */

505     IMethod[] getMethods() throws JavaModelException;
506     
507     /**
508      * Returns the package fragment in which this element is defined.
509      * This is a handle-only method.
510      *
511      * @return the package fragment in which this element is defined
512      */

513     IPackageFragment getPackageFragment();
514     
515     /**
516      * Returns the name of this type's superclass, or <code>null</code>
517      * for source types that do not specify a superclass.
518      * <p>
519      * For interfaces, the superclass name is always <code>"java.lang.Object"</code>.
520      * For source types, the name as declared is returned, for binary types,
521      * the resolved, qualified name is returned.
522      * For anonymous types, the superclass name is the name appearing after the 'new' keyword'.
523      * If the superclass is a parameterized type, the string
524      * may include its type arguments enclosed in "&lt;&gt;".
525      * If the returned string is needed for anything other than display
526      * purposes, use {@link #getSuperclassTypeSignature()} which returns
527      * a structured type signature string containing more precise information.
528      * </p>
529      *
530      * @exception JavaModelException if this element does not exist or if an
531      * exception occurs while accessing its corresponding resource.
532      * @return the name of this type's superclass, or <code>null</code> for source types that do not specify a superclass
533      */

534     String JavaDoc getSuperclassName() throws JavaModelException;
535     
536     /**
537      * Returns the type signature of this type's superclass, or
538      * <code>null</code> if none.
539      * <p>
540      * The type signature may be either unresolved (for source types)
541      * or resolved (for binary types), and either basic (for basic types)
542      * or rich (for parameterized types). See {@link Signature} for details.
543      * </p>
544      *
545      * @exception JavaModelException if this element does not exist or if an
546      * exception occurs while accessing its corresponding resource.
547      * @return the type signature of this type's superclass, or
548      * <code>null</code> if none
549      * @since 3.0
550      */

551     String JavaDoc getSuperclassTypeSignature() throws JavaModelException;
552     
553     /**
554      * Returns the type signatures of the interfaces that this type
555      * implements or extends, in the order in which they are listed in the
556      * source.
557      * <p>
558      * For classes and enum types, this gives the interfaces that this
559      * class implements. For interfaces and annotation types,
560      * this gives the interfaces that this interface extends.
561      * An empty collection is returned if this type does not implement or
562      * extend any interfaces. For anonymous types, an empty collection is
563      * always returned.
564      * </p>
565      * <p>
566      * The type signatures may be either unresolved (for source types)
567      * or resolved (for binary types), and either basic (for basic types)
568      * or rich (for parameterized types). See {@link Signature} for details.
569      * </p>
570      *
571      * @exception JavaModelException if this element does not exist or if an
572      * exception occurs while accessing its corresponding resource.
573      * @return the type signatures of interfaces that this type implements
574      * or extends, in the order in which they are listed in the source,
575      * an empty collection if none
576      * @since 3.0
577      */

578     String JavaDoc[] getSuperInterfaceTypeSignatures() throws JavaModelException;
579     
580     /**
581      * Returns the names of interfaces that this type implements or extends,
582      * in the order in which they are listed in the source.
583      * <p>
584      * For classes, this gives the interfaces that this class implements.
585      * For interfaces, this gives the interfaces that this interface extends.
586      * An empty collection is returned if this type does not implement or
587      * extend any interfaces. For source types, simple names are returned,
588      * for binary types, qualified names are returned.
589      * For anonymous types, an empty collection is always returned.
590      * If the list of supertypes includes parameterized types,
591      * the string may include type arguments enclosed in "&lt;&gt;".
592      * If the result is needed for anything other than display
593      * purposes, use {@link #getSuperInterfaceTypeSignatures()} which returns
594      * structured signature strings containing more precise information.
595      * </p>
596      *
597      * @exception JavaModelException if this element does not exist or if an
598      * exception occurs while accessing its corresponding resource.
599      * @return the names of interfaces that this type implements or extends, in the order in which they are listed in the source,
600      * an empty collection if none
601      */

602     String JavaDoc[] getSuperInterfaceNames() throws JavaModelException;
603     
604     /**
605      * Returns the formal type parameter signatures for this type.
606      * Returns an empty array if this type has no formal type parameters.
607      * <p>
608      * The formal type parameter signatures may be either unresolved (for source
609      * types) or resolved (for binary types). See {@link Signature} for details.
610      * </p>
611      *
612      * @exception JavaModelException if this element does not exist or if an
613      * exception occurs while accessing its corresponding resource.
614      * @return the formal type parameter signatures of this type,
615      * in the order declared in the source, an empty array if none
616      * @see Signature
617      * @since 3.0
618      */

619     String JavaDoc[] getTypeParameterSignatures() throws JavaModelException;
620     
621     /**
622      * Returns the formal type parameters for this type.
623      * Returns an empty array if this type has no formal type parameters.
624      *
625      * @exception JavaModelException if this element does not exist or if an
626      * exception occurs while accessing its corresponding resource.
627      * @return the formal type parameters of this type,
628      * in the order declared in the source, an empty array if none
629      * @since 3.1
630      */

631     ITypeParameter[] getTypeParameters() throws JavaModelException;
632
633     /**
634      * Returns the member type declared in this type with the given simple name.
635      * This is a handle-only method. The type may or may not exist.
636      *
637      * @param name the given simple name
638      * @return the member type declared in this type with the given simple name
639      */

640     IType getType(String JavaDoc name);
641     
642     /**
643      * Returns the type parameter declared in this type with the given name.
644      * This is a handle-only method. The type parameter may or may not exist.
645      *
646      * @param name the given simple name
647      * @return the type parameter declared in this type with the given name
648      * @since 3.1
649      */

650     ITypeParameter getTypeParameter(String JavaDoc name);
651     
652     /**
653      * Returns the type-qualified name of this type,
654      * including qualification for any enclosing types,
655      * but not including package qualification.
656      * For source types, this consists of the simple names of any enclosing types,
657      * separated by <code>'$'</code>, followed by the simple name of this type
658      * or the occurence count of this type if it is anonymous.
659      * For binary types, this is the name of the class file without the ".class" suffix.
660      * This is a handle-only method.
661      *
662      * @return the type-qualified name of this type
663      */

664     String JavaDoc getTypeQualifiedName();
665     
666     /**
667      * Returns the type-qualified name of this type,
668      * including qualification for any enclosing types,
669      * but not including package qualification.
670      * For source types, this consists of the simple names of any enclosing types,
671      * separated by <code>enclosingTypeSeparator</code>, followed by the
672      * simple name of this type or the occurence count of this type if it is anonymous.
673      * For binary types, this is the name of the class file without the ".class" suffix.
674      *
675      * For example:
676      * <ul>
677      * <li>the type qualified name of a class B defined as a member of a class A
678      * using the '.' separator is "A.B"</li>
679      * <li>the type qualified name of a class B defined as a member of a class A
680      * using the '$' separator is "A$B"</li>
681      * <li>the type qualified name of a binary type whose class file is A$B.class
682      * using the '.' separator is "A$B"</li>
683      * <li>the type qualified name of a binary type whose class file is A$B.class
684      * using the '$' separator is "A$B"</li>
685      * <li>the type qualified name of an anonymous binary type whose class file is A$1.class
686      * using the '.' separator is "A$1"</li>
687      * </ul>
688      *
689      * This is a handle-only method.
690      *
691      * @param enclosingTypeSeparator the specified enclosing type separator
692      * @return the type-qualified name of this type
693      * @since 2.0
694      */

695     String JavaDoc getTypeQualifiedName(char enclosingTypeSeparator);
696     
697     /**
698      * Returns the immediate member types declared by this type.
699      * The results are listed in the order in which they appear in the source or class file.
700      *
701      * @exception JavaModelException if this element does not exist or if an
702      * exception occurs while accessing its corresponding resource.
703      * @return the immediate member types declared by this type
704      */

705     IType[] getTypes() throws JavaModelException;
706     
707     /**
708      * Returns whether this type represents an anonymous type.
709      *
710      * @exception JavaModelException if this element does not exist or if an
711      * exception occurs while accessing its corresponding resource.
712      * @return true if this type represents an anonymous type, false otherwise
713      * @since 2.0
714      */

715     boolean isAnonymous() throws JavaModelException;
716
717     /**
718      * Returns whether this type represents a class.
719      * <p>
720      * Note that a class can neither be an interface, an enumeration class, nor an annotation type.
721      * </p>
722      *
723      * @exception JavaModelException if this element does not exist or if an
724      * exception occurs while accessing its corresponding resource.
725      * @return true if this type represents a class, false otherwise
726      */

727     boolean isClass() throws JavaModelException;
728     
729     /**
730      * Returns whether this type represents an enumeration class.
731      * <p>
732      * Note that an enumeration class can neither be a class, an interface, nor an annotation type.
733      * </p>
734      *
735      * @exception JavaModelException if this element does not exist or if an
736      * exception occurs while accessing its corresponding resource.
737      * @return true if this type represents an enumeration class,
738      * false otherwise
739      * @since 3.0
740      */

741     boolean isEnum() throws JavaModelException;
742
743     /**
744      * Returns whether this type represents an interface.
745      * <p>
746      * Note that an interface can also be an annotation type, but it can neither be a class nor an enumeration class.
747      * </p>
748      *
749      * @exception JavaModelException if this element does not exist or if an
750      * exception occurs while accessing its corresponding resource.
751      * @return true if this type represents an interface, false otherwise
752      */

753     boolean isInterface() throws JavaModelException;
754     
755     /**
756      * Returns whether this type represents an annotation type.
757      * <p>
758      * Note that an annotation type is also an interface, but it can neither be a class nor an enumeration class.
759      * </p>
760      *
761      * @exception JavaModelException if this element does not exist or if an
762      * exception occurs while accessing its corresponding resource.
763      * @return true if this type represents an annotation type,
764      * false otherwise
765      * @since 3.0
766      */

767     boolean isAnnotation() throws JavaModelException;
768
769     /**
770      * Returns whether this type represents a local type.
771      *
772      * @exception JavaModelException if this element does not exist or if an
773      * exception occurs while accessing its corresponding resource.
774      * @return true if this type represents a local type, false otherwise
775      * @since 2.0
776      */

777     boolean isLocal() throws JavaModelException;
778
779     /**
780      * Returns whether this type represents a member type.
781      *
782      * @exception JavaModelException if this element does not exist or if an
783      * exception occurs while accessing its corresponding resource.
784      * @return true if this type represents a member type, false otherwise
785      * @since 2.0
786      */

787     boolean isMember() throws JavaModelException;
788     /**
789      * Returns whether this type represents a resolved type.
790      * If a type is resolved, its key contains resolved information.
791      *
792      * @return whether this type represents a resolved type.
793      * @since 3.1
794      */

795     boolean isResolved();
796     /**
797      * Loads a previously saved ITypeHierarchy from an input stream. A type hierarchy can
798      * be stored using ITypeHierachy#store(OutputStream).
799      *
800      * Only hierarchies originally created by the following methods can be loaded:
801      * <ul>
802      * <li>IType#newSupertypeHierarchy(IProgressMonitor)</li>
803      * <li>IType#newTypeHierarchy(IJavaProject, IProgressMonitor)</li>
804      * <li>IType#newTypeHierarchy(IProgressMonitor)</li>
805      * </ul>
806      *
807      * @param input stream where hierarchy will be read
808      * @param monitor the given progress monitor
809      * @return the stored hierarchy
810      * @exception JavaModelException if the hierarchy could not be restored, reasons include:
811      * - type is not the focus of the hierarchy or
812      * - unable to read the input stream (wrong format, IOException during reading, ...)
813      * @see ITypeHierarchy#store(java.io.OutputStream, IProgressMonitor)
814      * @since 2.1
815      */

816     ITypeHierarchy loadTypeHierachy(InputStream JavaDoc input, IProgressMonitor monitor) throws JavaModelException;
817     /**
818      * Creates and returns a type hierarchy for this type containing
819      * this type and all of its supertypes.
820      *
821      * @param monitor the given progress monitor
822      * @exception JavaModelException if this element does not exist or if an
823      * exception occurs while accessing its corresponding resource.
824      * @return a type hierarchy for this type containing this type and all of its supertypes
825      */

826     ITypeHierarchy newSupertypeHierarchy(IProgressMonitor monitor) throws JavaModelException;
827     
828     /**
829      * Creates and returns a type hierarchy for this type containing
830      * this type and all of its supertypes, considering types in the given
831      * working copies. In other words, the list of working copies will take
832      * precedence over their original compilation units in the workspace.
833      * <p>
834      * Note that passing an empty working copy will be as if the original compilation
835      * unit had been deleted.
836      * </p>
837      *
838      * @param workingCopies the working copies that take precedence over their original compilation units
839      * @param monitor the given progress monitor
840      * @return a type hierarchy for this type containing this type and all of its supertypes
841      * @exception JavaModelException if this element does not exist or if an
842      * exception occurs while accessing its corresponding resource.
843      * @since 3.0
844      */

845     ITypeHierarchy newSupertypeHierarchy(ICompilationUnit[] workingCopies, IProgressMonitor monitor)
846         throws JavaModelException;
847         
848     /**
849      * Creates and returns a type hierarchy for this type containing
850      * this type and all of its supertypes, considering types in the given
851      * working copies. In other words, the list of working copies will take
852      * precedence over their original compilation units in the workspace.
853      * <p>
854      * Note that passing an empty working copy will be as if the original compilation
855      * unit had been deleted.
856      * </p>
857      *
858      * @param workingCopies the working copies that take precedence over their original compilation units
859      * @param monitor the given progress monitor
860      * @return a type hierarchy for this type containing this type and all of its supertypes
861      * @exception JavaModelException if this element does not exist or if an
862      * exception occurs while accessing its corresponding resource.
863      * @since 2.0
864      * @deprecated Use {@link #newSupertypeHierarchy(ICompilationUnit[], IProgressMonitor)} instead
865      */

866     ITypeHierarchy newSupertypeHierarchy(IWorkingCopy[] workingCopies, IProgressMonitor monitor)
867         throws JavaModelException;
868         
869     /**
870      * Creates and returns a type hierarchy for this type containing
871      * this type and all of its supertypes, considering types in the
872      * working copies with the given owner.
873      * In other words, the owner's working copies will take
874      * precedence over their original compilation units in the workspace.
875      * <p>
876      * Note that if a working copy is empty, it will be as if the original compilation
877      * unit had been deleted.
878      * <p>
879      *
880      * @param owner the owner of working copies that take precedence over their original compilation units
881      * @param monitor the given progress monitor
882      * @return a type hierarchy for this type containing this type and all of its supertypes
883      * @exception JavaModelException if this element does not exist or if an
884      * exception occurs while accessing its corresponding resource.
885      * @since 3.0
886      */

887     ITypeHierarchy newSupertypeHierarchy(WorkingCopyOwner owner, IProgressMonitor monitor)
888         throws JavaModelException;
889
890     /**
891      * Creates and returns a type hierarchy for this type containing
892      * this type, all of its supertypes, and all its subtypes
893      * in the context of the given project.
894      *
895      * @param project the given project
896      * @param monitor the given progress monitor
897      * @exception JavaModelException if this element does not exist or if an
898      * exception occurs while accessing its corresponding resource.
899      * @return a type hierarchy for this type containing
900      * this type, all of its supertypes, and all its subtypes
901      * in the context of the given project
902      */

903     ITypeHierarchy newTypeHierarchy(IJavaProject project, IProgressMonitor monitor) throws JavaModelException;
904     
905     /**
906      * Creates and returns a type hierarchy for this type containing
907      * this type, all of its supertypes, and all its subtypes
908      * in the context of the given project, considering types in the
909      * working copies with the given owner.
910      * In other words, the owner's working copies will take
911      * precedence over their original compilation units in the workspace.
912      * <p>
913      * Note that if a working copy is empty, it will be as if the original compilation
914      * unit had been deleted.
915      * <p>
916      *
917      * @param project the given project
918      * @param owner the owner of working copies that take precedence over their original compilation units
919      * @param monitor the given progress monitor
920      * @exception JavaModelException if this element does not exist or if an
921      * exception occurs while accessing its corresponding resource.
922      * @return a type hierarchy for this type containing
923      * this type, all of its supertypes, and all its subtypes
924      * in the context of the given project
925      * @since 3.0
926      */

927     ITypeHierarchy newTypeHierarchy(IJavaProject project, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException;
928
929     /**
930      * Creates and returns a type hierarchy for this type containing
931      * this type, all of its supertypes, and all its subtypes in the workspace.
932      *
933      * @param monitor the given progress monitor
934      * @exception JavaModelException if this element does not exist or if an
935      * exception occurs while accessing its corresponding resource.
936      * @return a type hierarchy for this type containing
937      * this type, all of its supertypes, and all its subtypes in the workspace
938      */

939     ITypeHierarchy newTypeHierarchy(IProgressMonitor monitor) throws JavaModelException;
940     
941     /**
942      * Creates and returns a type hierarchy for this type containing
943      * this type, all of its supertypes, and all its subtypes in the workspace,
944      * considering types in the given working copies. In other words, the list of working
945      * copies that will take precedence over their original compilation units in the workspace.
946      * <p>
947      * Note that passing an empty working copy will be as if the original compilation
948      * unit had been deleted.
949      *
950      * @param workingCopies the working copies that take precedence over their original compilation units
951      * @param monitor the given progress monitor
952      * @return a type hierarchy for this type containing
953      * this type, all of its supertypes, and all its subtypes in the workspace
954      * @exception JavaModelException if this element does not exist or if an
955      * exception occurs while accessing its corresponding resource.
956      * @since 3.0
957      */

958     ITypeHierarchy newTypeHierarchy(ICompilationUnit[] workingCopies, IProgressMonitor monitor) throws JavaModelException;
959     
960     /**
961      * Creates and returns a type hierarchy for this type containing
962      * this type, all of its supertypes, and all its subtypes in the workspace,
963      * considering types in the given working copies. In other words, the list of working
964      * copies that will take precedence over their original compilation units in the workspace.
965      * <p>
966      * Note that passing an empty working copy will be as if the original compilation
967      * unit had been deleted.
968      *
969      * @param workingCopies the working copies that take precedence over their original compilation units
970      * @param monitor the given progress monitor
971      * @return a type hierarchy for this type containing
972      * this type, all of its supertypes, and all its subtypes in the workspace
973      * @exception JavaModelException if this element does not exist or if an
974      * exception occurs while accessing its corresponding resource.
975      * @since 2.0
976      * @deprecated Use {@link #newTypeHierarchy(ICompilationUnit[], IProgressMonitor)} instead
977      */

978     ITypeHierarchy newTypeHierarchy(IWorkingCopy[] workingCopies, IProgressMonitor monitor) throws JavaModelException;
979     
980     /**
981      * Creates and returns a type hierarchy for this type containing
982      * this type, all of its supertypes, and all its subtypes in the workspace,
983      * considering types in the working copies with the given owner.
984      * In other words, the owner's working copies will take
985      * precedence over their original compilation units in the workspace.
986      * <p>
987      * Note that if a working copy is empty, it will be as if the original compilation
988      * unit had been deleted.
989      * <p>
990      *
991      * @param owner the owner of working copies that take precedence over their original compilation units
992      * @param monitor the given progress monitor
993      * @return a type hierarchy for this type containing
994      * this type, all of its supertypes, and all its subtypes in the workspace
995      * @exception JavaModelException if this element does not exist or if an
996      * exception occurs while accessing its corresponding resource.
997      * @since 3.0
998      */

999     ITypeHierarchy newTypeHierarchy(WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException;
1000    
1001    /**
1002     * Resolves the given type name within the context of this type (depending on the type hierarchy
1003     * and its imports).
1004     * <p>
1005     * Multiple answers might be found in case there are ambiguous matches.
1006     * </p>
1007     * <p>
1008     * Each matching type name is decomposed as an array of two strings, the first denoting the package
1009     * name (dot-separated) and the second being the type name. The package name is empty if it is the
1010     * default package. The type name is the type qualified name using a '.' enclosing type separator.
1011     * </p>
1012     * <p>
1013     * Returns <code>null</code> if unable to find any matching type.
1014     * </p>
1015     *<p>
1016     * For example, resolution of <code>"Object"</code> would typically return
1017     * <code>{{"java.lang", "Object"}}</code>. Another resolution that returns
1018     * <code>{{"", "X.Inner"}}</code> represents the inner type Inner defined in type X in the
1019     * default package.
1020     * </p>
1021     *
1022     * @param typeName the given type name
1023     * @exception JavaModelException if code resolve could not be performed.
1024     * @return the resolved type names or <code>null</code> if unable to find any matching type
1025     * @see #getTypeQualifiedName(char)
1026     */

1027    String JavaDoc[][] resolveType(String JavaDoc typeName) throws JavaModelException;
1028
1029    /**
1030     * Resolves the given type name within the context of this type (depending on the type hierarchy
1031     * and its imports) and using the given owner's working copies, considering types in the
1032     * working copies with the given owner. In other words, the owner's working copies will take
1033     * precedence over their original compilation units in the workspace.
1034     * <p>
1035     * Note that if a working copy is empty, it will be as if the original compilation
1036     * unit had been deleted.
1037     * </p>
1038     * <p>Multiple answers might be found in case there are ambiguous matches.
1039     * </p>
1040     * <p>
1041     * Each matching type name is decomposed as an array of two strings, the first denoting the package
1042     * name (dot-separated) and the second being the type name. The package name is empty if it is the
1043     * default package. The type name is the type qualified name using a '.' enclosing type separator.
1044     * </p>
1045     * <p>
1046     * Returns <code>null</code> if unable to find any matching type.
1047     *</p>
1048     *<p>
1049     * For example, resolution of <code>"Object"</code> would typically return
1050     * <code>{{"java.lang", "Object"}}</code>. Another resolution that returns
1051     * <code>{{"", "X.Inner"}}</code> represents the inner type Inner defined in type X in the
1052     * default package.
1053     * </p>
1054     *
1055     * @param typeName the given type name
1056     * @param owner the owner of working copies that take precedence over their original compilation units
1057     * @exception JavaModelException if code resolve could not be performed.
1058     * @return the resolved type names or <code>null</code> if unable to find any matching type
1059     * @see #getTypeQualifiedName(char)
1060     * @since 3.0
1061     */

1062    String JavaDoc[][] resolveType(String JavaDoc typeName, WorkingCopyOwner owner) throws JavaModelException;
1063}
1064
Popular Tags