Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse JDT Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.jdt.core.dom
Interface ITypeBinding

All Superinterfaces:
  IBinding

public interface ITypeBinding
extends IBinding

A type binding represents fully-resolved type. There are a number of different kinds of type bindings:

- a class - represents the class declaration; possibly with type parameters
- an interface - represents the class declaration; possibly with type parameters
- an enum - represents the enum declaration (enum types do not have have type parameters)
- an annotation - represents the annotation type declaration (annotation types do not have have type parameters)
- an array type - array types are referenced but not explicitly declared
- a primitive type (including the special return type `void`) - primitive types are referenced but not explicitly declared
- the null type - this is the special type of `null`
- a type variable - represents the declaration of a type variable; possibly with type bounds
- a parameterized type reference - represents a reference to a parameterized type with type arguments (which may include wildcards)
- a raw type reference - represents a (legacy) reference to a parameterized type without any type arguments
- a wildcard type - represents a wild card used as a type argument in a parameterized type reference

This interface is not intended to be implemented by clients.

Note: Support for new language features proposed for the upcoming 1.5 release of J2SE is tentative and subject to change.

Since:
  2.0
See Also:
  `getDeclaredTypes()`

Field Summary

Fields inherited from interface org.eclipse.jdt.core.dom.IBinding
`METHOD, PACKAGE, TYPE, VARIABLE`

Method Summary
`String` | `getBinaryName()` Returns the binary name of this type binding.
`ITypeBinding` | `getBound()` Returns the bound of this wildcard type if it has one.
`IVariableBinding[]` | `getDeclaredFields()` Returns a list of bindings representing all the fields declared as members of this class, interface, or enum type.
`IMethodBinding[]` | `getDeclaredMethods()` Returns a list of method bindings representing all the methods and constructors declared for this class, interface, or enum.
`int` | `getDeclaredModifiers()` Returns the declared modifiers for this class or interface binding as specified in the original source declaration of the class or interface.
`ITypeBinding[]` | `getDeclaredTypes()` Returns a list of type bindings representing all the types declared as members of this class, interface, or enum type.
`ITypeBinding` | `getDeclaringClass()` Returns the type binding representing the class, interface, or enum that declares this binding.
`int` | `getDimensions()` Returns the dimensionality of this array type, or `0` if this is not an array type binding.
`ITypeBinding` | `getElementType()` Returns the binding representing the element type of this array type, or `null` if this is not an array type binding.
`ITypeBinding` | `getErasure()` Returns the erasure of this type reference.
`ITypeBinding[]` | `getInterfaces()` Returns a list of type bindings representing the direct superinterfaces of the class, interface, or enum type represented by this type binding.
`int` | `getModifiers()` Returns the compiled modifiers for this class, interface, enum, or annotation type binding.
`String` | `getName()` Returns the unqualified name of the type represented by this binding if it has one.
`IPackageBinding` | `getPackage()` Returns the binding for the package in which this type is declared.
`String` | `getQualifiedName()` Returns the fully qualified name of the type represented by this binding if it has one.
`ITypeBinding` | `getSuperclass()` Returns the type binding for the superclass of the type represented by this class binding.
`ITypeBinding[]` | `getTypeArguments()` Returns the type arguments of the parameterized type reference.
`ITypeBinding[]` | `getTypeBounds()` Returns the type bounds of this type variable.
`ITypeBinding[]` | `getTypeParameters()` Returns the type parameters of this class or interface type binding.
`boolean` | `isAnnotation()` Returns whether this type binding represents an annotation type.
`boolean` | `isAnonymous()` Returns whether this type binding represents an anonymous class.
`boolean` | `isArray()` Returns whether this type binding represents an array type.
`boolean` | `isClass()` Returns whether this type binding represents a class type.
`boolean` | `isEnum()` Returns whether this type binding represents an enum type.
`boolean` | `isFromSource()` Returns whether this type binding originated in source code.
`boolean` | `isInterface()` Returns whether this type binding represents an interface type.
`boolean` | `isLocal()` Returns whether this type binding represents a local class.
`boolean` | `isMember()` Returns whether this type binding represents a member class or interface.
`boolean` | `isNested()` Returns whether this type binding represents a nested class, interface, enum, or annotation type.
`boolean` | `isNullType()` Returns whether this type binding represents the null type.
`boolean` | `isParameterizedType()` Returns whether this type binding represents a parameterized type reference.
`boolean` | `isPrimitive()` Returns whether this type binding represents a primitive type.
`boolean` | `isRawType()` Returns whether this type binding represents a raw type reference.
`boolean` | `isTopLevel()` Returns whether this type binding represents a top-level class, interface, enum, or annotation type.
`boolean` | `isTypeVariable()` Returns whether this type binding represents a type variable.
`boolean` | `isUpperbound()` Returns whether this wildcard type is an upper bound ("extends") as opposed to a lower bound ("super").
`boolean` | `isWildcardType()` Returns whether this type binding represents a wildcard type.

Methods inherited from interface org.eclipse.jdt.core.dom.IBinding
`equals, getKey, getKind, isDeprecated, isSynthetic, toString`

Method Detail

### getBinaryName

    public String getBinaryName()

  Returns the binary name of this type binding. The binary name of a class is defined in the Java Language Specification 2nd edition, section 13.1.

  Note that in some cases, the binary name may be unavailable. This may happen, for example, for a local type declared in unreachable code.

  Returns:
    the binary name of this type, or `null` if the binary name is unknown
  Since:
    3.0

### isPrimitive

    public boolean isPrimitive()

  Returns whether this type binding represents a primitive type.

  There are nine predefined type bindings to represent the eight primitive types and `void`. These have the same names as the primitive types that they represent, namely boolean, byte, char, short, int, long, float, and double, and void.

  Returns:
    `true` if this type binding is for a primitive type, and `false` otherwise

### isNullType

    public boolean isNullType()

  Returns whether this type binding represents the null type.

  The null type is the type of a `NullLiteral` node.

  Returns:
    `true` if this type binding is for the null type, and `false` otherwise

### isArray

    public boolean isArray()

  Returns whether this type binding represents an array type.

  Returns:
    `true` if this type binding is for an array type, and `false` otherwise
  See Also:
    `getElementType()`, `getDimensions()`

### getElementType

    public ITypeBinding getElementType()

  Returns the binding representing the element type of this array type, or `null` if this is not an array type binding. The element type of an array is never itself an array type.

  Returns:
    the element type binding, or `null` if this is not an array type

### getDimensions

    public int getDimensions()

  Returns the dimensionality of this array type, or `0` if this is not an array type binding.

  Returns:
    the number of dimension of this array type binding, or `0` if this is not an array type

### isClass

    public boolean isClass()

  Returns whether this type binding represents a class type.

  Returns:
    `true` if this object represents a class, and `false` otherwise

### isInterface

    public boolean isInterface()

  Returns whether this type binding represents an interface type.

  Returns:
    `true` if this object represents an interface, and `false` otherwise

### isEnum

    public boolean isEnum()

  Returns whether this type binding represents an enum type.

  Note: Support for new language features proposed for the upcoming 1.5 release of J2SE is tentative and subject to change.

  Returns:
    `true` if this object represents an enum type, and `false` otherwise
  Since:
    3.0

### isAnnotation

    public boolean isAnnotation()

  Returns whether this type binding represents an annotation type.

  Note: Support for new language features proposed for the upcoming 1.5 release of J2SE is tentative and subject to change.

  Returns:
    `true` if this object represents an annotation type, and `false` otherwise
  Since:
    3.0

### getTypeParameters

    public ITypeBinding[] getTypeParameters()

  Returns the type parameters of this class or interface type binding.

  Note that type parameters only occur on the declaring class or interface; e.g., `Collection<T>`. Do not confuse them with type arguments which only occur on references; e.g., `Collection<String>`.

  Note: Support for new language features proposed for the upcoming 1.5 release of J2SE is tentative and subject to change.

  Returns:
    the list of binding for the type variables for the type parameters of this type, or otherwise the empty list
  Since:
    3.0
  See Also:
    `isTypeVariable()`

### isTypeVariable

    public boolean isTypeVariable()

  Returns whether this type binding represents a type variable. Type variables bindings carry the type variable's bounds.

  Note: Support for new language features proposed for the upcoming 1.5 release of J2SE is tentative and subject to change.

  Returns:
    `true` if this type binding is for a type variable, and `false` otherwise
  Since:
    3.0
  See Also:
    `getTypeBounds()`

### getTypeBounds

    public ITypeBinding[] getTypeBounds()

  Returns the type bounds of this type variable.

  Note: Support for new language features proposed for the upcoming 1.5 release of J2SE is tentative and subject to change.

  Returns:
    the list of type bindings for this type variable, or otherwise the empty list
  Since:
    3.0
  See Also:
    `isTypeVariable()`

### isParameterizedType

    public boolean isParameterizedType()

  Returns whether this type binding represents a parameterized type reference.

  For example, a AST type like `Collection<String>` typically resolves to a parameterized type binding whose erasure is a type binding for the class `java.util.Collection` and whose type argument is a type binding for the class `java.util.Collection`.

  Note: Support for new language features proposed for the upcoming 1.5 release of J2SE is tentative and subject to change.

  Returns:
    `true` if this object represents a parameterized type reference, and `false` otherwise
  Since:
    3.0
  See Also:
    `getTypeArguments()`, `getErasure()`

### getTypeArguments

    public ITypeBinding[] getTypeArguments()

  Returns the type arguments of the parameterized type reference.

  Note that type arguments only occur on type references; e.g., `Collection<String>`. Do not confuse with type parameters which only occur on the declaring class or interface; e.g., `Collection<T>`.

  Note: Support for new language features proposed for the upcoming 1.5 release of J2SE is tentative and subject to change.

  Returns:
    the list of type bindings for the type arguments of this parameterized type, or otherwise the empty list
  Since:
    3.0

### getErasure

    public ITypeBinding getErasure()

  Returns the erasure of this type reference. For a parameterized type reference or a raw type reference, returns the type binding for the class or interface where the referenced type is declared. Returns this type binding for types other than parameterized types.

  Note: Support for new language features proposed for the upcoming 1.5 release of J2SE is tentative and subject to change.

  Returns:
    the erasure type
  Since:
    3.0
  See Also:
    `isRawType()`, `isParameterizedType()`

### isRawType

    public boolean isRawType()

  Returns whether this type binding represents a raw type reference. A raw type is a unparameterized (legacy) reference to a type declared with type parameters.

  For example, a AST type like `Collection` typically resolves to a raw type binding whose erasure is a type binding for the class `java.util.Collection`.

  Note: Support for new language features proposed for the upcoming 1.5 release of J2SE is tentative and subject to change.

  Returns:
    `true` if this object represents a raw type, and `false` otherwise
  Since:
    3.0
  See Also:
    `getErasure()`

### isWildcardType

    public boolean isWildcardType()

  Returns whether this type binding represents a wildcard type. A wildcard type occus only as an argument to a parameterized type reference.

  For example, a AST type like `Collection<? extends Object>` typically resolves to a parameterized type binding whose type argument is a wildcard type with upper type bound `java.util.Object/code>.`

  Note: Support for new language features proposed for the upcoming 1.5 release of J2SE is tentative and subject to change.

  Returns:
    `true` if this object represents a wildcard type, and `false` otherwise
  Since:
    3.0
  See Also:
    `getBound()`, `isUpperbound()`

### getBound

    public ITypeBinding getBound()

  Returns the bound of this wildcard type if it has one. Returns `null` if this is not a wildcard type.

  Note: Support for new language features proposed for the upcoming 1.5 release of J2SE is tentative and subject to change.

  Returns:
    the bound of this wildcard type, or `null` if none
  Since:
    3.0
  See Also:
    `isWildcardType()`, `isUpperbound()`

### isUpperbound

    public boolean isUpperbound()

  Returns whether this wildcard type is an upper bound ("extends") as opposed to a lower bound ("super"). Note that this property is only relevant for wildcards that have a bound.

  Note: Support for new language features proposed for the upcoming 1.5 release of J2SE is tentative and subject to change.

  Returns:
    `true` if this wildcard type has a bound that is an upper bound, and `false` in all other cases
  Since:
    3.0
  See Also:
    `isWildcardType()`, `getBound()`

### getName

    public String getName()

  Returns the unqualified name of the type represented by this binding if it has one.

  For named classes, interfaces, enums, and annotation types, this is the simple name of the type; if the type is parameterized, the name is followed by the simple names of the type variables surrounded by "<>" and separated by "," (the type bounds are not included). For primitive types, the name is the keyword for the primitive type. For array types, the name is the name of the component type (as computed by this method) followed by "[]". If this represents an anonymous class, it returns an empty string (note that it is impossible to have an array type with an anonymous class as element type). For the null type, it returns "null". For type variables, this is the name of the type variable. For parameterized type references, this is the simple name of the erasure type followed by the names of the type arguments (as computed by this method) surrounded by "<>" and separated by ",". For raw type references, this is the simple name of the erasure type. For wildcard types, this is "?" followed by the name of the bound (as computed by this method) when present.

  Specified by:
    `getName` in interface `IBinding`
  Returns:
    the unqualified name of the type represented by this binding, or the empty string if it has none
  See Also:
    `getQualifiedName()`

### getPackage

    public IPackageBinding getPackage()

  Returns the binding for the package in which this type is declared.

  Returns:
    the binding for the package in which this class, interface, enum, or annotation type is declared, or `null` if this type binding represents a primitive type, an array type, the null type, a type variable, a parameterized type reference, a raw type reference, or a wildcard type

### getDeclaringClass

    public ITypeBinding getDeclaringClass()

  Returns the type binding representing the class, interface, or enum that declares this binding.

  The declaring class of a member class, interface, enum, annotation type is the class, interface, or enum type of which it is a member. The declaring class of a local class or interface (including anonymous classes) is the innermost class or interface containing the expression or statement in which this type is declared. Array types, primitive types, the null type, top-level types, type variables, parameterized type references, raw type references, and wildcard types have no declaring class.

  Returns:
    the binding of the type that declares this type, or `null` if none

### getSuperclass

    public ITypeBinding getSuperclass()

  Returns the type binding for the superclass of the type represented by this class binding.

  If this type binding represents any class other than the class `java.lang.Object`, then the type binding for the direct superclass of this class is returned. If this type binding represents the class `java.lang.Object`, then `null` is returned.

  Loops that ascend the class hierarchy need a suitable termination test. Rather than test the superclass for `null`, it is more transparent to check whether the class is `Object`, by comparing whether the class binding is identical to `ast.resolveWellKnownType("java.lang.Object")`.

  If this type binding represents an interface, an array type, a primitive type, the null type, a type variable, an enum type, an annotation type, a parameterized type reference, a raw type reference, or a wildcard type, then `null` is returned.

  Returns:
    the superclass of the class represented by this type binding, or `null` if none
  See Also:
    `AST.resolveWellKnownType(String)`

### getInterfaces

    public ITypeBinding[] getInterfaces()

  Returns a list of type bindings representing the direct superinterfaces of the class, interface, or enum type represented by this type binding.

  If this type binding represents a class or enum type, the return value is an array containing type bindings representing all interfaces directly implemented by this class. The number and order of the interface objects in the array corresponds to the number and order of the interface names in the `implements` clause of the original declaration of this type.

  If this type binding represents an interface, the array contains type bindings representing all interfaces directly extended by this interface. The number and order of the interface objects in the array corresponds to the number and order of the interface names in the `extends` clause of the original declaration of this interface.

  If the class or enum implements no interfaces, or the interface extends no interfaces, or if this type binding represents an array type, a primitive type, the null type, a type variable, an annotation type, a parameterized type reference, a raw type reference, or a wildcard type, this method returns an array of length 0.

  Returns:
    the list of type bindings for the interfaces extended by this class or enum, or interfaces extended by this interface, or otherwise the empty list

### getModifiers

    public int getModifiers()

  Returns the compiled modifiers for this class, interface, enum, or annotation type binding. The result may not correspond to the modifiers as declared in the original source, since the compiler may change them (in particular, for inner class emulation). The `getDeclaredModifiers` method should be used if the original modifiers are needed. Returns 0 if this type does not represent a class or interface.

  Specified by:
    `getModifiers` in interface `IBinding`
  Returns:
    the compiled modifiers for this type binding or 0 if this type does not represent a class, interface, enum, or annotation type
  See Also:
    `getDeclaredModifiers()`

### getDeclaredModifiers

    public int getDeclaredModifiers()

  Returns the declared modifiers for this class or interface binding as specified in the original source declaration of the class or interface. The result may not correspond to the modifiers in the compiled binary, since the compiler may change them (in particular, for inner class emulation). The `getModifiers` method should be used if the compiled modifiers are needed. Returns -1 if this type does not represent a class or interface.

  Returns:
    the bit-wise or of `Modifier` constants
  See Also:
    `getModifiers()`, `Modifier`

### isTopLevel

    public boolean isTopLevel()

  Returns whether this type binding represents a top-level class, interface, enum, or annotation type.

  A top-level type is any type whose declaration does not occur within the body of another type declaration. The set of top level types is disjoint from the set of nested types.

  Returns:
    `true` if this type binding is for a top-level class, interface, enum, or annotation type, and `false` otherwise

### isNested

    public boolean isNested()

  Returns whether this type binding represents a nested class, interface, enum, or annotation type.

  A nested type is any type whose declaration occurs within the body of another. The set of nested types is disjoint from the set of top-level types. Nested types further subdivide into member types, local types, and anonymous types.

  Returns:
    `true` if this type binding is for a nested class, interface, enum, or annotation type, and `false` otherwise

### isMember

    public boolean isMember()

  Returns whether this type binding represents a member class or interface.

  A member type is any type declared as a member of another type. A member type is a subspecies of nested type, and mutually exclusive with local types.

  Returns:
    `true` if this type binding is for a member class, interface, enum, or annotation type, and `false` otherwise

### isLocal

    public boolean isLocal()

  Returns whether this type binding represents a local class.

  A local class is any nested class or enum type not declared as a member of another class or interface. A local class is a subspecies of nested type, and mutually exclusive with member types. Note that anonymous classes are a subspecies of local classes.

  Also note that interfaces and annotation types cannot be local.

  Returns:
    `true` if this type binding is for a local class or enum type, and `false` otherwise

### isAnonymous

    public boolean isAnonymous()

  Returns whether this type binding represents an anonymous class.

  An anonymous class is a subspecies of local class, and therefore mutually exclusive with member types. Note that anonymous classes have no name (`getName` returns the empty string).

  Returns:
    `true` if this type binding is for an anonymous class, and `false` otherwise

### getDeclaredTypes

    public ITypeBinding[] getDeclaredTypes()

  Returns a list of type bindings representing all the types declared as members of this class, interface, or enum type. These include public, protected, default (package-private) access, and private classes, interfaces, enum types, and annotation types declared by the type, but excludes inherited types. Returns an empty list if the type declares no type members, or if this type binding represents an array type, a primitive type, a wildcard type, a parameterized type reference, a raw type reference, or the null type. The resulting bindings are in no particular order.

  Returns:
    the list of type bindings for the member types of this type, or the empty list if this type does not have member types

### getDeclaredFields

    public IVariableBinding[] getDeclaredFields()

  Returns a list of bindings representing all the fields declared as members of this class, interface, or enum type. These include public, protected, default (package-private) access, and private fields declared by the class, but excludes inherited fields. Synthetic fields may or may not be included. Returns an empty list if the class, interface, or enum declares no fields, and for other kinds of type bindings that do not directly have members. The resulting bindings are in no particular order.

  Returns:
    the list of bindings for the field members of this type, or the empty list if this type does not have field members

### getDeclaredMethods

    public IMethodBinding[] getDeclaredMethods()

  Returns a list of method bindings representing all the methods and constructors declared for this class, interface, or enum. These include public, protected, default (package-private) access, and private methods. Synthetic methods and constructors may or may not be included. Returns an empty list if the class, interface, or enum declares no methods or constructors, or if this type binding represents some other kind of type bindings. The resulting bindings are in no particular order.

  Returns:
    the list of method bindings for the methods and constructors declared by this class, interface, or enum type, or the empty list if this type does not declare any methods or constructors

### isFromSource

    public boolean isFromSource()

  Returns whether this type binding originated in source code. Returns `false` for all primitive types, the null type, array types, and for all classes, interfaces, enums, annotation types, type variables, parameterized type references, raw type references, and wildcard types, whose information came from a pre-compiled binary class file.

  Returns:
    `true` if the type is in source code, and `false` otherwise

### getQualifiedName

    public String getQualifiedName()

  Returns the fully qualified name of the type represented by this binding if it has one.
  - For top-level types, the fully qualified name is the name of the type (as computed by `getName()`) preceded by the package name (or unqualified if in a default package) and a ".". Example: `"java.lang.String"`.
  - For members of top-level types, the fully qualified name is the simple name of the type preceded by the fully qualified name of the enclosing type (as computed by this method) and a ".". Example: `"java.io.ObjectInputStream.GetField"`.
  - For primitive types, the fully qualified name is the keyword for the primitive type. Example: `"int"`.
  - For array types whose component type has a fully qualified name, the fully qualified name is the fully qualified name of the component type (as computed by this method) followed by "[]". Example: `"java.lang.String[]"`.
  - For the null type, the fully qualified name is the string "null".
  - Local types (including anonymous classes) and members of local types do not have a fully qualified name. For these types, and array types thereof, this method returns an empty string.
  - For type variables, the fully qualified name is just the name of the type variable (type bounds are not included). Example: `"X"`.
  - For raw type references, the fully qualified name is the fully qualified name of the type but with the type parameters omitted. Example: `"java.util.Collection"`.
  - For parameterized type references, the fully qualified name is the fully qualified name of the erasure type followed by the fully qualified names of the type arguments surrounded by "<>" and separated by ",". Example: `"java.util.Collection<java.lang.String>"`.
  - For wildcard types, the fully qualified name is "?" followed by the fully qualified name of the bound (as computed by this method) when present. Example: `"? extends java.lang.Object"`.

  Returns:
    the fully qualified name of the type represented by this binding, or the empty string if it has none
  Since:
    2.1
  See Also:
    `getName()`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse JDT Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) IBM Corp. and others 2000, 2004. All Rights Reserved.