Eclipse JDT
2.0

org.eclipse.jdt.core.dom
Interface ITypeBinding

All Superinterfaces:
IBinding

public interface ITypeBinding
extends IBinding

A type binding represents a class type, interface type, array type, a primitive type (including the special return type void), or the null type.

This interface is not intended to be implemented by clients.

Since:
2.0
See Also:
getDeclaredTypes()

Field Summary
 
Fields inherited from interface org.eclipse.jdt.core.dom.IBinding
METHOD, PACKAGE, TYPE, VARIABLE
 
Method Summary
 IVariableBinding[] getDeclaredFields()
          Returns a list of bindings representing all the fields declared as members of this class or interface.
 IMethodBinding[] getDeclaredMethods()
          Returns a list of method bindings representing all the methods and constructors declared for this class or interface.
 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 classes and interfaces declared as members of this class or interface type.
 ITypeBinding getDeclaringClass()
          Returns the type binding representing the class or interface 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[] getInterfaces()
          Returns a list of type bindings representing the direct superinterfaces of the class or interface represented by this type binding.
 int getModifiers()
          Returns the compiled modifiers for this class or interface binding.
 String getName()
          Returns the unqualified name of the type represented by this binding.
 IPackageBinding getPackage()
          Returns the binding for the package in which this class or interface is declared.
 ITypeBinding getSuperclass()
          Returns the type binding for the superclass of the type represented by this class binding.
 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 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 or interface.
 boolean isMember()
          Returns whether this type binding represents a member class or interface.
 boolean isNested()
          Returns whether this type binding represents a nested class or interface.
 boolean isNullType()
          Returns whether this type binding represents the null type.
 boolean isPrimitive()
          Returns whether this type binding represents a primitive type.
 boolean isTopLevel()
          Returns whether this type binding represents a top-level class or interface.
 
Methods inherited from interface org.eclipse.jdt.core.dom.IBinding
equals, getKey, getKind, isDeprecated, isSynthetic, toString
 

Method Detail

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.

The set of primitive types is mutually exclusive with the sets of array types, with the sets of class and interface types, and with the null type.

Returns:
true if this type binding is for a primitive type, and false otherwise
See Also:
isArray(), isClass(), isInterface()

isNullType

public boolean isNullType()
Returns whether this type binding represents the null type.

The null type is the type of a NullLiteral node.

The null type is mutually exclusive with the sets of array types, with the sets of class and interface types, and with the set of primitive types .

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.

The set of array types is mutually exclusive with the sets of primitive types and with the sets of class and interface types.

Returns:
true if this type binding is for an array type, and false otherwise
See Also:
isClass(), isInterface(), isPrimitive()

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.

The set of class types is mutually exclusive with the sets of primive types, array types, interface types, and the null type.

Returns:
true if this object represents a class, and false otherwise
See Also:
isArray(), isInterface(), isPrimitive()

isInterface

public boolean isInterface()
Returns whether this type binding represents an interface type.

The set of interface types is mutually exclusive with the sets of primive types, array types, class types, and the null type.

Returns:
true if this object represents an interface, and false otherwise
See Also:
isArray(), isClass(), isPrimitive()

getName

public String getName()
Returns the unqualified name of the type represented by this binding.

For named classes and interfaces, this is the simple name of the type. For primitive types, the name is the keyword for the primitive type. For array types, the name is the unqualified name of the component type 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".

Specified by:
getName in interface IBinding
Returns:
the unqualified name of the type represented by this binding, an empty string this is an anonymous type, or "null" for the null type

getPackage

public IPackageBinding getPackage()
Returns the binding for the package in which this class or interface is declared.

Returns:
the binding for the package in which this class or interface is declared, or null if this type binding represents a primitive type, an array type, or the null type.

getDeclaringClass

public ITypeBinding getDeclaringClass()
Returns the type binding representing the class or interface that declares this binding.

The declaring class of a member class or interface is the class or interface 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, and top-level types have no declaring class.

Returns:
the binding of the class or interface 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.

If this type binding represents an interface, an array type, a primitive type, or the null type, then null is returned.

Returns:
the superclass of the class represented by this type binding, or null if none

getInterfaces

public ITypeBinding[] getInterfaces()
Returns a list of type bindings representing the direct superinterfaces of the class or interface represented by this type binding.

If this type binding represents a class, 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 class.

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 implements no interfaces, or the interface extends no interfaces, or if this type binding represents an array type, a primitive type, or the null type, this method returns an array of length 0.

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

getModifiers

public int getModifiers()
Returns the compiled modifiers for this class or interface 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 bit-wise or of Modifier constants
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 or interface.

A top-level type is any class or interface whose declaration does not occur within the body of another class or interface. 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 or interface, and false otherwise

isNested

public boolean isNested()
Returns whether this type binding represents a nested class or interface.

A nested type is any class or interface whose declaration occurs within the body of another class or interface. 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 or interface, and false otherwise

isMember

public boolean isMember()
Returns whether this type binding represents a member class or interface.

A member type is any class or interface declared as a member of another class or interface. 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 or interface, and false otherwise

isLocal

public boolean isLocal()
Returns whether this type binding represents a local class or interface.

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

Returns:
true if this type binding is for a local class or interface, 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 classes and interfaces declared as members of this class or interface type. These include public, protected, default (package-private) access, and private classes and interfaces declared by the class, but excludes inherited classes and interfaces. Returns an empty list if the class declares no classes or interfaces as members, or if this type binding represents an array type, a primitive type, 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 or interface. 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 or interface declares no fields, or if this type binding represents a primitive type or an array type (the implicit length field of array types is not considered to be a declared field). 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 or is an array type, primitive type, or the null type

getDeclaredMethods

public IMethodBinding[] getDeclaredMethods()
Returns a list of method bindings representing all the methods and constructors declared for this class or interface. 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 or interface declares no methods or constructors, or if this type binding represents an array type or a primitive type. The resulting bindings are in no particular order.

Returns:
the list of method bindings for the methods and constructors declared by this class or interface, 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 primitive types, the null type, array types, and classes and interfaces whose information came from a pre-compiled binary class file.

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

Eclipse JDT
2.0

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