Source Code Cross Referenced for ITypeBinding.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » core » dom » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » jdt » org.eclipse.jdt.core.dom 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.jdt.core.dom;
011:
012:        /**
013:         * A type binding represents fully-resolved type. There are a number of
014:         * different kinds of type bindings:
015:         * <ul>
016:         * <li>a class - represents the class declaration;
017:         * possibly with type parameters</li>
018:         * <li>an interface - represents the class declaration;
019:         * possibly with type parameters</li>
020:         * <li>an enum - represents the enum declaration (enum types do not have
021:         * have type parameters)</li>
022:         * <li>an annotation - represents the annotation type declaration
023:         * (annotation types do not have have type parameters)</li>
024:         * <li>an array type - array types are referenced but not explicitly
025:         * declared</li>
026:         * <li>a primitive type (including the special return type <code>void</code>)
027:         * - primitive types are referenced but not explicitly declared</li>
028:         * <li>the null type - this is the special type of <code>null</code></li>
029:         * <li>a type variable - represents the declaration of a type variable;
030:         * possibly with type bounds</li>
031:         * <li>a wildcard type - represents a wild card used as a type argument in
032:         * a parameterized type reference</li>
033:         * <li>a raw type - represents a legacy non-parameterized reference to
034:         * a generic type</li>
035:         * <li>a parameterized type - represents an copy of a type declaration
036:         * with substitutions for its type parameters</li>
037:         * <li>a capture - represents a capture binding</li>
038:         * </ul>
039:         * <p>
040:         * This interface is not intended to be implemented by clients.
041:         * </p>
042:         *
043:         * @see ITypeBinding#getDeclaredTypes()
044:         * @since 2.0
045:         */
046:        public interface ITypeBinding extends IBinding {
047:
048:            /**
049:             * Answer an array type binding using the receiver and the given dimension.
050:             *
051:             * <p>If the receiver is an array binding, then the resulting dimension is the given dimension
052:             * plus the dimension of the receiver. Otherwise the resulting dimension is the given
053:             * dimension.</p>
054:             *
055:             * @param dimension the given dimension
056:             * @return an array type binding
057:             * @throws IllegalArgumentException:<ul>
058:             * <li>if the receiver represents the void type</li>
059:             * <li>if the resulting dimensions is lower than one or greater than 255</li>
060:             * </ul>
061:             * @since 3.3
062:             */
063:            public ITypeBinding createArrayType(int dimension);
064:
065:            /**
066:             * Returns the binary name of this type binding.
067:             * The binary name of a class is defined in the Java Language
068:             * Specification 3rd edition, section 13.1.
069:             * <p>
070:             * Note that in some cases, the binary name may be unavailable.
071:             * This may happen, for example, for a local type declared in
072:             * unreachable code.
073:             * </p>
074:             *
075:             * @return the binary name of this type, or <code>null</code>
076:             * if the binary name is unknown
077:             * @since 3.0
078:             */
079:            public String getBinaryName();
080:
081:            /**
082:             * Returns the bound of this wildcard type if it has one.
083:             * Returns <code>null</code> if this is not a wildcard type.
084:             *
085:             * @return the bound of this wildcard type, or <code>null</code> if none
086:             * @see #isWildcardType()
087:             * @see #isUpperbound()
088:             * @since 3.1
089:             */
090:            public ITypeBinding getBound();
091:
092:            /**
093:             * Returns the binding representing the component type of this array type,
094:             * or <code>null</code> if this is not an array type binding. The component
095:             * type of an array might be an array type.
096:             * <p>This is subject to change before 3.2 release.</p>
097:             *
098:             * @return the component type binding, or <code>null</code> if this is
099:             *   not an array type
100:             * @since 3.2
101:             */
102:            public ITypeBinding getComponentType();
103:
104:            /**
105:             * Returns a list of bindings representing all the fields declared
106:             * as members of this class, interface, or enum type.
107:             * 
108:             * <p>These include public, protected, default (package-private) access,
109:             * and private fields declared by the class, but excludes inherited fields.
110:             * Synthetic fields may or may not be included. Fields from binary types that
111:             * reference unresolvable types may not be included.</p>
112:             *
113:             * <p>Returns an empty list if the class, interface, or enum declares no fields,
114:             * and for other kinds of type bindings that do not directly have members.</p>
115:             *
116:             * <p>The resulting bindings are in no particular order.</p>
117:             *
118:             * @return the list of bindings for the field members of this type,
119:             *   or the empty list if this type does not have field members
120:             */
121:            public IVariableBinding[] getDeclaredFields();
122:
123:            /**
124:             * Returns a list of method bindings representing all the methods and
125:             * constructors declared for this class, interface, enum, or annotation
126:             * type.
127:             * <p>These include public, protected, default (package-private) access,
128:             * and private methods Synthetic methods and constructors may or may not be
129:             * included. Returns an empty list if the class, interface, or enum,
130:             * type declares no methods or constructors, if the annotation type declares
131:             * no members, or if this type binding represents some other kind of type
132:             * binding. Methods from binary types that reference unresolvable types may
133:             * not be included.</p>
134:             * <p>The resulting bindings are in no particular order.</p>
135:             *
136:             * @return the list of method bindings for the methods and constructors
137:             *   declared by this class, interface, enum type, or annotation type,
138:             *   or the empty list if this type does not declare any methods or constructors
139:             */
140:            public IMethodBinding[] getDeclaredMethods();
141:
142:            /**
143:             * Returns the declared modifiers for this class or interface binding
144:             * as specified in the original source declaration of the class or
145:             * interface. The result may not correspond to the modifiers in the compiled
146:             * binary, since the compiler may change them (in particular, for inner
147:             * class emulation). The <code>getModifiers</code> method should be used if
148:             * the compiled modifiers are needed. Returns -1 if this type does not
149:             * represent a class or interface.
150:             *
151:             * @return the bit-wise or of <code>Modifier</code> constants
152:             * @see #getModifiers()
153:             * @see Modifier
154:             */
155:            public int getDeclaredModifiers();
156:
157:            /**
158:             * Returns a list of type bindings representing all the types declared as
159:             * members of this class, interface, or enum type.
160:             * These include public, protected, default (package-private) access,
161:             * and private classes, interfaces, enum types, and annotation types
162:             * declared by the type, but excludes inherited types. Returns an empty
163:             * list if the type declares no type members, or if this type
164:             * binding represents an array type, a primitive type, a type variable,
165:             * a wildcard type, a capture, or the null type.
166:             * The resulting bindings are in no particular order.
167:             *
168:             * @return the list of type bindings for the member types of this type,
169:             *   or the empty list if this type does not have member types
170:             */
171:            public ITypeBinding[] getDeclaredTypes();
172:
173:            /**
174:             * Returns the type binding representing the class, interface, or enum
175:             * that declares this binding.
176:             * <p>
177:             * The declaring class of a member class, interface, enum, annotation
178:             * type is the class, interface, or enum type of which it is a member.
179:             * The declaring class of a local class or interface (including anonymous
180:             * classes) is the innermost class or interface containing the expression
181:             * or statement in which this type is declared.
182:             * </p>
183:             * <p>The declaring class of a type variable is the class in which the type
184:             * variable is declared if it is declared on a type. It returns
185:             * <code>null</code> otherwise.
186:             * </p>
187:             * <p>The declaring class of a capture binding is the innermost class or
188:             * interface containing the expression or statement in which this capture is
189:             * declared.
190:             * </p>
191:             * <p>Array types, primitive types, the null type, top-level types,
192:             * wildcard types, recovered binding have no declaring class.
193:             * </p>
194:             *
195:             * @return the binding of the type that declares this type, or
196:             * <code>null</code> if none
197:             */
198:            public ITypeBinding getDeclaringClass();
199:
200:            /**
201:             * Returns the method binding representing the method that declares this binding
202:             * of a local type or type variable.
203:             * <p>
204:             * The declaring method of a local class or interface (including anonymous
205:             * classes) is the innermost method containing the expression or statement in
206:             * which this type is declared. Returns <code>null</code> if the type
207:             * is declared in an initializer.
208:             * </p>
209:             * <p>
210:             * The declaring method of a type variable is the method in which the type
211:             * variable is declared if it is declared on a method. It
212:             * returns <code>null</code> otherwise.
213:             * </p>
214:             * <p>Array types, primitive types, the null type, top-level types,
215:             * wildcard types, capture bindings, and recovered binding have no
216:             * declaring method.
217:             * </p>
218:             *
219:             * @return the binding of the method that declares this type, or
220:             * <code>null</code> if none
221:             * @since 3.1
222:             */
223:            public IMethodBinding getDeclaringMethod();
224:
225:            /**
226:             * Returns the dimensionality of this array type, or <code>0</code> if this
227:             * is not an array type binding.
228:             *
229:             * @return the number of dimension of this array type binding, or
230:             *   <code>0</code> if this is not an array type
231:             */
232:            public int getDimensions();
233:
234:            /**
235:             * Returns the binding representing the element type of this array type,
236:             * or <code>null</code> if this is not an array type binding. The element
237:             * type of an array is never itself an array type.
238:             *
239:             * @return the element type binding, or <code>null</code> if this is
240:             *   not an array type
241:             */
242:            public ITypeBinding getElementType();
243:
244:            /**
245:             * Returns the erasure of this type binding.
246:             * <ul>
247:             * <li>For parameterized types ({@link #isParameterizedType()})
248:             * - returns the binding for the corresponding generic type.</li>
249:             * <li>For raw types ({@link #isRawType()})
250:             * - returns the binding for the corresponding generic type.</li>
251:             * <li>For wildcard types ({@link #isWildcardType()})
252:             * - returns the binding for the upper bound if it has one and
253:             * java.lang.Object in other cases.</li>
254:             * <li>For type variables ({@link #isTypeVariable()})
255:             * - returns the binding for the erasure of the leftmost bound
256:             * if it has bounds and java.lang.Object if it does not.</li>
257:             * <li>For captures ({@link #isCapture()})
258:             * - returns the binding for the erasure of the leftmost bound
259:             * if it has bounds and java.lang.Object if it does not.</li>
260:             * <li>For array types ({@link #isArray()}) - returns an array type of
261:             * the same dimension ({@link #getDimensions()}) as this type
262:             * binding for which the element type is the erasure of the element type
263:             * ({@link #getElementType()}) of this type binding.</li>
264:             * <li>For all other type bindings - returns the identical binding.</li>
265:             * </ul>
266:             *
267:             * @return the erasure type binding
268:             * @since 3.1
269:             */
270:            public ITypeBinding getErasure();
271:
272:            /**
273:             * Returns a list of type bindings representing the direct superinterfaces
274:             * of the class, interface, or enum type represented by this type binding.
275:             * <p>
276:             * If this type binding represents a class or enum type, the return value
277:             * is an array containing type bindings representing all interfaces
278:             * directly implemented by this class. The number and order of the interface
279:             * objects in the array corresponds to the number and order of the interface
280:             * names in the <code>implements</code> clause of the original declaration
281:             * of this type.
282:             * </p>
283:             * <p>
284:             * If this type binding represents an interface, the array contains
285:             * type bindings representing all interfaces directly extended by this
286:             * interface. The number and order of the interface objects in the array
287:             * corresponds to the number and order of the interface names in the
288:             * <code>extends</code> clause of the original declaration of this interface.
289:             * </p>
290:             * <p>
291:             * If the class or enum implements no interfaces, or the interface extends
292:             * no interfaces, or if this type binding represents an array type, a
293:             * primitive type, the null type, a type variable, an annotation type,
294:             * a wildcard type, or a capture binding, this method returns an array of
295:             * length 0.
296:             * </p>
297:             *
298:             * @return the list of type bindings for the interfaces extended by this
299:             *   class or enum, or interfaces extended by this interface, or otherwise
300:             *   the empty list
301:             */
302:            public ITypeBinding[] getInterfaces();
303:
304:            /**
305:             * Returns the compiled modifiers for this class, interface, enum,
306:             * or annotation type binding.
307:             * The result may not correspond to the modifiers as declared in the
308:             * original source, since the compiler may change them (in particular,
309:             * for inner class emulation). The <code>getDeclaredModifiers</code> method
310:             * should be used if the original modifiers are needed.
311:             * Returns 0 if this type does not represent a class, an interface, an enum, an annotation
312:             * type or a recovered type.
313:             *
314:             * @return the compiled modifiers for this type binding or 0
315:             * if this type does not represent a class, an interface, an enum, an annotation
316:             * type or a recovered type.
317:             * @see #getDeclaredModifiers()
318:             */
319:            public int getModifiers();
320:
321:            /**
322:             * Returns the unqualified name of the type represented by this binding
323:             * if it has one.
324:             * <ul>
325:             * <li>For top-level types, member types, and local types,
326:             * the name is the simple name of the type.
327:             * Example: <code>"String"</code> or <code>"Collection"</code>.
328:             * Note that the type parameters of a generic type are not included.</li>
329:             * <li>For primitive types, the name is the keyword for the primitive type.
330:             * Example: <code>"int"</code>.</li>
331:             * <li>For the null type, the name is the string "null".</li>
332:             * <li>For anonymous classes, which do not have a name,
333:             * this method returns an empty string.</li>
334:             * <li>For array types, the name is the unqualified name of the component
335:             * type (as computed by this method) followed by "[]".
336:             * Example: <code>"String[]"</code>. Note that the component type is never an
337:             * an anonymous class.</li>
338:             * <li>For type variables, the name is just the simple name of the
339:             * type variable (type bounds are not included).
340:             * Example: <code>"X"</code>.</li>
341:             * <li>For type bindings that correspond to particular instances of a generic
342:             * type arising from a parameterized type reference,
343:             * the name is the unqualified name of the erasure type (as computed by this method)
344:             * followed by the names (again, as computed by this method) of the type arguments
345:             * surrounded by "&lt;&gt;" and separated by ",".
346:             * Example: <code>"Collection&lt;String&gt;"</code>.
347:             * </li>
348:             * <li>For type bindings that correspond to particular instances of a generic
349:             * type arising from a raw type reference, the name is the unqualified name of
350:             * the erasure type (as computed by this method).
351:             * Example: <code>"Collection"</code>.</li>
352:             * <li>For wildcard types, the name is "?" optionally followed by
353:             * a single space followed by the keyword "extends" or "super"
354:             * followed a single space followed by the name of the bound (as computed by
355:             * this method) when present.
356:             * Example: <code>"? extends InputStream"</code>.
357:             * </li>
358:             * <li>Capture types do not have a name. For these types,
359:             * and array types thereof, this method returns an empty string.</li>
360:             * </ul>
361:             *
362:             * @return the unqualified name of the type represented by this binding,
363:             * or the empty string if it has none
364:             * @see #getQualifiedName()
365:             */
366:            public String getName();
367:
368:            /**
369:             * Returns the binding for the package in which this type is declared.
370:             * 
371:             * <p>The package of a recovered type reference binding is the package of the
372:             * enclosing type.</p>
373:             *
374:             * @return the binding for the package in which this class, interface,
375:             * enum, or annotation type is declared, or <code>null</code> if this type
376:             * binding represents a primitive type, an array type, the null type,
377:             * a type variable, a wildcard type, a capture binding.
378:             */
379:            public IPackageBinding getPackage();
380:
381:            /**
382:             * Returns the fully qualified name of the type represented by this
383:             * binding if it has one.
384:             * <ul>
385:             * <li>For top-level types, the fully qualified name is the simple name of
386:             * the type preceded by the package name (or unqualified if in a default package)
387:             * and a ".".
388:             * Example: <code>"java.lang.String"</code> or <code>"java.util.Collection"</code>.
389:             * Note that the type parameters of a generic type are not included.</li>
390:             * <li>For members of top-level types, the fully qualified name is the
391:             * simple name of the type preceded by the fully qualified name of the
392:             * enclosing type (as computed by this method) and a ".".
393:             * Example: <code>"java.io.ObjectInputStream.GetField"</code>.
394:             * If the binding is for a member type that corresponds to a particular instance
395:             * of a generic type arising from a parameterized type reference, the simple
396:             * name of the type is followed by the fully qualified names of the type arguments
397:             * (as computed by this method) surrounded by "&lt;&gt;" and separated by ",".
398:             * Example: <code>"pkg.Outer.Inner&lt;java.lang.String&gt;"</code>.
399:             * </li>
400:             * <li>For primitive types, the fully qualified name is the keyword for
401:             * the primitive type.
402:             * Example: <code>"int"</code>.</li>
403:             * <li>For the null type, the fully qualified name is the string
404:             * "null".</li>
405:             * <li>Local types (including anonymous classes) and members of local
406:             * types do not have a fully qualified name. For these types, and array
407:             * types thereof, this method returns an empty string.</li>
408:             * <li>For array types whose component type has a fully qualified name,
409:             * the fully qualified name is the fully qualified name of the component
410:             * type (as computed by this method) followed by "[]".
411:             * Example: <code>"java.lang.String[]"</code>.</li>
412:             * <li>For type variables, the fully qualified name is just the name of the
413:             * type variable (type bounds are not included).
414:             * Example: <code>"X"</code>.</li>
415:             * <li>For type bindings that correspond to particular instances of a generic
416:             * type arising from a parameterized type reference,
417:             * the fully qualified name is the fully qualified name of the erasure
418:             * type followed by the fully qualified names of the type arguments surrounded by "&lt;&gt;" and separated by ",".
419:             * Example: <code>"java.util.Collection&lt;java.lang.String&gt;"</code>.
420:             * </li>
421:             * <li>For type bindings that correspond to particular instances of a generic
422:             * type arising from a raw type reference,
423:             * the fully qualified name is the fully qualified name of the erasure type.
424:             * Example: <code>"java.util.Collection"</code>. Note that the
425:             * the type parameters are omitted.</li>
426:             * <li>For wildcard types, the fully qualified name is "?" optionally followed by
427:             * a single space followed by the keyword "extends" or "super"
428:             * followed a single space followed by the fully qualified name of the bound
429:             * (as computed by this method) when present.
430:             * Example: <code>"? extends java.io.InputStream"</code>.
431:             * </li>
432:             * <li>Capture types do not have a fully qualified name. For these types,
433:             * and array types thereof, this method returns an empty string.</li>
434:             * </ul>
435:             *
436:             * @return the fully qualified name of the type represented by this
437:             *    binding, or the empty string if it has none
438:             * @see #getName()
439:             * @since 2.1
440:             */
441:            public String getQualifiedName();
442:
443:            /**
444:             * Returns the type binding for the superclass of the type represented
445:             * by this class binding.
446:             * <p>
447:             * If this type binding represents any class other than the class
448:             * <code>java.lang.Object</code>, then the type binding for the direct
449:             * superclass of this class is returned. If this type binding represents
450:             * the class <code>java.lang.Object</code>, then <code>null</code> is
451:             * returned.
452:             * <p>
453:             * Loops that ascend the class hierarchy need a suitable termination test.
454:             * Rather than test the superclass for <code>null</code>, it is more
455:             * transparent to check whether the class is <code>Object</code>, by
456:             * comparing whether the class binding is identical to
457:             * <code>ast.resolveWellKnownType("java.lang.Object")</code>.
458:             * </p>
459:             * <p>
460:             * If this type binding represents an interface, an array type, a
461:             * primitive type, the null type, a type variable, an enum type,
462:             * an annotation type, a wildcard type, or a capture binding then
463:             * <code>null</code> is returned.
464:             * </p>
465:             *
466:             * @return the superclass of the class represented by this type binding,
467:             *    or <code>null</code> if none
468:             * @see AST#resolveWellKnownType(String)
469:             */
470:            public ITypeBinding getSuperclass();
471:
472:            /**
473:             * Returns the type arguments of this generic type instance, or the
474:             * empty list for other type bindings.
475:             * <p>
476:             * Note that type arguments only occur on a type binding that represents
477:             * an instance of a generic type corresponding to a parameterized type
478:             * reference (e.g., <code>Collection&lt;String&gt;</code>).
479:             * Do not confuse these with type parameters which only occur on the
480:             * type binding corresponding directly to the declaration of the
481:             * generic class or interface (e.g., <code>Collection&lt;T&gt;</code>).
482:             * </p>
483:             *
484:             * @return the list of type bindings for the type arguments used to
485:             * instantiate the corresponding generic type, or otherwise the empty list
486:             * @see #getTypeDeclaration()
487:             * @see #isGenericType()
488:             * @see #isParameterizedType()
489:             * @see #isRawType()
490:             * @since 3.1
491:             */
492:            public ITypeBinding[] getTypeArguments();
493:
494:            /**
495:             * Returns the declared type bounds of this type variable or capture. If the
496:             * variable or the capture had no explicit bound, then it returns an empty list.
497:             * <p>
498:             * Note that per construction, it can only contain one class or array type,
499:             * at most, and then it is located in first position.
500:             * </p>
501:             * <p>
502:             * Also note that array type bound may only occur in the case of a capture
503:             * binding, e.g. <code>capture-of ? extends Object[]</code>
504:             * </p>
505:             *
506:             * @return the list of type bindings for this type variable or capture,
507:             * or otherwise the empty list
508:             * @see #isCapture()
509:             * @see #isTypeVariable()
510:             * @since 3.1
511:             */
512:            public ITypeBinding[] getTypeBounds();
513:
514:            /**
515:             * Returns the binding for the type declaration corresponding to this type
516:             * binding.
517:             * <p>For parameterized types ({@link #isParameterizedType()})
518:             * and most raw types ({@link #isRawType()}), this method returns the binding
519:             * for the corresponding generic type.</p>
520:             * <p>For raw member types ({@link #isRawType()}, {@link #isMember()})
521:             * of a raw declaring class, the type declaration is a generic or a non-generic
522:             * type.</p>
523:             * <p>A different non-generic binding will be returned when one of the declaring
524:             * types/methods was parameterized.</p>
525:             * <p>For other type bindings, this returns the same binding.</p>
526:             *
527:             * @return the type binding
528:             * @since 3.1
529:             */
530:            public ITypeBinding getTypeDeclaration();
531:
532:            /**
533:             * Returns the type parameters of this class or interface type binding.
534:             * <p>
535:             * Note that type parameters only occur on the binding of the
536:             * declaring generic class or interface; e.g., <code>Collection&lt;T&gt;</code>.
537:             * Type bindings corresponding to a raw or parameterized reference to a generic
538:             * type do not carry type parameters (they instead have non-empty type arguments
539:             * and non-trivial erasure).
540:             * </p>
541:             *
542:             * @return the list of binding for the type variables for the type
543:             * parameters of this type, or otherwise the empty list
544:             * @see #isTypeVariable()
545:             * @since 3.1
546:             */
547:            // 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
548:            public ITypeBinding[] getTypeParameters();
549:
550:            /**
551:             * Returns the corresponding wildcard binding of this capture binding.
552:             * Returns <code>null</code> if this type bindings does not represent
553:             * a capture binding.
554:             *
555:             * @return the corresponding wildcard binding for a capture
556:             * binding, <code>null</code> otherwise
557:             * @since 3.1
558:             */
559:            public ITypeBinding getWildcard();
560:
561:            /**
562:             * Returns whether this type binding represents an annotation type.
563:             * <p>
564:             * Note that an annotation type is always an interface.
565:             * </p>
566:             *
567:             * @return <code>true</code> if this object represents an annotation type,
568:             *    and <code>false</code> otherwise
569:             * @since 3.1
570:             */
571:            public boolean isAnnotation();
572:
573:            /**
574:             * Returns whether this type binding represents an anonymous class.
575:             * <p>
576:             * An anonymous class is a subspecies of local class, and therefore mutually
577:             * exclusive with member types. Note that anonymous classes have no name
578:             * (<code>getName</code> returns the empty string).
579:             * </p>
580:             *
581:             * @return <code>true</code> if this type binding is for an anonymous class,
582:             *   and <code>false</code> otherwise
583:             */
584:            public boolean isAnonymous();
585:
586:            /**
587:             * Returns whether this type binding represents an array type.
588:             *
589:             * @return <code>true</code> if this type binding is for an array type,
590:             *   and <code>false</code> otherwise
591:             * @see #getElementType()
592:             * @see #getDimensions()
593:             */
594:            public boolean isArray();
595:
596:            /**
597:             * Returns whether an expression of this type can be assigned to a variable
598:             * of the given type, as specified in section 5.2 of <em>The Java Language
599:             * Specification, Third Edition</em> (JLS3).
600:             *
601:             * <p>If the receiver or the argument is a recovered type, the answer is always false,
602:             * unless the two types are identical or the argument is <code>java.lang.Object</code>.</p>
603:             *
604:             * @param variableType the type of a variable to check compatibility against
605:             * @return <code>true</code> if an expression of this type can be assigned to a
606:             *   variable of the given type, and <code>false</code> otherwise
607:             * @since 3.1
608:             */
609:            public boolean isAssignmentCompatible(ITypeBinding variableType);
610:
611:            /**
612:             * Returns whether this type binding represents a capture binding.
613:             * <p>
614:             * Capture bindings result from capture conversion as specified
615:             * in section 5.1.10 of <em>The Java Language Specification,
616:             * Third Edition</em> (JLS3).
617:             * </p>
618:             * <p>
619:             * A capture binding may have upper bounds and a lower bound.
620:             * Upper bounds may be accessed using {@link #getTypeBounds()},
621:             * the lower bound must be accessed indirectly through the associated
622:             * wildcard {@link #getWildcard()} when it is a lower bound wildcard.
623:             * </p>
624:             * <p>
625:             * Note that capture bindings are distinct from type variables
626:             * (even though they are often depicted as synthetic type
627:             * variables); as such, {@link #isTypeVariable()} answers
628:             * <code>false</code> for capture bindings, and
629:             * {@link #isCapture()} answers <code>false</code> for type variables.
630:             * </p>
631:             *
632:             * @return <code>true</code> if this type binding is a capture,
633:             *   and <code>false</code> otherwise
634:             * @see #getTypeBounds()
635:             * @see #getWildcard()
636:             * @since 3.1
637:             */
638:            public boolean isCapture();
639:
640:            /**
641:             * Returns whether this type is cast compatible with the given type,
642:             * as specified in section 5.5 of <em>The Java Language
643:             * Specification, Third Edition</em> (JLS3).
644:             * <p>
645:             * NOTE: The cast compatibility check performs backwards.
646:             * When testing whether type B can be cast to type A, one would use:
647:             * <code>A.isCastCompatible(B)</code>
648:             * </p>
649:             *
650:             * <p>If the receiver or the argument is a recovered type, the answer is always false,
651:             * unless the two types are identical or the argument is <code>java.lang.Object</code>.</p>
652:             *
653:             * @param type the type to check compatibility against
654:             * @return <code>true</code> if this type is cast compatible with the
655:             * given type, and <code>false</code> otherwise
656:             * @since 3.1
657:             */
658:            public boolean isCastCompatible(ITypeBinding type);
659:
660:            /**
661:             * Returns whether this type binding represents a class type or a recovered binding.
662:             *
663:             * @return <code>true</code> if this object represents a class or a recovered binding,
664:             *    and <code>false</code> otherwise
665:             */
666:            public boolean isClass();
667:
668:            /**
669:             * Returns whether this type binding represents an enum type.
670:             *
671:             * @return <code>true</code> if this object represents an enum type,
672:             *    and <code>false</code> otherwise
673:             * @since 3.1
674:             */
675:            public boolean isEnum();
676:
677:            /**
678:             * Returns whether this type binding originated in source code.
679:             * Returns <code>false</code> for all primitive types, the null type,
680:             * array types, and for all classes, interfaces, enums, annotation
681:             * types, type variables, parameterized type references,
682:             * raw type references, wildcard types, and capture bindings
683:             * whose information came from a pre-compiled binary class file.
684:             *
685:             * @return <code>true</code> if the type is in source code,
686:             *    and <code>false</code> otherwise
687:             */
688:            public boolean isFromSource();
689:
690:            /**
691:             * Returns whether this type binding represents a declaration of
692:             * a generic class or interface.
693:             * <p>
694:             * Note that type parameters only occur on the binding of the
695:             * declaring generic class or interface; e.g., <code>Collection&lt;T&gt;</code>.
696:             * Type bindings corresponding to a raw or parameterized reference to a generic
697:             * type do not carry type parameters (they instead have non-empty type arguments
698:             * and non-trivial erasure).
699:             * This method is fully equivalent to <code>getTypeParameters().length &gt; 0)</code>.
700:             * </p>
701:             * <p>
702:             * Note that {@link #isGenericType()},
703:             * {@link #isParameterizedType()},
704:             * and {@link #isRawType()} are mutually exclusive.
705:             * </p>
706:             *
707:             * @return <code>true</code> if this type binding represents a
708:             * declaration of a generic class or interface, and <code>false</code> otherwise
709:             * @see #getTypeParameters()
710:             * @since 3.1
711:             */
712:            public boolean isGenericType();
713:
714:            /**
715:             * Returns whether this type binding represents an interface type.
716:             * <p>
717:             * Note that an interface can also be an annotation type.
718:             * </p>
719:             *
720:             * @return <code>true</code> if this object represents an interface,
721:             *    and <code>false</code> otherwise
722:             */
723:            public boolean isInterface();
724:
725:            /**
726:             * Returns whether this type binding represents a local class.
727:             * <p>
728:             * A local class is any nested class or enum type not declared as a member
729:             * of another class or interface. A local class is a subspecies of nested
730:             * type, and mutually exclusive with member types. Note that anonymous
731:             * classes are a subspecies of local classes.
732:             * </p>
733:             * <p>
734:             * Also note that interfaces and annotation types cannot be local.
735:             * </p>
736:             *
737:             * @return <code>true</code> if this type binding is for a local class or
738:             * enum type, and <code>false</code> otherwise
739:             */
740:            public boolean isLocal();
741:
742:            /**
743:             * Returns whether this type binding represents a member class or
744:             * interface.
745:             * <p>
746:             * A member type is any type declared as a member of
747:             * another type. A member type is a subspecies of nested
748:             * type, and mutually exclusive with local types.
749:             * </p>
750:             *
751:             * @return <code>true</code> if this type binding is for a member class,
752:             *   interface, enum, or annotation type, and <code>false</code> otherwise
753:             */
754:            public boolean isMember();
755:
756:            /**
757:             * Returns whether this type binding represents a nested class, interface,
758:             * enum, or annotation type.
759:             * <p>
760:             * A nested type is any type whose declaration occurs within
761:             * the body of another. The set of nested types is disjoint from the set of
762:             * top-level types. Nested types further subdivide into member types, local
763:             * types, and anonymous types.
764:             * </p>
765:             *
766:             * @return <code>true</code> if this type binding is for a nested class,
767:             *   interface, enum, or annotation type, and <code>false</code> otherwise
768:             */
769:            public boolean isNested();
770:
771:            /**
772:             * Returns whether this type binding represents the null type.
773:             * <p>
774:             * The null type is the type of a <code>NullLiteral</code> node.
775:             * </p>
776:             *
777:             * @return <code>true</code> if this type binding is for the null type,
778:             *   and <code>false</code> otherwise
779:             */
780:            public boolean isNullType();
781:
782:            /**
783:             * Returns whether this type binding represents an instance of
784:             * a generic type corresponding to a parameterized type reference.
785:             * <p>
786:             * For example, an AST type like
787:             * <code>Collection&lt;String&gt;</code> typically resolves to a
788:             * type binding whose type argument is the type binding for the
789:             * class <code>java.lang.String</code> and whose erasure is the type
790:             * binding for the generic type <code>java.util.Collection</code>.
791:             * </p>
792:             * <p>
793:             * Note that {@link #isGenericType()},
794:             * {@link #isParameterizedType()},
795:             * and {@link #isRawType()} are mutually exclusive.
796:             * </p>
797:             *
798:             * @return <code>true</code> if this type binding represents a
799:             * an instance of a generic type corresponding to a parameterized
800:             * type reference, and <code>false</code> otherwise
801:             * @see #getTypeArguments()
802:             * @see #getTypeDeclaration()
803:             * @since 3.1
804:             */
805:            public boolean isParameterizedType();
806:
807:            /**
808:             * Returns whether this type binding represents a primitive type.
809:             * <p>
810:             * There are nine predefined type bindings to represent the eight primitive
811:             * types and <code>void</code>. These have the same names as the primitive
812:             * types that they represent, namely boolean, byte, char, short, int,
813:             * long, float, and double, and void.
814:             * </p>
815:             *
816:             * @return <code>true</code> if this type binding is for a primitive type,
817:             *   and <code>false</code> otherwise
818:             */
819:            public boolean isPrimitive();
820:
821:            /**
822:             * Returns whether this type binding represents an instance of
823:             * a generic type corresponding to a raw type reference.
824:             * <p>
825:             * For example, an AST type like
826:             * <code>Collection</code> typically resolves to a
827:             * type binding whose type argument is the type binding for
828:             * the class <code>java.lang.Object</code> (the
829:             * default bound for the single type parameter of
830:             * <code>java.util.Collection</code>) and whose erasure is the
831:             * type binding for the generic type
832:             * <code>java.util.Collection</code>.
833:             * </p>
834:             * <p>
835:             * Note that {@link #isGenericType()},
836:             * {@link #isParameterizedType()},
837:             * and {@link #isRawType()} are mutually exclusive.
838:             * </p>
839:             *
840:             * @return <code>true</code> if this type binding represents a
841:             * an instance of a generic type corresponding to a raw
842:             * type reference, and <code>false</code> otherwise
843:             * @see #getTypeDeclaration()
844:             * @see #getTypeArguments()
845:             * @since 3.1
846:             */
847:            public boolean isRawType();
848:
849:            /**
850:             * Returns whether this type is subtype compatible with the given type,
851:             * as specified in section 4.10 of <em>The Java Language
852:             * Specification, Third Edition</em> (JLS3).
853:             *
854:             * <p>If the receiver or the argument is a recovered type, the answer is always false,
855:             * unless the two types are identical or the argument is <code>java.lang.Object</code>.</p>
856:             *
857:             * @param type the type to check compatibility against
858:             * @return <code>true</code> if this type is subtype compatible with the
859:             * given type, and <code>false</code> otherwise
860:             * @since 3.1
861:             */
862:            public boolean isSubTypeCompatible(ITypeBinding type);
863:
864:            /**
865:             * Returns whether this type binding represents a top-level class,
866:             * interface, enum, or annotation type.
867:             * <p>
868:             * A top-level type is any type whose declaration does not occur within the
869:             * body of another type declaration. The set of top level types is disjoint
870:             * from the set of nested types.
871:             * </p>
872:             *
873:             * @return <code>true</code> if this type binding is for a top-level class,
874:             *   interface, enum, or annotation type, and <code>false</code> otherwise
875:             */
876:            public boolean isTopLevel();
877:
878:            /**
879:             * Returns whether this type binding represents a type variable.
880:             * Type variables bindings carry the type variable's bounds.
881:             * <p>
882:             * Note that type variables are distinct from capture bindings
883:             * (even though capture bindings are often depicted as synthetic
884:             * type variables); as such, {@link #isTypeVariable()} answers
885:             * <code>false</code> for capture bindings, and
886:             * {@link #isCapture()} answers <code>false</code> for type variables.
887:             * </p>
888:             *
889:             * @return <code>true</code> if this type binding is for a type variable,
890:             *   and <code>false</code> otherwise
891:             * @see #getName()
892:             * @see #getTypeBounds()
893:             * @since 3.1
894:             */
895:            public boolean isTypeVariable();
896:
897:            /**
898:             * Returns whether this wildcard type is an upper bound
899:             * ("extends") as opposed to a lower bound ("super").
900:             * Note that this property is only relevant for wildcards
901:             * that have a bound.
902:             *
903:             * @return <code>true</code> if this wildcard type has a bound that is
904:             * an upper bound, and <code>false</code> in all other cases
905:             * @see #isWildcardType()
906:             * @see #getBound()
907:             * @since 3.1
908:             */
909:            public boolean isUpperbound();
910:
911:            /**
912:             * Returns whether this type binding represents a wildcard type. A wildcard
913:             * type occus only as an argument to a parameterized type reference.
914:             * <p>
915:             * For example, a AST type like
916:             * <code>Collection&lt;? extends Object&gt;</code> typically resolves to a
917:             * parameterized type binding whose type argument is a wildcard type
918:             * with upper type bound <code>java.util.Object</code>.
919:             * </p>
920:             *
921:             * @return <code>true</code> if this object represents a wildcard type,
922:             *    and <code>false</code> otherwise
923:             * @since 3.1
924:             * @see #getBound()
925:             * @see #isUpperbound()
926:             */
927:            public boolean isWildcardType();
928:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.