Lines 36-41
Link Here
|
36 |
* a generic type</li> |
36 |
* a generic type</li> |
37 |
* <li>a parameterized type - represents an copy of a type declaration |
37 |
* <li>a parameterized type - represents an copy of a type declaration |
38 |
* with substitutions for its type parameters</li> |
38 |
* with substitutions for its type parameters</li> |
|
|
39 |
* <li>a capture - represents a capture binding</li> |
39 |
* </ul> |
40 |
* </ul> |
40 |
* <p> |
41 |
* <p> |
41 |
* This interface is not intended to be implemented by clients. |
42 |
* This interface is not intended to be implemented by clients. |
Lines 63-295
Link Here
|
63 |
public String getBinaryName(); |
64 |
public String getBinaryName(); |
64 |
|
65 |
|
65 |
/** |
66 |
/** |
66 |
* Returns whether this type binding represents a primitive type. |
67 |
* Returns the bound of this wildcard type if it has one. |
67 |
* <p> |
68 |
* Returns <code>null</code> if this is not a wildcard type. |
68 |
* There are nine predefined type bindings to represent the eight primitive |
|
|
69 |
* types and <code>void</code>. These have the same names as the primitive |
70 |
* types that they represent, namely boolean, byte, char, short, int, |
71 |
* long, float, and double, and void. |
72 |
* </p> |
73 |
* |
69 |
* |
74 |
* @return <code>true</code> if this type binding is for a primitive type, |
70 |
* @return the bound of this wildcard type, or <code>null</code> if none |
75 |
* and <code>false</code> otherwise |
71 |
* @see #isWildcardType() |
|
|
72 |
* @see #isUpperbound() |
73 |
* @since 3.1 |
76 |
*/ |
74 |
*/ |
77 |
public boolean isPrimitive(); |
75 |
public ITypeBinding getBound(); |
78 |
|
76 |
|
79 |
/** |
77 |
/** |
80 |
* Returns whether this type binding represents the null type. |
78 |
* Returns a list of bindings representing all the fields declared |
81 |
* <p> |
79 |
* as members of this class, interface, or enum type. These include public, |
82 |
* The null type is the type of a <code>NullLiteral</code> node. |
80 |
* protected, default (package-private) access, and private fields declared |
83 |
* </p> |
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. |
84 |
* |
86 |
* |
85 |
* @return <code>true</code> if this type binding is for the null type, |
87 |
* @return the list of bindings for the field members of this type, |
86 |
* and <code>false</code> otherwise |
88 |
* or the empty list if this type does not have field members |
87 |
*/ |
|
|
88 |
public boolean isNullType(); |
89 |
|
90 |
/** |
91 |
* Returns whether this type binding represents an array type. |
92 |
* |
93 |
* @return <code>true</code> if this type binding is for an array type, |
94 |
* and <code>false</code> otherwise |
95 |
* @see #getElementType() |
96 |
* @see #getDimensions() |
97 |
*/ |
89 |
*/ |
98 |
public boolean isArray(); |
90 |
public IVariableBinding[] getDeclaredFields(); |
99 |
|
91 |
|
100 |
/** |
92 |
/** |
101 |
* Returns the binding representing the element type of this array type, |
93 |
* Returns a list of method bindings representing all the methods and |
102 |
* or <code>null</code> if this is not an array type binding. The element |
94 |
* constructors declared for this class, interface, enum, or annotation |
103 |
* type of an array is never itself an array type. |
95 |
* type. These include public, protected, default (package-private) access, |
104 |
* |
96 |
* and private methods Synthetic methods and constructors may or may not be |
105 |
* @return the element type binding, or <code>null</code> if this is |
97 |
* included. Returns an empty list if the class, interface, or enum, |
106 |
* not an array type |
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 |
107 |
*/ |
105 |
*/ |
108 |
public ITypeBinding getElementType(); |
106 |
public IMethodBinding[] getDeclaredMethods(); |
109 |
|
107 |
|
110 |
/** |
108 |
/** |
111 |
* Returns the dimensionality of this array type, or <code>0</code> if this |
109 |
* Returns the declared modifiers for this class or interface binding |
112 |
* is not an array type 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. |
113 |
* |
116 |
* |
114 |
* @return the number of dimension of this array type binding, or |
117 |
* @return the bit-wise or of <code>Modifier</code> constants |
115 |
* <code>0</code> if this is not an array type |
118 |
* @see #getModifiers() |
116 |
*/ |
119 |
* @see Modifier |
117 |
public int getDimensions(); |
|
|
118 |
|
119 |
/** |
120 |
* Returns whether this type is assigment compatible with the given type, |
121 |
* as specified in section 5.2 of <em>The Java Language |
122 |
* Specification, Second Edition</em> (JLS2). |
123 |
* |
124 |
* @param type the type to check compatibility against |
125 |
* @return <code>true</code> if this type is assigment compatible with the |
126 |
* given type, and <code>false</code> otherwise |
127 |
* @since 3.1 |
128 |
*/ |
120 |
*/ |
129 |
public boolean isAssignmentCompatible(ITypeBinding type); |
121 |
public int getDeclaredModifiers(); |
130 |
|
122 |
|
131 |
/** |
123 |
/** |
132 |
* Returns whether this type is cast compatible with the given type, |
124 |
* Returns a list of type bindings representing all the types declared as |
133 |
* as specified in section 5.5 of <em>The Java Language |
125 |
* members of this class, interface, or enum type. |
134 |
* Specification, Second Edition</em> (JLS2). |
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. |
135 |
* |
133 |
* |
136 |
* @param type the type to check compatibility against |
134 |
* @return the list of type bindings for the member types of this type, |
137 |
* @return <code>true</code> if this type is cast compatible with the |
135 |
* or the empty list if this type does not have member types |
138 |
* given type, and <code>false</code> otherwise |
|
|
139 |
* @since 3.1 |
140 |
*/ |
141 |
public boolean isCastCompatible(ITypeBinding type); |
142 |
|
143 |
/** |
144 |
* Returns whether this type binding represents a class type. |
145 |
* |
146 |
* @return <code>true</code> if this object represents a class, |
147 |
* and <code>false</code> otherwise |
148 |
*/ |
136 |
*/ |
149 |
public boolean isClass(); |
137 |
public ITypeBinding[] getDeclaredTypes(); |
150 |
|
138 |
|
151 |
/** |
139 |
/** |
152 |
* Returns whether this type binding represents an interface type. |
140 |
* Returns the type binding representing the class, interface, or enum |
|
|
141 |
* that declares this binding. |
153 |
* <p> |
142 |
* <p> |
154 |
* Note that an interface can also be an annotation type. |
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. |
155 |
* </p> |
148 |
* </p> |
156 |
* |
149 |
* <p>The declaring class of a type variable is the class in which the type variable |
157 |
* @return <code>true</code> if this object represents an interface, |
150 |
* is declared if it is declared on a type. It returns <code>null</code> otherwise. |
158 |
* and <code>false</code> otherwise |
|
|
159 |
*/ |
160 |
public boolean isInterface(); |
161 |
|
162 |
/** |
163 |
* Returns whether this type binding represents an enum type. |
164 |
* |
165 |
* @return <code>true</code> if this object represents an enum type, |
166 |
* and <code>false</code> otherwise |
167 |
* @since 3.1 |
168 |
*/ |
169 |
public boolean isEnum(); |
170 |
|
171 |
/** |
172 |
* Returns whether this type binding represents an annotation type. |
173 |
* <p> |
174 |
* Note that an annotation type is always an interface. |
175 |
* </p> |
151 |
* </p> |
176 |
* |
152 |
* <p>Array types, primitive types, the null type, top-level types, |
177 |
* @return <code>true</code> if this object represents an annotation type, |
153 |
* wildcard types, and capture bindings have no declaring class. |
178 |
* and <code>false</code> otherwise |
154 |
* </p> |
179 |
* @since 3.1 |
155 |
* |
180 |
*/ |
156 |
* @return the binding of the type that declares this type, or |
181 |
public boolean isAnnotation(); |
157 |
* <code>null</code> if none |
182 |
|
|
|
183 |
/** |
184 |
* Returns the type parameters of this class or interface type binding. |
185 |
* <p> |
186 |
* Note that type parameters only occur on the binding of the |
187 |
* declaring generic class or interface; e.g., <code>Collection<T></code>. |
188 |
* Type bindings corresponding to a raw or parameterized reference to a generic |
189 |
* type do not carry type parameters (they instead have non-empty type arguments |
190 |
* and non-trivial erasure). |
191 |
* </p> |
192 |
* |
193 |
* @return the list of binding for the type variables for the type |
194 |
* parameters of this type, or otherwise the empty list |
195 |
* @see #isTypeVariable() |
196 |
* @since 3.1 |
197 |
*/ |
158 |
*/ |
198 |
// 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 |
159 |
public ITypeBinding getDeclaringClass(); |
199 |
public ITypeBinding[] getTypeParameters(); |
|
|
200 |
|
160 |
|
201 |
/** |
161 |
/** |
202 |
* Returns whether this type binding represents a declaration of |
162 |
* Returns the method binding representing the method that declares this binding |
203 |
* a generic class or interface. |
163 |
* of a local type or type variable. |
204 |
* <p> |
164 |
* <p> |
205 |
* Note that type parameters only occur on the binding of the |
165 |
* The declaring method of a local class or interface (including anonymous |
206 |
* declaring generic class or interface; e.g., <code>Collection<T></code>. |
166 |
* classes) is the innermost method containing the expression or statement in |
207 |
* Type bindings corresponding to a raw or parameterized reference to a generic |
167 |
* which this type is declared. Returns <code>null</code> if the type |
208 |
* type do not carry type parameters (they instead have non-empty type arguments |
168 |
* is declared in an initializer. |
209 |
* and non-trivial erasure). |
|
|
210 |
* This method is fully equivalent to <code>getTypeParameters().length > 0)</code>. |
211 |
* </p> |
169 |
* </p> |
212 |
* <p> |
170 |
* <p> |
213 |
* Note that {@link #isGenericType()}, |
171 |
* The declaring method of a type variable is the method in which the type |
214 |
* {@link #isParameterizedType()}, |
172 |
* variable is declared if it is declared on a method. It |
215 |
* and {@link #isRawType()} are mutually exclusive. |
173 |
* returns <code>null</code> otherwise. |
|
|
174 |
* </p> |
175 |
* <p>Array types, primitive types, the null type, top-level types, |
176 |
* wildcard types, and capture bindings have no declaring method. |
216 |
* </p> |
177 |
* </p> |
217 |
* |
|
|
218 |
* @return <code>true</code> if this type binding represents a |
219 |
* declaration of a generic class or interface, and <code>false</code> otherwise |
220 |
* @see #getTypeParameters() |
221 |
* @since 3.1 |
222 |
*/ |
223 |
public boolean isGenericType(); |
224 |
|
225 |
/** |
226 |
* Returns whether this type binding represents a type variable. |
227 |
* Type variables bindings carry the type variable's bounds. |
228 |
* |
178 |
* |
229 |
* @return <code>true</code> if this type binding is for a type variable, |
179 |
* @return the binding of the method that declares this type, or |
230 |
* and <code>false</code> otherwise |
180 |
* <code>null</code> if none |
231 |
* @see #getName() |
|
|
232 |
* @see #getTypeBounds() |
233 |
* @since 3.1 |
234 |
*/ |
235 |
public boolean isTypeVariable(); |
236 |
|
237 |
/** |
238 |
* Returns the type bounds of this type variable. |
239 |
* |
240 |
* @return the list of type bindings for this type variable, or otherwise |
241 |
* the empty list |
242 |
* @see #isTypeVariable() |
243 |
* @since 3.1 |
244 |
*/ |
181 |
*/ |
245 |
public ITypeBinding[] getTypeBounds(); |
182 |
public IMethodBinding getDeclaringMethod(); |
246 |
|
183 |
|
247 |
/** |
184 |
/** |
248 |
* Returns whether this type binding represents an instance of |
185 |
* Returns the dimensionality of this array type, or <code>0</code> if this |
249 |
* a generic type corresponding to a parameterized type reference. |
186 |
* is not an array type binding. |
250 |
* <p> |
|
|
251 |
* For example, an AST type like |
252 |
* <code>Collection<String></code> typically resolves to a |
253 |
* type binding whose type argument is the type binding for the |
254 |
* class <code>java.lang.String</code> and whose erasure is the type |
255 |
* binding for the generic type <code>java.util.Collection</code>. |
256 |
* </p> |
257 |
* Note that {@link #isGenericType()}, |
258 |
* {@link #isParameterizedType()}, |
259 |
* and {@link #isRawType()} are mutually exclusive. |
260 |
* </p> |
261 |
* |
187 |
* |
262 |
* @return <code>true</code> if this type binding represents a |
188 |
* @return the number of dimension of this array type binding, or |
263 |
* an instance of a generic type corresponding to a parameterized |
189 |
* <code>0</code> if this is not an array type |
264 |
* type reference, and <code>false</code> otherwise |
|
|
265 |
* @see #getTypeArguments() |
266 |
* @see #getTypeDeclaration() |
267 |
* @since 3.1 |
268 |
*/ |
190 |
*/ |
269 |
public boolean isParameterizedType(); |
191 |
public int getDimensions(); |
270 |
|
192 |
|
271 |
/** |
193 |
/** |
272 |
* Returns the type arguments of this generic type instance, or the |
194 |
* Returns the binding representing the element type of this array type, |
273 |
* empty list for other type bindings. |
195 |
* or <code>null</code> if this is not an array type binding. The element |
274 |
* <p> |
196 |
* type of an array is never itself an array type. |
275 |
* Note that type arguments only occur on a type binding that represents |
|
|
276 |
* an instance of a generic type corresponding to a parameterized type |
277 |
* reference (e.g., <code>Collection<String></code>) or to a raw |
278 |
* type reference (e.g., <code>Collection</code>) to a generic type. |
279 |
* Do not confuse these with type parameters which only occur on the |
280 |
* type binding corresponding directly to the declaration of the |
281 |
* generic class or interface (e.g., <code>Collection<T></code>). |
282 |
* </p> |
283 |
* |
197 |
* |
284 |
* @return the list of type bindings for the type arguments used to |
198 |
* @return the element type binding, or <code>null</code> if this is |
285 |
* instantiate the corrresponding generic type, or otherwise the empty list |
199 |
* not an array type |
286 |
* @see #getTypeDeclaration() |
|
|
287 |
* @see #isGenericType() |
288 |
* @see #isParameterizedType() |
289 |
* @see #isRawType() |
290 |
* @since 3.1 |
291 |
*/ |
200 |
*/ |
292 |
public ITypeBinding[] getTypeArguments(); |
201 |
public ITypeBinding getElementType(); |
293 |
|
202 |
|
294 |
/** |
203 |
/** |
295 |
* Returns the erasure of this type binding. |
204 |
* Returns the erasure of this type binding. |
Lines 300-310
Link Here
|
300 |
* - returns the binding for the corresponding generic type.</li> |
209 |
* - returns the binding for the corresponding generic type.</li> |
301 |
* <li>For wildcard types ({@link #isWildcardType()}) |
210 |
* <li>For wildcard types ({@link #isWildcardType()}) |
302 |
* - returns the binding for the upper bound if it has one and |
211 |
* - returns the binding for the upper bound if it has one and |
303 |
* java.lang.Object in other cases. |
212 |
* java.lang.Object in other cases.</li> |
304 |
* </li> |
|
|
305 |
* <li>For type variables ({@link #isTypeVariable()}) |
213 |
* <li>For type variables ({@link #isTypeVariable()}) |
306 |
* - returns the binding for the erasure of the leftmost bound |
214 |
* - returns the binding for the erasure of the leftmost bound |
307 |
* if it has bounds and java.lang.Object if it does not.</li> |
215 |
* if it has bounds and java.lang.Object if it does not.</li> |
|
|
216 |
* <li>For captures ({@link #isCapture()}) |
217 |
* - returns the binding for the erasure of the leftmost bound |
218 |
* if it has bounds and java.lang.Object if it does not.</li> |
308 |
* <li>For all other type bindings - returns the identical binding.</li> |
219 |
* <li>For all other type bindings - returns the identical binding.</li> |
309 |
* </ul> |
220 |
* </ul> |
310 |
* |
221 |
* |
Lines 314-400
Link Here
|
314 |
public ITypeBinding getErasure(); |
225 |
public ITypeBinding getErasure(); |
315 |
|
226 |
|
316 |
/** |
227 |
/** |
317 |
* Returns the binding for the type declaration corresponding to this type |
228 |
* Returns a list of type bindings representing the direct superinterfaces |
318 |
* binding. For parameterized types ({@link #isParameterizedType()}) |
229 |
* of the class, interface, or enum type represented by this type binding. |
319 |
* and raw types ({@link #isRawType()}), this method returns the binding |
|
|
320 |
* for the corresponding generic type. For other type bindings, this |
321 |
* returns the same binding. |
322 |
* |
323 |
* @return the type binding |
324 |
* @since 3.1 |
325 |
*/ |
326 |
public ITypeBinding getTypeDeclaration(); |
327 |
|
328 |
/** |
329 |
* Returns whether this type binding represents an instance of |
330 |
* a generic type corresponding to a raw type reference. |
331 |
* <p> |
230 |
* <p> |
332 |
* For example, an AST type like |
231 |
* If this type binding represents a class or enum type, the return value |
333 |
* <code>Collection</code> typically resolves to a |
232 |
* is an array containing type bindings representing all interfaces |
334 |
* type binding whose type argument is the type binding for |
233 |
* directly implemented by this class. The number and order of the interface |
335 |
* the class <code>java.lang.Object</code> (the |
234 |
* objects in the array corresponds to the number and order of the interface |
336 |
* default bound for the single type parameter of |
235 |
* names in the <code>implements</code> clause of the original declaration |
337 |
* <code>java.util.Collection</code>) and whose erasure is the |
236 |
* of this type. |
338 |
* type binding for the generic type |
|
|
339 |
* <code>java.util.Collection</code>. |
340 |
* </p> |
237 |
* </p> |
341 |
* <p> |
238 |
* <p> |
342 |
* Note that {@link #isGenericType()}, |
239 |
* If this type binding represents an interface, the array contains |
343 |
* {@link #isParameterizedType()}, |
240 |
* type bindings representing all interfaces directly extended by this |
344 |
* and {@link #isRawType()} are mutually exclusive. |
241 |
* interface. The number and order of the interface objects in the array |
|
|
242 |
* corresponds to the number and order of the interface names in the |
243 |
* <code>extends</code> clause of the original declaration of this interface. |
345 |
* </p> |
244 |
* </p> |
346 |
* |
|
|
347 |
* @return <code>true</code> if this type binding represents a |
348 |
* an instance of a generic type corresponding to a raw |
349 |
* type reference, and <code>false</code> otherwise |
350 |
* @see #getTypeDeclaration() |
351 |
* @see #getTypeArguments() |
352 |
* @since 3.1 |
353 |
*/ |
354 |
public boolean isRawType(); |
355 |
|
356 |
/** |
357 |
* Returns whether this type binding represents a wildcard type. A wildcard |
358 |
* type occus only as an argument to a parameterized type reference. |
359 |
* <p> |
245 |
* <p> |
360 |
* For example, a AST type like |
246 |
* If the class or enum implements no interfaces, or the interface extends |
361 |
* <code>Collection<? extends Object></code> typically resolves to a |
247 |
* no interfaces, or if this type binding represents an array type, a |
362 |
* parameterized type binding whose type argument is a wildcard type |
248 |
* primitive type, the null type, a type variable, an annotation type, |
363 |
* with upper type bound <code>java.util.Object/code>. |
249 |
* a wildcard type, or a capture binding, this method returns an array of |
|
|
250 |
* length 0. |
364 |
* </p> |
251 |
* </p> |
365 |
* |
252 |
* |
366 |
* @return <code>true</code> if this object represents a wildcard type, |
253 |
* @return the list of type bindings for the interfaces extended by this |
367 |
* and <code>false</code> otherwise |
254 |
* class or enum, or interfaces extended by this interface, or otherwise |
368 |
* @since 3.1 |
255 |
* the empty list |
369 |
* @see #getBound() |
|
|
370 |
* @see #isUpperbound() |
371 |
*/ |
256 |
*/ |
372 |
public boolean isWildcardType(); |
257 |
public ITypeBinding[] getInterfaces(); |
373 |
|
258 |
|
374 |
/** |
259 |
/** |
375 |
* Returns the bound of this wildcard type if it has one. |
260 |
* Returns the compiled modifiers for this class, interface, enum, |
376 |
* Returns <code>null</code> if this is not a wildcard type. |
261 |
* or annotation type binding. |
|
|
262 |
* The result may not correspond to the modifiers as declared in the |
263 |
* original source, since the compiler may change them (in particular, |
264 |
* for inner class emulation). The <code>getDeclaredModifiers</code> method |
265 |
* should be used if the original modifiers are needed. |
266 |
* Returns 0 if this type does not represent a class, interface, enum, or annotation |
267 |
* type. |
377 |
* |
268 |
* |
378 |
* @return the bound of this wildcard type, or <code>null</code> if none |
269 |
* @return the compiled modifiers for this type binding or 0 |
379 |
* @see #isWildcardType() |
270 |
* if this type does not represent a class, interface, enum, or annotation |
380 |
* @see #isUpperbound() |
271 |
* type |
381 |
* @since 3.1 |
272 |
* @see #getDeclaredModifiers() |
382 |
*/ |
|
|
383 |
public ITypeBinding getBound(); |
384 |
|
385 |
/** |
386 |
* Returns whether this wildcard type is an upper bound |
387 |
* ("extends") as opposed to a lower bound ("super"). |
388 |
* Note that this property is only relevant for wildcards |
389 |
* that have a bound. |
390 |
* |
391 |
* @return <code>true</code> if this wildcard type has a bound that is |
392 |
* an upper bound, and <code>false</code> in all other cases |
393 |
* @see #isWildcardType() |
394 |
* @see #getBound() |
395 |
* @since 3.1 |
396 |
*/ |
273 |
*/ |
397 |
public boolean isUpperbound(); |
274 |
public int getModifiers(); |
398 |
|
275 |
|
399 |
/** |
276 |
/** |
400 |
* Returns the unqualified name of the type represented by this binding |
277 |
* Returns the unqualified name of the type represented by this binding |
Lines 433-438
Link Here
|
433 |
* this method) when present. |
310 |
* this method) when present. |
434 |
* Example: <code>"? extends InputStream"</code>. |
311 |
* Example: <code>"? extends InputStream"</code>. |
435 |
* </li> |
312 |
* </li> |
|
|
313 |
* <li>Capture types do not have a name. For these types, |
314 |
* and array types thereof, this method returns an empty string.</li> |
436 |
* </ul> |
315 |
* </ul> |
437 |
* |
316 |
* |
438 |
* @return the unqualified name of the type represented by this binding, |
317 |
* @return the unqualified name of the type represented by this binding, |
Lines 440-501
Link Here
|
440 |
* @see #getQualifiedName() |
319 |
* @see #getQualifiedName() |
441 |
*/ |
320 |
*/ |
442 |
public String getName(); |
321 |
public String getName(); |
443 |
|
322 |
|
444 |
/** |
323 |
/** |
445 |
* Returns the binding for the package in which this type is declared. |
324 |
* Returns the binding for the package in which this type is declared. |
446 |
* |
325 |
* |
447 |
* @return the binding for the package in which this class, interface, |
326 |
* @return the binding for the package in which this class, interface, |
448 |
* enum, or annotation type is declared, or <code>null</code> if this type |
327 |
* enum, or annotation type is declared, or <code>null</code> if this type |
449 |
* binding represents a primitive type, an array type, the null type, |
328 |
* binding represents a primitive type, an array type, the null type, |
450 |
* a type variable, or a wildcard type. |
329 |
* a type variable, a wildcard type, or a capture binding. |
451 |
*/ |
330 |
*/ |
452 |
public IPackageBinding getPackage(); |
331 |
public IPackageBinding getPackage(); |
453 |
|
332 |
|
454 |
/** |
333 |
/** |
455 |
* Returns the type binding representing the class, interface, or enum |
334 |
* Returns the fully qualified name of the type represented by this |
456 |
* that declares this binding. |
335 |
* binding if it has one. |
457 |
* <p> |
336 |
* <ul> |
458 |
* The declaring class of a member class, interface, enum, annotation |
337 |
* <li>For top-level types, the fully qualified name is the simple name of |
459 |
* type is the class, interface, or enum type of which it is a member. |
338 |
* the type preceded by the package name (or unqualified if in a default package) |
460 |
* The declaring class of a local class or interface (including anonymous |
339 |
* and a ".". |
461 |
* classes) is the innermost class or interface containing the expression |
340 |
* Example: <code>"java.lang.String"</code> or <code>"java.util.Collection"</code>. |
462 |
* or statement in which this type is declared. |
341 |
* Note that the type parameters of a generic type are not included.</li> |
463 |
* </p> |
342 |
* <li>For members of top-level types, the fully qualified name is the |
464 |
* <p>The declaring class of a type variable is the class in which the type variable |
343 |
* simple name of the type preceded by the fully qualified name of the |
465 |
* is declared if it is declared on a type. It returns <code>null</code> otherwise. |
344 |
* enclosing type (as computed by this method) and a ".". |
466 |
* </p> |
345 |
* Example: <code>"java.io.ObjectInputStream.GetField"</code>. |
467 |
* <p>Array types, primitive types, the null type, top-level types, |
346 |
* If the binding is for a member type that corresponds to a particular instance |
468 |
* and wildcard types have no declaring class. |
347 |
* of a generic type arising from a parameterized type reference, the simple |
469 |
* </p> |
348 |
* name of the type is followed by the fully qualified names of the type arguments |
470 |
* |
349 |
* (as computed by this method) surrounded by "<>" and separated by ",". |
471 |
* @return the binding of the type that declares this type, or |
350 |
* Example: <code>"pkg.Outer.Inner<java.lang.String>"</code>. |
472 |
* <code>null</code> if none |
351 |
* </li> |
473 |
*/ |
352 |
* <li>For primitive types, the fully qualified name is the keyword for |
474 |
public ITypeBinding getDeclaringClass(); |
353 |
* the primitive type. |
475 |
|
354 |
* Example: <code>"int"</code>.</li> |
476 |
/** |
355 |
* <li>For the null type, the fully qualified name is the string |
477 |
* Returns the method binding representing the method that declares this binding |
356 |
* "null".</li> |
478 |
* of a local type or type variable. |
357 |
* <li>Local types (including anonymous classes) and members of local |
479 |
* <p> |
358 |
* types do not have a fully qualified name. For these types, and array |
480 |
* The declaring method of a local class or interface (including anonymous |
359 |
* types thereof, this method returns an empty string.</li> |
481 |
* classes) is the innermost method containing the expression or statement in |
360 |
* <li>For array types whose component type has a fully qualified name, |
482 |
* which this type is declared. Returns <code>null</code> if the type |
361 |
* the fully qualified name is the fully qualified name of the component |
483 |
* is declared in an initializer. |
362 |
* type (as computed by this method) followed by "[]". |
484 |
* </p> |
363 |
* Example: <code>"java.lang.String[]"</code>.</li> |
485 |
* <p> |
364 |
* <li>For type variables, the fully qualified name is just the name of the |
486 |
* The declaring method of a type variable is the method in which the type |
365 |
* type variable (type bounds are not included). |
487 |
* variable is declared if it is declared on a method. It |
366 |
* Example: <code>"X"</code>.</li> |
488 |
* returns <code>null</code> otherwise. |
367 |
* <li>For type bindings that correspond to particular instances of a generic |
489 |
* </p> |
368 |
* type arising from a parameterized type reference, |
490 |
* <p>Array types, primitive types, the null type, top-level types, |
369 |
* the fully qualified name is the fully qualified name of the erasure |
491 |
* and wildcard types have no declaring method. |
370 |
* type followed by the fully qualified names of the type arguments surrounded by "<>" and separated by ",". |
492 |
* </p> |
371 |
* Example: <code>"java.util.Collection<java.lang.String>"</code>. |
|
|
372 |
* </li> |
373 |
* <li>For type bindings that correspond to particular instances of a generic |
374 |
* type arising from a raw type reference, |
375 |
* the fully qualified name is the fully qualified name of the erasure type. |
376 |
* Example: <code>"java.util.Collection"</code>. Note that the |
377 |
* the type parameters are omitted.</li> |
378 |
* <li>For wildcard types, the fully qualified name is "?" optionally followed by |
379 |
* a single space followed by the keyword "extends" or "super" |
380 |
* followed a single space followed by the fully qualified name of the bound |
381 |
* (as computed by this method) when present. |
382 |
* Example: <code>"? extends java.io.InputStream"</code>. |
383 |
* </li> |
384 |
* <li>Capture types do not have a fully qualified name. For these types, |
385 |
* and array types thereof, this method returns an empty string.</li> |
386 |
* </ul> |
493 |
* |
387 |
* |
494 |
* @return the binding of the method that declares this type, or |
388 |
* @return the fully qualified name of the type represented by this |
495 |
* <code>null</code> if none |
389 |
* binding, or the empty string if it has none |
|
|
390 |
* @see #getName() |
391 |
* @since 2.1 |
496 |
*/ |
392 |
*/ |
497 |
public IMethodBinding getDeclaringMethod(); |
393 |
public String getQualifiedName(); |
498 |
|
394 |
|
499 |
/** |
395 |
/** |
500 |
* Returns the type binding for the superclass of the type represented |
396 |
* Returns the type binding for the superclass of the type represented |
501 |
* by this class binding. |
397 |
* by this class binding. |
Lines 515-522
Link Here
|
515 |
* <p> |
411 |
* <p> |
516 |
* If this type binding represents an interface, an array type, a |
412 |
* If this type binding represents an interface, an array type, a |
517 |
* primitive type, the null type, a type variable, an enum type, |
413 |
* primitive type, the null type, a type variable, an enum type, |
518 |
* an annotation type, or a wildcard type, then <code>null</code> |
414 |
* an annotation type, a wildcard type, or a capture binding, |
519 |
* is returned. |
415 |
* then <code>null</code> is returned. |
520 |
* </p> |
416 |
* </p> |
521 |
* |
417 |
* |
522 |
* @return the superclass of the class represented by this type binding, |
418 |
* @return the superclass of the class represented by this type binding, |
Lines 526-619
Link Here
|
526 |
public ITypeBinding getSuperclass(); |
422 |
public ITypeBinding getSuperclass(); |
527 |
|
423 |
|
528 |
/** |
424 |
/** |
529 |
* Returns a list of type bindings representing the direct superinterfaces |
425 |
* Returns the type arguments of this generic type instance, or the |
530 |
* of the class, interface, or enum type represented by this type binding. |
426 |
* empty list for other type bindings. |
531 |
* <p> |
427 |
* <p> |
532 |
* If this type binding represents a class or enum type, the return value |
428 |
* Note that type arguments only occur on a type binding that represents |
533 |
* is an array containing type bindings representing all interfaces |
429 |
* an instance of a generic type corresponding to a parameterized type |
534 |
* directly implemented by this class. The number and order of the interface |
430 |
* reference (e.g., <code>Collection<String></code>) or to a raw |
535 |
* objects in the array corresponds to the number and order of the interface |
431 |
* type reference (e.g., <code>Collection</code>) to a generic type. |
536 |
* names in the <code>implements</code> clause of the original declaration |
432 |
* Do not confuse these with type parameters which only occur on the |
537 |
* of this type. |
433 |
* type binding corresponding directly to the declaration of the |
538 |
* </p> |
434 |
* generic class or interface (e.g., <code>Collection<T></code>). |
|
|
435 |
* </p> |
436 |
* |
437 |
* @return the list of type bindings for the type arguments used to |
438 |
* instantiate the corrresponding generic type, or otherwise the empty list |
439 |
* @see #getTypeDeclaration() |
440 |
* @see #isGenericType() |
441 |
* @see #isParameterizedType() |
442 |
* @see #isRawType() |
443 |
* @since 3.1 |
444 |
*/ |
445 |
public ITypeBinding[] getTypeArguments(); |
446 |
|
447 |
/** |
448 |
* Returns the type bounds of this type variable or capture. |
449 |
* |
450 |
* @return the list of type bindings for this type variable or capture, |
451 |
* or otherwise the empty list |
452 |
* @see #isCapture() |
453 |
* @see #isTypeVariable() |
454 |
* @since 3.1 |
455 |
*/ |
456 |
public ITypeBinding[] getTypeBounds(); |
457 |
|
458 |
/** |
459 |
* Returns the binding for the type declaration corresponding to this type |
460 |
* binding. For parameterized types ({@link #isParameterizedType()}) |
461 |
* and raw types ({@link #isRawType()}), this method returns the binding |
462 |
* for the corresponding generic type. For other type bindings, this |
463 |
* returns the same binding. |
464 |
* |
465 |
* @return the type binding |
466 |
* @since 3.1 |
467 |
*/ |
468 |
public ITypeBinding getTypeDeclaration(); |
469 |
|
470 |
/** |
471 |
* Returns the type parameters of this class or interface type binding. |
539 |
* <p> |
472 |
* <p> |
540 |
* If this type binding represents an interface, the array contains |
473 |
* Note that type parameters only occur on the binding of the |
541 |
* type bindings representing all interfaces directly extended by this |
474 |
* declaring generic class or interface; e.g., <code>Collection<T></code>. |
542 |
* interface. The number and order of the interface objects in the array |
475 |
* Type bindings corresponding to a raw or parameterized reference to a generic |
543 |
* corresponds to the number and order of the interface names in the |
476 |
* type do not carry type parameters (they instead have non-empty type arguments |
544 |
* <code>extends</code> clause of the original declaration of this interface. |
477 |
* and non-trivial erasure). |
545 |
* </p> |
478 |
* </p> |
|
|
479 |
* |
480 |
* @return the list of binding for the type variables for the type |
481 |
* parameters of this type, or otherwise the empty list |
482 |
* @see #isTypeVariable() |
483 |
* @since 3.1 |
484 |
*/ |
485 |
// 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 |
486 |
public ITypeBinding[] getTypeParameters(); |
487 |
|
488 |
/** |
489 |
* Returns the corresponding wildcard binding of this capture binding. |
490 |
* Returns <code>null</code> if this type bindings does not represent |
491 |
* a capture binding. |
492 |
* |
493 |
* @return the corresponding wildcard binding for a capture |
494 |
* binding, <code>null</code> otherwise |
495 |
* @since 3.1 |
496 |
*/ |
497 |
public ITypeBinding getWildcard(); |
498 |
|
499 |
/** |
500 |
* Returns whether this type binding represents an annotation type. |
546 |
* <p> |
501 |
* <p> |
547 |
* If the class or enum implements no interfaces, or the interface extends |
502 |
* Note that an annotation type is always an interface. |
548 |
* no interfaces, or if this type binding represents an array type, a |
|
|
549 |
* primitive type, the null type, a type variable, an annotation type, |
550 |
* or a wildcard type, this method returns an array of length 0. |
551 |
* </p> |
503 |
* </p> |
552 |
* |
504 |
* |
553 |
* @return the list of type bindings for the interfaces extended by this |
505 |
* @return <code>true</code> if this object represents an annotation type, |
554 |
* class or enum, or interfaces extended by this interface, or otherwise |
506 |
* and <code>false</code> otherwise |
555 |
* the empty list |
507 |
* @since 3.1 |
556 |
*/ |
508 |
*/ |
557 |
public ITypeBinding[] getInterfaces(); |
509 |
public boolean isAnnotation(); |
558 |
|
510 |
|
559 |
/** |
511 |
/** |
560 |
* Returns the compiled modifiers for this class, interface, enum, |
512 |
* Returns whether this type binding represents an anonymous class. |
561 |
* or annotation type binding. |
513 |
* <p> |
562 |
* The result may not correspond to the modifiers as declared in the |
514 |
* An anonymous class is a subspecies of local class, and therefore mutually |
563 |
* original source, since the compiler may change them (in particular, |
515 |
* exclusive with member types. Note that anonymous classes have no name |
564 |
* for inner class emulation). The <code>getDeclaredModifiers</code> method |
516 |
* (<code>getName</code> returns the empty string). |
565 |
* should be used if the original modifiers are needed. |
517 |
* </p> |
566 |
* Returns 0 if this type does not represent a class, interface, enum, or annotation |
518 |
* |
567 |
* type. |
519 |
* @return <code>true</code> if this type binding is for an anonymous class, |
568 |
* |
520 |
* and <code>false</code> otherwise |
569 |
* @return the compiled modifiers for this type binding or 0 |
|
|
570 |
* if this type does not represent a class, interface, enum, or annotation |
571 |
* type |
572 |
* @see #getDeclaredModifiers() |
573 |
*/ |
521 |
*/ |
574 |
public int getModifiers(); |
522 |
public boolean isAnonymous(); |
575 |
|
523 |
|
576 |
/** |
524 |
/** |
577 |
* Returns the declared modifiers for this class or interface binding |
525 |
* Returns whether this type binding represents an array type. |
578 |
* as specified in the original source declaration of the class or |
|
|
579 |
* interface. The result may not correspond to the modifiers in the compiled |
580 |
* binary, since the compiler may change them (in particular, for inner |
581 |
* class emulation). The <code>getModifiers</code> method should be used if |
582 |
* the compiled modifiers are needed. Returns -1 if this type does not |
583 |
* represent a class or interface. |
584 |
* |
526 |
* |
585 |
* @return the bit-wise or of <code>Modifier</code> constants |
527 |
* @return <code>true</code> if this type binding is for an array type, |
586 |
* @see #getModifiers() |
528 |
* and <code>false</code> otherwise |
587 |
* @see Modifier |
529 |
* @see #getElementType() |
|
|
530 |
* @see #getDimensions() |
588 |
*/ |
531 |
*/ |
589 |
public int getDeclaredModifiers(); |
532 |
public boolean isArray(); |
590 |
|
533 |
|
591 |
/** |
534 |
/** |
592 |
* Returns whether this type is subtype compatible with the given type, |
535 |
* Returns whether this type is assigment compatible with the given type, |
593 |
* as specified in section 4.10 of <em>The Java Language |
536 |
* as specified in section 5.2 of <em>The Java Language |
594 |
* Specification, Third Edition</em> (JLS3). |
537 |
* Specification, Third Edition</em> (JLS3). |
595 |
* |
538 |
* |
596 |
* @param type the type to check compatibility against |
539 |
* @param type the type to check compatibility against |
597 |
* @return <code>true</code> if this type is subtype compatible with the |
540 |
* @return <code>true</code> if this type is assigment compatible with the |
598 |
* given type, and <code>false</code> otherwise |
541 |
* given type, and <code>false</code> otherwise |
599 |
* @since 3.1 |
542 |
* @since 3.1 |
600 |
*/ |
543 |
*/ |
601 |
public boolean isSubTypeCompatible(ITypeBinding type); |
544 |
public boolean isAssignmentCompatible(ITypeBinding type); |
602 |
|
545 |
|
603 |
/** |
546 |
/** |
604 |
* Returns whether this type binding represents a top-level class, |
547 |
* Returns whether this type binding represents a capture binding. |
605 |
* interface, enum, or annotation type. |
548 |
* <p> |
|
|
549 |
* Capture bindings result from capture conversion as specified |
550 |
* in section 5.1.10 of <em>The Java Language Specification, |
551 |
* Third Edition</em> (JLS3). |
552 |
* </p> |
553 |
* <p> |
554 |
* A capture binding may have upper bounds and a lower bound. |
555 |
* Upper bounds may be accessed using {@link #getTypeBounds()}, |
556 |
* the lower bound must be accessed indirectly through the associated |
557 |
* wildcard {@link #getWildcard()} when it is a lower bound wildcard. |
558 |
* </p> |
559 |
* <p> |
560 |
* Note that capture bindings are distinct from type variables |
561 |
* (even though they are often depicted as synthetic type |
562 |
* variables); as such, {@link #isTypeVariable()} answers |
563 |
* <code>false</code> for capture bindings, and |
564 |
* {@link #isCapture()} answers <code>false</code> for type variables. |
565 |
* </p> |
566 |
* |
567 |
* @return <code>true</code> if this type binding is a capture, |
568 |
* and <code>false</code> otherwise |
569 |
* @see #getTypeBounds() |
570 |
* @see #getWildcard() |
571 |
* @since 3.1 |
572 |
*/ |
573 |
public boolean isCapture(); |
574 |
|
575 |
/** |
576 |
* Returns whether this type is cast compatible with the given type, |
577 |
* as specified in section 5.5 of <em>The Java Language |
578 |
* Specification, Third Edition</em> (JLS3). |
579 |
* |
580 |
* @param type the type to check compatibility against |
581 |
* @return <code>true</code> if this type is cast compatible with the |
582 |
* given type, and <code>false</code> otherwise |
583 |
* @since 3.1 |
584 |
*/ |
585 |
public boolean isCastCompatible(ITypeBinding type); |
586 |
|
587 |
/** |
588 |
* Returns whether this type binding represents a class type. |
589 |
* |
590 |
* @return <code>true</code> if this object represents a class, |
591 |
* and <code>false</code> otherwise |
592 |
*/ |
593 |
public boolean isClass(); |
594 |
|
595 |
/** |
596 |
* Returns whether this type binding represents an enum type. |
597 |
* |
598 |
* @return <code>true</code> if this object represents an enum type, |
599 |
* and <code>false</code> otherwise |
600 |
* @since 3.1 |
601 |
*/ |
602 |
public boolean isEnum(); |
603 |
|
604 |
/** |
605 |
* Returns whether this type binding originated in source code. |
606 |
* Returns <code>false</code> for all primitive types, the null type, |
607 |
* array types, and for all classes, interfaces, enums, annotation |
608 |
* types, type variables, parameterized type references, |
609 |
* raw type references, wildcard types, and capture bindings |
610 |
* whose information came from a pre-compiled binary class file. |
611 |
* |
612 |
* @return <code>true</code> if the type is in source code, |
613 |
* and <code>false</code> otherwise |
614 |
*/ |
615 |
public boolean isFromSource(); |
616 |
|
617 |
/** |
618 |
* Returns whether this type binding represents a declaration of |
619 |
* a generic class or interface. |
620 |
* <p> |
621 |
* Note that type parameters only occur on the binding of the |
622 |
* declaring generic class or interface; e.g., <code>Collection<T></code>. |
623 |
* Type bindings corresponding to a raw or parameterized reference to a generic |
624 |
* type do not carry type parameters (they instead have non-empty type arguments |
625 |
* and non-trivial erasure). |
626 |
* This method is fully equivalent to <code>getTypeParameters().length > 0)</code>. |
627 |
* </p> |
628 |
* <p> |
629 |
* Note that {@link #isGenericType()}, |
630 |
* {@link #isParameterizedType()}, |
631 |
* and {@link #isRawType()} are mutually exclusive. |
632 |
* </p> |
633 |
* |
634 |
* @return <code>true</code> if this type binding represents a |
635 |
* declaration of a generic class or interface, and <code>false</code> otherwise |
636 |
* @see #getTypeParameters() |
637 |
* @since 3.1 |
638 |
*/ |
639 |
public boolean isGenericType(); |
640 |
|
641 |
/** |
642 |
* Returns whether this type binding represents an interface type. |
643 |
* <p> |
644 |
* Note that an interface can also be an annotation type. |
645 |
* </p> |
646 |
* |
647 |
* @return <code>true</code> if this object represents an interface, |
648 |
* and <code>false</code> otherwise |
649 |
*/ |
650 |
public boolean isInterface(); |
651 |
|
652 |
/** |
653 |
* Returns whether this type binding represents a local class. |
654 |
* <p> |
655 |
* A local class is any nested class or enum type not declared as a member |
656 |
* of another class or interface. A local class is a subspecies of nested |
657 |
* type, and mutually exclusive with member types. Note that anonymous |
658 |
* classes are a subspecies of local classes. |
659 |
* </p> |
660 |
* <p> |
661 |
* Also note that interfaces and annotation types cannot be local. |
662 |
* </p> |
663 |
* |
664 |
* @return <code>true</code> if this type binding is for a local class or |
665 |
* enum type, and <code>false</code> otherwise |
666 |
*/ |
667 |
public boolean isLocal(); |
668 |
|
669 |
/** |
670 |
* Returns whether this type binding represents a member class or |
671 |
* interface. |
606 |
* <p> |
672 |
* <p> |
607 |
* A top-level type is any type whose declaration does not occur within the |
673 |
* A member type is any type declared as a member of |
608 |
* body of another type declaration. The set of top level types is disjoint |
674 |
* another type. A member type is a subspecies of nested |
609 |
* from the set of nested types. |
675 |
* type, and mutually exclusive with local types. |
610 |
* </p> |
676 |
* </p> |
611 |
* |
677 |
* |
612 |
* @return <code>true</code> if this type binding is for a top-level class, |
678 |
* @return <code>true</code> if this type binding is for a member class, |
613 |
* interface, enum, or annotation type, and <code>false</code> otherwise |
679 |
* interface, enum, or annotation type, and <code>false</code> otherwise |
614 |
*/ |
680 |
*/ |
615 |
public boolean isTopLevel(); |
681 |
public boolean isMember(); |
616 |
|
682 |
|
617 |
/** |
683 |
/** |
618 |
* Returns whether this type binding represents a nested class, interface, |
684 |
* Returns whether this type binding represents a nested class, interface, |
619 |
* enum, or annotation type. |
685 |
* enum, or annotation type. |
Lines 630-795
Link Here
|
630 |
public boolean isNested(); |
696 |
public boolean isNested(); |
631 |
|
697 |
|
632 |
/** |
698 |
/** |
633 |
* Returns whether this type binding represents a member class or |
699 |
* Returns whether this type binding represents the null type. |
634 |
* interface. |
|
|
635 |
* <p> |
700 |
* <p> |
636 |
* A member type is any type declared as a member of |
701 |
* The null type is the type of a <code>NullLiteral</code> node. |
637 |
* another type. A member type is a subspecies of nested |
|
|
638 |
* type, and mutually exclusive with local types. |
639 |
* </p> |
702 |
* </p> |
640 |
* |
703 |
* |
641 |
* @return <code>true</code> if this type binding is for a member class, |
704 |
* @return <code>true</code> if this type binding is for the null type, |
642 |
* interface, enum, or annotation type, and <code>false</code> otherwise |
705 |
* and <code>false</code> otherwise |
643 |
*/ |
706 |
*/ |
644 |
public boolean isMember(); |
707 |
public boolean isNullType(); |
645 |
|
708 |
|
646 |
/** |
709 |
/** |
647 |
* Returns whether this type binding represents a local class. |
710 |
* Returns whether this type binding represents an instance of |
|
|
711 |
* a generic type corresponding to a parameterized type reference. |
648 |
* <p> |
712 |
* <p> |
649 |
* A local class is any nested class or enum type not declared as a member |
713 |
* For example, an AST type like |
650 |
* of another class or interface. A local class is a subspecies of nested |
714 |
* <code>Collection<String></code> typically resolves to a |
651 |
* type, and mutually exclusive with member types. Note that anonymous |
715 |
* type binding whose type argument is the type binding for the |
652 |
* classes are a subspecies of local classes. |
716 |
* class <code>java.lang.String</code> and whose erasure is the type |
|
|
717 |
* binding for the generic type <code>java.util.Collection</code>. |
653 |
* </p> |
718 |
* </p> |
654 |
* <p> |
719 |
* Note that {@link #isGenericType()}, |
655 |
* Also note that interfaces and annotation types cannot be local. |
720 |
* {@link #isParameterizedType()}, |
|
|
721 |
* and {@link #isRawType()} are mutually exclusive. |
656 |
* </p> |
722 |
* </p> |
657 |
* |
723 |
* |
658 |
* @return <code>true</code> if this type binding is for a local class or |
724 |
* @return <code>true</code> if this type binding represents a |
659 |
* enum type, and <code>false</code> otherwise |
725 |
* an instance of a generic type corresponding to a parameterized |
|
|
726 |
* type reference, and <code>false</code> otherwise |
727 |
* @see #getTypeArguments() |
728 |
* @see #getTypeDeclaration() |
729 |
* @since 3.1 |
660 |
*/ |
730 |
*/ |
661 |
public boolean isLocal(); |
731 |
public boolean isParameterizedType(); |
662 |
|
732 |
|
663 |
/** |
733 |
/** |
664 |
* Returns whether this type binding represents an anonymous class. |
734 |
* Returns whether this type binding represents a primitive type. |
665 |
* <p> |
735 |
* <p> |
666 |
* An anonymous class is a subspecies of local class, and therefore mutually |
736 |
* There are nine predefined type bindings to represent the eight primitive |
667 |
* exclusive with member types. Note that anonymous classes have no name |
737 |
* types and <code>void</code>. These have the same names as the primitive |
668 |
* (<code>getName</code> returns the empty string). |
738 |
* types that they represent, namely boolean, byte, char, short, int, |
|
|
739 |
* long, float, and double, and void. |
669 |
* </p> |
740 |
* </p> |
670 |
* |
741 |
* |
671 |
* @return <code>true</code> if this type binding is for an anonymous class, |
742 |
* @return <code>true</code> if this type binding is for a primitive type, |
672 |
* and <code>false</code> otherwise |
743 |
* and <code>false</code> otherwise |
673 |
*/ |
744 |
*/ |
674 |
public boolean isAnonymous(); |
745 |
public boolean isPrimitive(); |
|
|
746 |
|
747 |
/** |
748 |
* Returns whether this type binding represents an instance of |
749 |
* a generic type corresponding to a raw type reference. |
750 |
* <p> |
751 |
* For example, an AST type like |
752 |
* <code>Collection</code> typically resolves to a |
753 |
* type binding whose type argument is the type binding for |
754 |
* the class <code>java.lang.Object</code> (the |
755 |
* default bound for the single type parameter of |
756 |
* <code>java.util.Collection</code>) and whose erasure is the |
757 |
* type binding for the generic type |
758 |
* <code>java.util.Collection</code>. |
759 |
* </p> |
760 |
* <p> |
761 |
* Note that {@link #isGenericType()}, |
762 |
* {@link #isParameterizedType()}, |
763 |
* and {@link #isRawType()} are mutually exclusive. |
764 |
* </p> |
765 |
* |
766 |
* @return <code>true</code> if this type binding represents a |
767 |
* an instance of a generic type corresponding to a raw |
768 |
* type reference, and <code>false</code> otherwise |
769 |
* @see #getTypeDeclaration() |
770 |
* @see #getTypeArguments() |
771 |
* @since 3.1 |
772 |
*/ |
773 |
public boolean isRawType(); |
675 |
|
774 |
|
676 |
/** |
775 |
/** |
677 |
* Returns a list of type bindings representing all the types declared as |
776 |
* Returns whether this type is subtype compatible with the given type, |
678 |
* members of this class, interface, or enum type. |
777 |
* as specified in section 4.10 of <em>The Java Language |
679 |
* These include public, protected, default (package-private) access, |
778 |
* Specification, Third Edition</em> (JLS3). |
680 |
* and private classes, interfaces, enum types, and annotation types |
|
|
681 |
* declared by the type, but excludes inherited types. Returns an empty |
682 |
* list if the type declares no type members, or if this type |
683 |
* binding represents an array type, a primitive type, a type variable, |
684 |
* a wildcard type, or the null type. |
685 |
* The resulting bindings are in no particular order. |
686 |
* |
779 |
* |
687 |
* @return the list of type bindings for the member types of this type, |
780 |
* @param type the type to check compatibility against |
688 |
* or the empty list if this type does not have member types |
781 |
* @return <code>true</code> if this type is subtype compatible with the |
|
|
782 |
* given type, and <code>false</code> otherwise |
783 |
* @since 3.1 |
689 |
*/ |
784 |
*/ |
690 |
public ITypeBinding[] getDeclaredTypes(); |
785 |
public boolean isSubTypeCompatible(ITypeBinding type); |
691 |
|
786 |
|
692 |
/** |
787 |
/** |
693 |
* Returns a list of bindings representing all the fields declared |
788 |
* Returns whether this type binding represents a top-level class, |
694 |
* as members of this class, interface, or enum type. These include public, |
789 |
* interface, enum, or annotation type. |
695 |
* protected, default (package-private) access, and private fields declared |
790 |
* <p> |
696 |
* by the class, but excludes inherited fields. Synthetic fields may or |
791 |
* A top-level type is any type whose declaration does not occur within the |
697 |
* may not be included. |
792 |
* body of another type declaration. The set of top level types is disjoint |
698 |
* Returns an empty list if the class, interface, or enum declares no fields, |
793 |
* from the set of nested types. |
699 |
* and for other kinds of type bindings that do not directly have members. |
794 |
* </p> |
700 |
* The resulting bindings are in no particular order. |
795 |
* |
701 |
* |
796 |
* @return <code>true</code> if this type binding is for a top-level class, |
702 |
* @return the list of bindings for the field members of this type, |
797 |
* interface, enum, or annotation type, and <code>false</code> otherwise |
703 |
* or the empty list if this type does not have field members |
|
|
704 |
*/ |
798 |
*/ |
705 |
public IVariableBinding[] getDeclaredFields(); |
799 |
public boolean isTopLevel(); |
706 |
|
800 |
|
707 |
/** |
801 |
/** |
708 |
* Returns a list of method bindings representing all the methods and |
802 |
* Returns whether this type binding represents a type variable. |
709 |
* constructors declared for this class, interface, enum, or annotation |
803 |
* Type variables bindings carry the type variable's bounds. |
710 |
* type. These include public, protected, default (package-private) access, |
804 |
* <p> |
711 |
* and private methods Synthetic methods and constructors may or may not be |
805 |
* Note that type variables are distinct from capture bindings |
712 |
* included. Returns an empty list if the class, interface, or enum, |
806 |
* (even though capture bindings are often depicted as synthetic |
713 |
* type declares no methods or constructors, if the annotation type declares |
807 |
* type variables); as such, {@link #isTypeVariable()} answers |
714 |
* no members, or if this type binding represents some other kind of type |
808 |
* <code>false</code> for capture bindings, and |
715 |
* binding. The resulting bindings are in no particular order. |
809 |
* {@link #isCapture()} answers <code>false</code> for type variables. |
716 |
* |
810 |
* </p> |
717 |
* @return the list of method bindings for the methods and constructors |
811 |
* |
718 |
* declared by this class, interface, enum type, or annotation type, |
812 |
* @return <code>true</code> if this type binding is for a type variable, |
719 |
* or the empty list if this type does not declare any methods or constructors |
813 |
* and <code>false</code> otherwise |
|
|
814 |
* @see #getName() |
815 |
* @see #getTypeBounds() |
816 |
* @since 3.1 |
720 |
*/ |
817 |
*/ |
721 |
public IMethodBinding[] getDeclaredMethods(); |
818 |
public boolean isTypeVariable(); |
722 |
|
819 |
|
723 |
/** |
820 |
/** |
724 |
* Returns whether this type binding originated in source code. |
821 |
* Returns whether this wildcard type is an upper bound |
725 |
* Returns <code>false</code> for all primitive types, the null type, |
822 |
* ("extends") as opposed to a lower bound ("super"). |
726 |
* array types, and for all classes, interfaces, enums, annotation |
823 |
* Note that this property is only relevant for wildcards |
727 |
* types, type variables, parameterized type references, |
824 |
* that have a bound. |
728 |
* raw type references, and wildcard types, whose information came from a |
825 |
* |
729 |
* pre-compiled binary class file. |
826 |
* @return <code>true</code> if this wildcard type has a bound that is |
730 |
* |
827 |
* an upper bound, and <code>false</code> in all other cases |
731 |
* @return <code>true</code> if the type is in source code, |
828 |
* @see #isWildcardType() |
732 |
* and <code>false</code> otherwise |
829 |
* @see #getBound() |
|
|
830 |
* @since 3.1 |
733 |
*/ |
831 |
*/ |
734 |
public boolean isFromSource(); |
832 |
public boolean isUpperbound(); |
735 |
|
833 |
|
736 |
/** |
834 |
/** |
737 |
* Returns the fully qualified name of the type represented by this |
835 |
* Returns whether this type binding represents a wildcard type. A wildcard |
738 |
* binding if it has one. |
836 |
* type occus only as an argument to a parameterized type reference. |
739 |
* <ul> |
837 |
* <p> |
740 |
* <li>For top-level types, the fully qualified name is the simple name of |
838 |
* For example, a AST type like |
741 |
* the type preceded by the package name (or unqualified if in a default package) |
839 |
* <code>Collection<? extends Object></code> typically resolves to a |
742 |
* and a ".". |
840 |
* parameterized type binding whose type argument is a wildcard type |
743 |
* Example: <code>"java.lang.String"</code> or <code>"java.util.Collection"</code>. |
841 |
* with upper type bound <code>java.util.Object/code>. |
744 |
* Note that the type parameters of a generic type are not included.</li> |
842 |
* </p> |
745 |
* <li>For members of top-level types, the fully qualified name is the |
843 |
* |
746 |
* simple name of the type preceded by the fully qualified name of the |
844 |
* @return <code>true</code> if this object represents a wildcard type, |
747 |
* enclosing type (as computed by this method) and a ".". |
845 |
* and <code>false</code> otherwise |
748 |
* Example: <code>"java.io.ObjectInputStream.GetField"</code>. |
846 |
* @since 3.1 |
749 |
* If the binding is for a member type that corresponds to a particular instance |
847 |
* @see #getBound() |
750 |
* of a generic type arising from a parameterized type reference, the simple |
848 |
* @see #isUpperbound() |
751 |
* name of the type is followed by the fully qualified names of the type arguments |
|
|
752 |
* (as computed by this method) surrounded by "<>" and separated by ",". |
753 |
* Example: <code>"pkg.Outer.Inner<java.lang.String>"</code>. |
754 |
* </li> |
755 |
* <li>For primitive types, the fully qualified name is the keyword for |
756 |
* the primitive type. |
757 |
* Example: <code>"int"</code>.</li> |
758 |
* <li>For the null type, the fully qualified name is the string |
759 |
* "null".</li> |
760 |
* <li>Local types (including anonymous classes) and members of local |
761 |
* types do not have a fully qualified name. For these types, and array |
762 |
* types thereof, this method returns an empty string.</li> |
763 |
* <li>For array types whose component type has a fully qualified name, |
764 |
* the fully qualified name is the fully qualified name of the component |
765 |
* type (as computed by this method) followed by "[]". |
766 |
* Example: <code>"java.lang.String[]"</code>.</li> |
767 |
* <li>For type variables, the fully qualified name is just the name of the |
768 |
* type variable (type bounds are not included). |
769 |
* Example: <code>"X"</code>.</li> |
770 |
* <li>For type bindings that correspond to particular instances of a generic |
771 |
* type arising from a parameterized type reference, |
772 |
* the fully qualified name is the fully qualified name of the erasure |
773 |
* type followed by the fully qualified names of the type arguments surrounded by "<>" and separated by ",". |
774 |
* Example: <code>"java.util.Collection<java.lang.String>"</code>. |
775 |
* </li> |
776 |
* <li>For type bindings that correspond to particular instances of a generic |
777 |
* type arising from a raw type reference, |
778 |
* the fully qualified name is the fully qualified name of the erasure type. |
779 |
* Example: <code>"java.util.Collection"</code>. Note that the |
780 |
* the type parameters are omitted.</li> |
781 |
* <li>For wildcard types, the fully qualified name is "?" optionally followed by |
782 |
* a single space followed by the keyword "extends" or "super" |
783 |
* followed a single space followed by the fully qualified name of the bound |
784 |
* (as computed by this method) when present. |
785 |
* Example: <code>"? extends java.io.InputStream"</code>. |
786 |
* </li> |
787 |
* </ul> |
788 |
* |
789 |
* @return the fully qualified name of the type represented by this |
790 |
* binding, or the empty string if it has none |
791 |
* @see #getName() |
792 |
* @since 2.1 |
793 |
*/ |
849 |
*/ |
794 |
public String getQualifiedName(); |
850 |
public boolean isWildcardType(); |
795 |
} |
851 |
} |