KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > core > dom > ITypeBinding


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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
12 package org.eclipse.jdt.core.dom;
13
14 /**
15  * A type binding represents fully-resolved type. There are a number of
16  * different kinds of type bindings:
17  * <ul>
18  * <li>a class - represents the class declaration;
19  * possibly with type parameters</li>
20  * <li>an interface - represents the class declaration;
21  * possibly with type parameters</li>
22  * <li>an enum - represents the enum declaration (enum types do not have
23  * have type parameters)</li>
24  * <li>an annotation - represents the annotation type declaration
25  * (annotation types do not have have type parameters)</li>
26  * <li>an array type - array types are referenced but not explicitly
27  * declared</li>
28  * <li>a primitive type (including the special return type <code>void</code>)
29  * - primitive types are referenced but not explicitly declared</li>
30  * <li>the null type - this is the special type of <code>null</code></li>
31  * <li>a type variable - represents the declaration of a type variable;
32  * possibly with type bounds</li>
33  * <li>a wildcard type - represents a wild card used as a type argument in
34  * a parameterized type reference</li>
35  * <li>a raw type - represents a legacy non-parameterized reference to
36  * a generic type</li>
37  * <li>a parameterized type - represents an copy of a type declaration
38  * with substitutions for its type parameters</li>
39  * <li>a capture - represents a capture binding</li>
40  * </ul>
41  * <p>
42  * This interface is not intended to be implemented by clients.
43  * </p>
44  *
45  * @see ITypeBinding#getDeclaredTypes()
46  * @since 2.0
47  */

48 public interface ITypeBinding extends IBinding {
49     
50     /**
51      * Returns the binary name of this type binding.
52      * The binary name of a class is defined in the Java Language
53      * Specification 2nd edition, section 13.1.
54      * <p>
55      * Note that in some cases, the binary name may be unavailable.
56      * This may happen, for example, for a local type declared in
57      * unreachable code.
58      * </p>
59      *
60      * @return the binary name of this type, or <code>null</code>
61      * if the binary name is unknown
62      * @since 3.0
63      */

64     public String JavaDoc getBinaryName();
65     
66     /**
67      * Returns the bound of this wildcard type if it has one.
68      * Returns <code>null</code> if this is not a wildcard type.
69      *
70      * @return the bound of this wildcard type, or <code>null</code> if none
71      * @see #isWildcardType()
72      * @see #isUpperbound()
73      * @since 3.1
74      */

75     public ITypeBinding getBound();
76
77     /**
78      * Returns a list of bindings representing all the fields declared
79      * as members of this class, interface, or enum type. These include public,
80      * protected, default (package-private) access, and private fields declared
81      * by the class, but excludes inherited fields. Synthetic fields may or
82      * may not be included.
83      * Returns an empty list if the class, interface, or enum declares no fields,
84      * and for other kinds of type bindings that do not directly have members.
85      * The resulting bindings are in no particular order.
86      *
87      * @return the list of bindings for the field members of this type,
88      * or the empty list if this type does not have field members
89      */

90     public IVariableBinding[] getDeclaredFields();
91     
92     /**
93      * Returns a list of method bindings representing all the methods and
94      * constructors declared for this class, interface, enum, or annotation
95      * type. These include public, protected, default (package-private) access,
96      * and private methods Synthetic methods and constructors may or may not be
97      * included. Returns an empty list if the class, interface, or enum,
98      * type declares no methods or constructors, if the annotation type declares
99      * no members, or if this type binding represents some other kind of type
100      * binding. The resulting bindings are in no particular order.
101      *
102      * @return the list of method bindings for the methods and constructors
103      * declared by this class, interface, enum type, or annotation type,
104      * or the empty list if this type does not declare any methods or constructors
105      */

106     public IMethodBinding[] getDeclaredMethods();
107     
108     /**
109      * Returns the declared modifiers for this class or interface binding
110      * as specified in the original source declaration of the class or
111      * interface. The result may not correspond to the modifiers in the compiled
112      * binary, since the compiler may change them (in particular, for inner
113      * class emulation). The <code>getModifiers</code> method should be used if
114      * the compiled modifiers are needed. Returns -1 if this type does not
115      * represent a class or interface.
116      *
117      * @return the bit-wise or of <code>Modifier</code> constants
118      * @see #getModifiers()
119      * @see Modifier
120      */

121     public int getDeclaredModifiers();
122     
123     /**
124      * Returns a list of type bindings representing all the types declared as
125      * members of this class, interface, or enum type.
126      * These include public, protected, default (package-private) access,
127      * and private classes, interfaces, enum types, and annotation types
128      * declared by the type, but excludes inherited types. Returns an empty
129      * list if the type declares no type members, or if this type
130      * binding represents an array type, a primitive type, a type variable,
131      * a wildcard type, a capture, or the null type.
132      * The resulting bindings are in no particular order.
133      *
134      * @return the list of type bindings for the member types of this type,
135      * or the empty list if this type does not have member types
136      */

137     public ITypeBinding[] getDeclaredTypes();
138     
139     /**
140      * Returns the type binding representing the class, interface, or enum
141      * that declares this binding.
142      * <p>
143      * The declaring class of a member class, interface, enum, annotation
144      * type is the class, interface, or enum type of which it is a member.
145      * The declaring class of a local class or interface (including anonymous
146      * classes) is the innermost class or interface containing the expression
147      * or statement in which this type is declared.
148      * </p>
149      * <p>The declaring class of a type variable is the class in which the type
150      * variable is declared if it is declared on a type. It returns
151      * <code>null</code> otherwise.
152      * </p>
153      * <p>The declaring class of a capture binding is the innermost class or
154      * interface containing the expression or statement in which this capture is
155      * declared.
156      * </p>
157      * <p>Array types, primitive types, the null type, top-level types,
158      * wildcard types have no declaring class.
159      * </p>
160      *
161      * @return the binding of the type that declares this type, or
162      * <code>null</code> if none
163      */

164     public ITypeBinding getDeclaringClass();
165     
166     /**
167      * Returns the method binding representing the method that declares this binding
168      * of a local type or type variable.
169      * <p>
170      * The declaring method of a local class or interface (including anonymous
171      * classes) is the innermost method containing the expression or statement in
172      * which this type is declared. Returns <code>null</code> if the type
173      * is declared in an initializer.
174      * </p>
175      * <p>
176      * The declaring method of a type variable is the method in which the type
177      * variable is declared if it is declared on a method. It
178      * returns <code>null</code> otherwise.
179      * </p>
180      * <p>Array types, primitive types, the null type, top-level types,
181      * wildcard types, and capture bindings have no declaring method.
182      * </p>
183      *
184      * @return the binding of the method that declares this type, or
185      * <code>null</code> if none
186      * @since 3.1
187      */

188     public IMethodBinding getDeclaringMethod();
189
190     /**
191      * Returns the dimensionality of this array type, or <code>0</code> if this
192      * is not an array type binding.
193      *
194      * @return the number of dimension of this array type binding, or
195      * <code>0</code> if this is not an array type
196      */

197     public int getDimensions();
198
199     /**
200      * Returns the binding representing the element type of this array type,
201      * or <code>null</code> if this is not an array type binding. The element
202      * type of an array is never itself an array type.
203      *
204      * @return the element type binding, or <code>null</code> if this is
205      * not an array type
206      */

207     public ITypeBinding getElementType();
208     
209     /**
210      * Returns the erasure of this type binding.
211      * <ul>
212      * <li>For parameterized types ({@link #isParameterizedType()})
213      * - returns the binding for the corresponding generic type.</li>
214      * <li>For raw types ({@link #isRawType()})
215      * - returns the binding for the corresponding generic type.</li>
216      * <li>For wildcard types ({@link #isWildcardType()})
217      * - returns the binding for the upper bound if it has one and
218      * java.lang.Object in other cases.</li>
219      * <li>For type variables ({@link #isTypeVariable()})
220      * - returns the binding for the erasure of the leftmost bound
221      * if it has bounds and java.lang.Object if it does not.</li>
222      * <li>For captures ({@link #isCapture()})
223      * - returns the binding for the erasure of the leftmost bound
224      * if it has bounds and java.lang.Object if it does not.</li>
225      * <li>For array types ({@link #isArray()}) - returns an array type of
226      * the same dimension ({@link #getDimensions()}) as this type
227      * binding for which the element type is the erasure of the element type
228      * ({@link #getElementType()}) of this type binding.</li>
229      * <li>For all other type bindings - returns the identical binding.</li>
230      * </ul>
231      *
232      * @return the erasure type binding
233      * @since 3.1
234      */

235     public ITypeBinding getErasure();
236     
237     /**
238      * Returns a list of type bindings representing the direct superinterfaces
239      * of the class, interface, or enum type represented by this type binding.
240      * <p>
241      * If this type binding represents a class or enum type, the return value
242      * is an array containing type bindings representing all interfaces
243      * directly implemented by this class. The number and order of the interface
244      * objects in the array corresponds to the number and order of the interface
245      * names in the <code>implements</code> clause of the original declaration
246      * of this type.
247      * </p>
248      * <p>
249      * If this type binding represents an interface, the array contains
250      * type bindings representing all interfaces directly extended by this
251      * interface. The number and order of the interface objects in the array
252      * corresponds to the number and order of the interface names in the
253      * <code>extends</code> clause of the original declaration of this interface.
254      * </p>
255      * <p>
256      * If the class or enum implements no interfaces, or the interface extends
257      * no interfaces, or if this type binding represents an array type, a
258      * primitive type, the null type, a type variable, an annotation type,
259      * a wildcard type, or a capture binding, this method returns an array of
260      * length 0.
261      * </p>
262      *
263      * @return the list of type bindings for the interfaces extended by this
264      * class or enum, or interfaces extended by this interface, or otherwise
265      * the empty list
266      */

267     public ITypeBinding[] getInterfaces();
268     
269     /**
270      * Returns the compiled modifiers for this class, interface, enum,
271      * or annotation type binding.
272      * The result may not correspond to the modifiers as declared in the
273      * original source, since the compiler may change them (in particular,
274      * for inner class emulation). The <code>getDeclaredModifiers</code> method
275      * should be used if the original modifiers are needed.
276      * Returns 0 if this type does not represent a class, interface, enum, or annotation
277      * type.
278      *
279      * @return the compiled modifiers for this type binding or 0
280      * if this type does not represent a class, interface, enum, or annotation
281      * type
282      * @see #getDeclaredModifiers()
283      */

284     public int getModifiers();
285     
286     /**
287      * Returns the unqualified name of the type represented by this binding
288      * if it has one.
289      * <ul>
290      * <li>For top-level types, member types, and local types,
291      * the name is the simple name of the type.
292      * Example: <code>"String"</code> or <code>"Collection"</code>.
293      * Note that the type parameters of a generic type are not included.</li>
294      * <li>For primitive types, the name is the keyword for the primitive type.
295      * Example: <code>"int"</code>.</li>
296      * <li>For the null type, the name is the string "null".</li>
297      * <li>For anonymous classes, which do not have a name,
298      * this method returns an empty string.</li>
299      * <li>For array types, the name is the unqualified name of the component
300      * type (as computed by this method) followed by "[]".
301      * Example: <code>"String[]"</code>. Note that the component type is never an
302      * an anonymous class.</li>
303      * <li>For type variables, the name is just the simple name of the
304      * type variable (type bounds are not included).
305      * Example: <code>"X"</code>.</li>
306      * <li>For type bindings that correspond to particular instances of a generic
307      * type arising from a parameterized type reference,
308      * the name is the unqualified name of the erasure type (as computed by this method)
309      * followed by the names (again, as computed by this method) of the type arguments
310      * surrounded by "&lt;&gt;" and separated by ",".
311      * Example: <code>"Collection&lt;String&gt;"</code>.
312      * </li>
313      * <li>For type bindings that correspond to particular instances of a generic
314      * type arising from a raw type reference, the name is the unqualified name of
315      * the erasure type (as computed by this method).
316      * Example: <code>"Collection"</code>.</li>
317      * <li>For wildcard types, the name is "?" optionally followed by
318      * a single space followed by the keyword "extends" or "super"
319      * followed a single space followed by the name of the bound (as computed by
320      * this method) when present.
321      * Example: <code>"? extends InputStream"</code>.
322      * </li>
323      * <li>Capture types do not have a name. For these types,
324      * and array types thereof, this method returns an empty string.</li>
325      * </ul>
326      *
327      * @return the unqualified name of the type represented by this binding,
328      * or the empty string if it has none
329      * @see #getQualifiedName()
330      */

331     public String JavaDoc getName();
332     
333     /**
334      * Returns the binding for the package in which this type is declared.
335      *
336      * @return the binding for the package in which this class, interface,
337      * enum, or annotation type is declared, or <code>null</code> if this type
338      * binding represents a primitive type, an array type, the null type,
339      * a type variable, a wildcard type, or a capture binding.
340      */

341     public IPackageBinding getPackage();
342     
343     /**
344      * Returns the fully qualified name of the type represented by this
345      * binding if it has one.
346      * <ul>
347      * <li>For top-level types, the fully qualified name is the simple name of
348      * the type preceded by the package name (or unqualified if in a default package)
349      * and a ".".
350      * Example: <code>"java.lang.String"</code> or <code>"java.util.Collection"</code>.
351      * Note that the type parameters of a generic type are not included.</li>
352      * <li>For members of top-level types, the fully qualified name is the
353      * simple name of the type preceded by the fully qualified name of the
354      * enclosing type (as computed by this method) and a ".".
355      * Example: <code>"java.io.ObjectInputStream.GetField"</code>.
356      * If the binding is for a member type that corresponds to a particular instance
357      * of a generic type arising from a parameterized type reference, the simple
358      * name of the type is followed by the fully qualified names of the type arguments
359      * (as computed by this method) surrounded by "&lt;&gt;" and separated by ",".
360      * Example: <code>"pkg.Outer.Inner&lt;java.lang.String&gt;"</code>.
361      * </li>
362      * <li>For primitive types, the fully qualified name is the keyword for
363      * the primitive type.
364      * Example: <code>"int"</code>.</li>
365      * <li>For the null type, the fully qualified name is the string
366      * "null".</li>
367      * <li>Local types (including anonymous classes) and members of local
368      * types do not have a fully qualified name. For these types, and array
369      * types thereof, this method returns an empty string.</li>
370      * <li>For array types whose component type has a fully qualified name,
371      * the fully qualified name is the fully qualified name of the component
372      * type (as computed by this method) followed by "[]".
373      * Example: <code>"java.lang.String[]"</code>.</li>
374      * <li>For type variables, the fully qualified name is just the name of the
375      * type variable (type bounds are not included).
376      * Example: <code>"X"</code>.</li>
377      * <li>For type bindings that correspond to particular instances of a generic
378      * type arising from a parameterized type reference,
379      * the fully qualified name is the fully qualified name of the erasure
380      * type followed by the fully qualified names of the type arguments surrounded by "&lt;&gt;" and separated by ",".
381      * Example: <code>"java.util.Collection&lt;java.lang.String&gt;"</code>.
382      * </li>
383      * <li>For type bindings that correspond to particular instances of a generic
384      * type arising from a raw type reference,
385      * the fully qualified name is the fully qualified name of the erasure type.
386      * Example: <code>"java.util.Collection"</code>. Note that the
387      * the type parameters are omitted.</li>
388      * <li>For wildcard types, the fully qualified name is "?" optionally followed by
389      * a single space followed by the keyword "extends" or "super"
390      * followed a single space followed by the fully qualified name of the bound
391      * (as computed by this method) when present.
392      * Example: <code>"? extends java.io.InputStream"</code>.
393      * </li>
394     * <li>Capture types do not have a fully qualified name. For these types,
395     * and array types thereof, this method returns an empty string.</li>
396      * </ul>
397      *
398      * @return the fully qualified name of the type represented by this
399      * binding, or the empty string if it has none
400      * @see #getName()
401      * @since 2.1
402      */

403     public String JavaDoc getQualifiedName();
404     
405     /**
406      * Returns the type binding for the superclass of the type represented
407      * by this class binding.
408      * <p>
409      * If this type binding represents any class other than the class
410      * <code>java.lang.Object</code>, then the type binding for the direct
411      * superclass of this class is returned. If this type binding represents
412      * the class <code>java.lang.Object</code>, then <code>null</code> is
413      * returned.
414      * <p>
415      * Loops that ascend the class hierarchy need a suitable termination test.
416      * Rather than test the superclass for <code>null</code>, it is more
417      * transparent to check whether the class is <code>Object</code>, by
418      * comparing whether the class binding is identical to
419      * <code>ast.resolveWellKnownType("java.lang.Object")</code>.
420      * </p>
421      * <p>
422      * If this type binding represents an interface, an array type, a
423      * primitive type, the null type, a type variable, an enum type,
424      * an annotation type, a wildcard type, or a capture binding,
425      * then <code>null</code> is returned.
426      * </p>
427      *
428      * @return the superclass of the class represented by this type binding,
429      * or <code>null</code> if none
430      * @see AST#resolveWellKnownType(String)
431      */

432     public ITypeBinding getSuperclass();
433     
434     /**
435      * Returns the type arguments of this generic type instance, or the
436      * empty list for other type bindings.
437      * <p>
438      * Note that type arguments only occur on a type binding that represents
439      * an instance of a generic type corresponding to a parameterized type
440      * reference (e.g., <code>Collection&lt;String&gt;</code>) or to a raw
441      * type reference (e.g., <code>Collection</code>) to a generic type.
442      * Do not confuse these with type parameters which only occur on the
443      * type binding corresponding directly to the declaration of the
444      * generic class or interface (e.g., <code>Collection&lt;T&gt;</code>).
445      * </p>
446      *
447      * @return the list of type bindings for the type arguments used to
448      * instantiate the corrresponding generic type, or otherwise the empty list
449      * @see #getTypeDeclaration()
450      * @see #isGenericType()
451      * @see #isParameterizedType()
452      * @see #isRawType()
453      * @since 3.1
454      */

455     public ITypeBinding[] getTypeArguments();
456     
457     /**
458      * Returns the declared type bounds of this type variable or capture. If the
459      * variable or the capture had no explicit bound, then it returns an empty list.
460      * <p>
461      * Note that per construction, it can only contain one class or array type,
462      * at most, and then it is located in first position.
463      * </p>
464      * Also note that array type bound may only occur in the case of a capture
465      * binding, e.g. <code>capture-of ? extends Object[]</code>
466      * </p>
467      *
468      * @return the list of type bindings for this type variable or capture,
469      * or otherwise the empty list
470      * @see #isCapture()
471      * @see #isTypeVariable()
472      * @since 3.1
473      */

474     public ITypeBinding[] getTypeBounds();
475     
476     /**
477      * Returns the binding for the type declaration corresponding to this type
478      * binding. For parameterized types ({@link #isParameterizedType()})
479      * and raw types ({@link #isRawType()}), this method returns the binding
480      * for the corresponding generic type. For other type bindings, this
481      * returns the same binding.
482      *
483      * @return the type binding
484      * @since 3.1
485      */

486     public ITypeBinding getTypeDeclaration();
487     
488     /**
489      * Returns the type parameters of this class or interface type binding.
490      * <p>
491      * Note that type parameters only occur on the binding of the
492      * declaring generic class or interface; e.g., <code>Collection&lt;T&gt;</code>.
493      * Type bindings corresponding to a raw or parameterized reference to a generic
494      * type do not carry type parameters (they instead have non-empty type arguments
495      * and non-trivial erasure).
496      * </p>
497      *
498      * @return the list of binding for the type variables for the type
499      * parameters of this type, or otherwise the empty list
500      * @see #isTypeVariable()
501      * @since 3.1
502      */

503     // TODO (jeem) - clarify whether binding for a generic type instance carries a copy of the generic type's type parameters as well as type arguments
504
public ITypeBinding[] getTypeParameters();
505     
506     /**
507      * Returns the corresponding wildcard binding of this capture binding.
508      * Returns <code>null</code> if this type bindings does not represent
509      * a capture binding.
510      *
511      * @return the corresponding wildcard binding for a capture
512      * binding, <code>null</code> otherwise
513      * @since 3.1
514      */

515     public ITypeBinding getWildcard();
516     
517     /**
518      * Returns whether this type binding represents an annotation type.
519      * <p>
520      * Note that an annotation type is always an interface.
521      * </p>
522      *
523      * @return <code>true</code> if this object represents an annotation type,
524      * and <code>false</code> otherwise
525      * @since 3.1
526      */

527     public boolean isAnnotation();
528     
529     /**
530      * Returns whether this type binding represents an anonymous class.
531      * <p>
532      * An anonymous class is a subspecies of local class, and therefore mutually
533      * exclusive with member types. Note that anonymous classes have no name
534      * (<code>getName</code> returns the empty string).
535      * </p>
536      *
537      * @return <code>true</code> if this type binding is for an anonymous class,
538      * and <code>false</code> otherwise
539      */

540     public boolean isAnonymous();
541     
542     /**
543      * Returns whether this type binding represents an array type.
544      *
545      * @return <code>true</code> if this type binding is for an array type,
546      * and <code>false</code> otherwise
547      * @see #getElementType()
548      * @see #getDimensions()
549      */

550     public boolean isArray();
551     
552     /**
553      * Returns whether this type is assigment compatible with the given type,
554      * as specified in section 5.2 of <em>The Java Language
555      * Specification, Third Edition</em> (JLS3).
556      *
557      * @param type the type to check compatibility against
558      * @return <code>true</code> if this type is assigment compatible with the
559      * given type, and <code>false</code> otherwise
560      * @since 3.1
561      */

562     public boolean isAssignmentCompatible(ITypeBinding type);
563     
564     /**
565      * Returns whether this type binding represents a capture binding.
566      * <p>
567      * Capture bindings result from capture conversion as specified
568      * in section 5.1.10 of <em>The Java Language Specification,
569      * Third Edition</em> (JLS3).
570      * </p>
571      * <p>
572      * A capture binding may have upper bounds and a lower bound.
573      * Upper bounds may be accessed using {@link #getTypeBounds()},
574      * the lower bound must be accessed indirectly through the associated
575      * wildcard {@link #getWildcard()} when it is a lower bound wildcard.
576      * </p>
577      * <p>
578      * Note that capture bindings are distinct from type variables
579      * (even though they are often depicted as synthetic type
580      * variables); as such, {@link #isTypeVariable()} answers
581      * <code>false</code> for capture bindings, and
582      * {@link #isCapture()} answers <code>false</code> for type variables.
583      * </p>
584      *
585      * @return <code>true</code> if this type binding is a capture,
586      * and <code>false</code> otherwise
587      * @see #getTypeBounds()
588      * @see #getWildcard()
589      * @since 3.1
590      */

591     public boolean isCapture();
592             
593     /**
594      * Returns whether this type is cast compatible with the given type,
595      * as specified in section 5.5 of <em>The Java Language
596      * Specification, Third Edition</em> (JLS3).
597      * <p>
598      * NOTE: The cast compatibility check performs backwards.
599      * When testing whether type B can be cast to type A, one would use:
600      * <code>A.isCastCompatible(B)</code>
601      * </p>
602      * @param type the type to check compatibility against
603      * @return <code>true</code> if this type is cast compatible with the
604      * given type, and <code>false</code> otherwise
605      * @since 3.1
606      */

607     public boolean isCastCompatible(ITypeBinding type);
608     
609     /**
610      * Returns whether this type binding represents a class type.
611      *
612      * @return <code>true</code> if this object represents a class,
613      * and <code>false</code> otherwise
614      */

615     public boolean isClass();
616
617     /**
618      * Returns whether this type binding represents an enum type.
619      *
620      * @return <code>true</code> if this object represents an enum type,
621      * and <code>false</code> otherwise
622      * @since 3.1
623      */

624     public boolean isEnum();
625
626     /**
627      * Returns whether this type binding originated in source code.
628      * Returns <code>false</code> for all primitive types, the null type,
629      * array types, and for all classes, interfaces, enums, annotation
630      * types, type variables, parameterized type references,
631      * raw type references, wildcard types, and capture bindings
632      * whose information came from a pre-compiled binary class file.
633      *
634      * @return <code>true</code> if the type is in source code,
635      * and <code>false</code> otherwise
636      */

637     public boolean isFromSource();
638     
639     /**
640      * Returns whether this type binding represents a declaration of
641      * a generic class or interface.
642      * <p>
643      * Note that type parameters only occur on the binding of the
644      * declaring generic class or interface; e.g., <code>Collection&lt;T&gt;</code>.
645      * Type bindings corresponding to a raw or parameterized reference to a generic
646      * type do not carry type parameters (they instead have non-empty type arguments
647      * and non-trivial erasure).
648      * This method is fully equivalent to <code>getTypeParameters().length &gt; 0)</code>.
649      * </p>
650      * <p>
651      * Note that {@link #isGenericType()},
652      * {@link #isParameterizedType()},
653      * and {@link #isRawType()} are mutually exclusive.
654      * </p>
655      *
656      * @return <code>true</code> if this type binding represents a
657      * declaration of a generic class or interface, and <code>false</code> otherwise
658      * @see #getTypeParameters()
659      * @since 3.1
660      */

661     public boolean isGenericType();
662         
663     /**
664      * Returns whether this type binding represents an interface type.
665      * <p>
666      * Note that an interface can also be an annotation type.
667      * </p>
668      *
669      * @return <code>true</code> if this object represents an interface,
670      * and <code>false</code> otherwise
671      */

672     public boolean isInterface();
673     
674     /**
675      * Returns whether this type binding represents a local class.
676      * <p>
677      * A local class is any nested class or enum type not declared as a member
678      * of another class or interface. A local class is a subspecies of nested
679      * type, and mutually exclusive with member types. Note that anonymous
680      * classes are a subspecies of local classes.
681      * </p>
682      * <p>
683      * Also note that interfaces and annotation types cannot be local.
684      * </p>
685      *
686      * @return <code>true</code> if this type binding is for a local class or
687      * enum type, and <code>false</code> otherwise
688      */

689     public boolean isLocal();
690     
691     /**
692      * Returns whether this type binding represents a member class or
693      * interface.
694      * <p>
695      * A member type is any type declared as a member of
696      * another type. A member type is a subspecies of nested
697      * type, and mutually exclusive with local types.
698      * </p>
699      *
700      * @return <code>true</code> if this type binding is for a member class,
701      * interface, enum, or annotation type, and <code>false</code> otherwise
702      */

703     public boolean isMember();
704     
705     /**
706      * Returns whether this type binding represents a nested class, interface,
707      * enum, or annotation type.
708      * <p>
709      * A nested type is any type whose declaration occurs within
710      * the body of another. The set of nested types is disjoint from the set of
711      * top-level types. Nested types further subdivide into member types, local
712      * types, and anonymous types.
713      * </p>
714      *
715      * @return <code>true</code> if this type binding is for a nested class,
716      * interface, enum, or annotation type, and <code>false</code> otherwise
717      */

718     public boolean isNested();
719
720     /**
721      * Returns whether this type binding represents the null type.
722      * <p>
723      * The null type is the type of a <code>NullLiteral</code> node.
724      * </p>
725      *
726      * @return <code>true</code> if this type binding is for the null type,
727      * and <code>false</code> otherwise
728      */

729     public boolean isNullType();
730
731     /**
732      * Returns whether this type binding represents an instance of
733      * a generic type corresponding to a parameterized type reference.
734      * <p>
735      * For example, an AST type like
736      * <code>Collection&lt;String&gt;</code> typically resolves to a
737      * type binding whose type argument is the type binding for the
738      * class <code>java.lang.String</code> and whose erasure is the type
739      * binding for the generic type <code>java.util.Collection</code>.
740      * </p>
741      * Note that {@link #isGenericType()},
742      * {@link #isParameterizedType()},
743      * and {@link #isRawType()} are mutually exclusive.
744      * </p>
745      *
746      * @return <code>true</code> if this type binding represents a
747      * an instance of a generic type corresponding to a parameterized
748      * type reference, and <code>false</code> otherwise
749      * @see #getTypeArguments()
750      * @see #getTypeDeclaration()
751      * @since 3.1
752      */

753     public boolean isParameterizedType();
754     
755     /**
756      * Returns whether this type binding represents a primitive type.
757      * <p>
758      * There are nine predefined type bindings to represent the eight primitive
759      * types and <code>void</code>. These have the same names as the primitive
760      * types that they represent, namely boolean, byte, char, short, int,
761      * long, float, and double, and void.
762      * </p>
763      *
764      * @return <code>true</code> if this type binding is for a primitive type,
765      * and <code>false</code> otherwise
766      */

767     public boolean isPrimitive();
768     
769     /**
770      * Returns whether this type binding represents an instance of
771      * a generic type corresponding to a raw type reference.
772      * <p>
773      * For example, an AST type like
774      * <code>Collection</code> typically resolves to a
775      * type binding whose type argument is the type binding for
776      * the class <code>java.lang.Object</code> (the
777      * default bound for the single type parameter of
778      * <code>java.util.Collection</code>) and whose erasure is the
779      * type binding for the generic type
780      * <code>java.util.Collection</code>.
781      * </p>
782      * <p>
783      * Note that {@link #isGenericType()},
784      * {@link #isParameterizedType()},
785      * and {@link #isRawType()} are mutually exclusive.
786      * </p>
787      *
788      * @return <code>true</code> if this type binding represents a
789      * an instance of a generic type corresponding to a raw
790      * type reference, and <code>false</code> otherwise
791      * @see #getTypeDeclaration()
792      * @see #getTypeArguments()
793      * @since 3.1
794      */

795     public boolean isRawType();
796
797     /**
798      * Returns whether this type is subtype compatible with the given type,
799      * as specified in section 4.10 of <em>The Java Language
800      * Specification, Third Edition</em> (JLS3).
801      *
802      * @param type the type to check compatibility against
803      * @return <code>true</code> if this type is subtype compatible with the
804      * given type, and <code>false</code> otherwise
805      * @since 3.1
806      */

807     public boolean isSubTypeCompatible(ITypeBinding type);
808     
809     /**
810      * Returns whether this type binding represents a top-level class,
811      * interface, enum, or annotation type.
812      * <p>
813      * A top-level type is any type whose declaration does not occur within the
814      * body of another type declaration. The set of top level types is disjoint
815      * from the set of nested types.
816      * </p>
817      *
818      * @return <code>true</code> if this type binding is for a top-level class,
819      * interface, enum, or annotation type, and <code>false</code> otherwise
820      */

821     public boolean isTopLevel();
822     
823     /**
824      * Returns whether this type binding represents a type variable.
825      * Type variables bindings carry the type variable's bounds.
826      * <p>
827      * Note that type variables are distinct from capture bindings
828      * (even though capture bindings are often depicted as synthetic
829      * type variables); as such, {@link #isTypeVariable()} answers
830      * <code>false</code> for capture bindings, and
831      * {@link #isCapture()} answers <code>false</code> for type variables.
832      * </p>
833      *
834      * @return <code>true</code> if this type binding is for a type variable,
835      * and <code>false</code> otherwise
836      * @see #getName()
837      * @see #getTypeBounds()
838      * @since 3.1
839      */

840     public boolean isTypeVariable();
841     
842     /**
843      * Returns whether this wildcard type is an upper bound
844      * ("extends") as opposed to a lower bound ("super").
845      * Note that this property is only relevant for wildcards
846      * that have a bound.
847      *
848      * @return <code>true</code> if this wildcard type has a bound that is
849      * an upper bound, and <code>false</code> in all other cases
850      * @see #isWildcardType()
851      * @see #getBound()
852      * @since 3.1
853      */

854     public boolean isUpperbound();
855     
856     /**
857      * Returns whether this type binding represents a wildcard type. A wildcard
858      * type occus only as an argument to a parameterized type reference.
859      * <p>
860      * For example, a AST type like
861      * <code>Collection&lt;? extends Object&gt;</code> typically resolves to a
862      * parameterized type binding whose type argument is a wildcard type
863      * with upper type bound <code>java.util.Object/code>.
864      * </p>
865      *
866      * @return <code>true</code> if this object represents a wildcard type,
867      * and <code>false</code> otherwise
868      * @since 3.1
869      * @see #getBound()
870      * @see #isUpperbound()
871      */

872     public boolean isWildcardType();
873 }
874
Popular Tags