Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse JDT
Release 3.5

org.eclipse.jdt.core.dom
Interface IBinding

All Known Subinterfaces:
IAnnotationBinding, IMemberValuePairBinding, IMethodBinding, IPackageBinding, ITypeBinding, IVariableBinding

public interface IBinding

A binding represents a named entity in the Java language. The world of bindings provides an integrated picture of the structure of the program as seen from the compiler's point of view. This interface declare protocol common to the various different kinds of named entities in the Java language: packages, types, fields, methods, constructors, and local variables.

Since:
2.0
See Also:
IPackageBinding, ITypeBinding, IVariableBinding, IMethodBinding, IAnnotationBinding, IMemberValuePairBinding
Restriction:
This interface is not intended to be implemented by clients.

Field Summary
static int ANNOTATION
          Kind constant (value 5) indicating an annotation binding.
static int MEMBER_VALUE_PAIR
          Kind constant (value 6) indicating a member value pair binding.
static int METHOD
          Kind constant (value 4) indicating a method or constructor binding.
static int PACKAGE
          Kind constant (value 1) indicating a package binding.
static int TYPE
          Kind constant (value 2) indicating a type binding.
static int VARIABLE
          Kind constant (value 3) indicating a field or local variable binding.
 
Method Summary
 boolean equals ( Object obj)
          There is no special definition of equality for bindings; equality is simply object identity.
  IAnnotationBinding[] getAnnotations ()
          Return the resolved annotations associated with this binding.
  IJavaElement getJavaElement ()
          Returns the Java element that corresponds to this binding.
  String getKey ()
          Returns the key for this binding.
 int getKind ()
          Returns the kind of bindings this is.
 int getModifiers ()
          Returns the modifiers for this binding.
  String getName ()
          Returns the name of this binding.
 boolean isDeprecated ()
          Return whether this binding is for something that is deprecated.
 boolean isEqualTo ( IBinding binding)
          Returns whether this binding has the same key as that of the given binding.
 boolean isRecovered ()
          Return whether this binding is created because the bindings recovery is enabled.
 boolean isSynthetic ()
          Returns whether this binding is synthetic.
  String toString ()
          Returns a string representation of this binding suitable for debugging purposes only.
 

Field Detail

PACKAGE

static final int PACKAGE
Kind constant (value 1) indicating a package binding. Bindings of this kind can be safely cast to IPackageBinding.

See Also:
getKind(), IPackageBinding, Constant Field Values

TYPE

static final int TYPE
Kind constant (value 2) indicating a type binding. Bindings of this kind can be safely cast to ITypeBinding.

See Also:
getKind(), ITypeBinding, Constant Field Values

VARIABLE

static final int VARIABLE
Kind constant (value 3) indicating a field or local variable binding. Bindings of this kind can be safely cast to IVariableBinding.

See Also:
getKind(), IVariableBinding, Constant Field Values

METHOD

static final int METHOD
Kind constant (value 4) indicating a method or constructor binding. Bindings of this kind can be safely cast to IMethodBinding.

See Also:
getKind(), IMethodBinding, Constant Field Values

ANNOTATION

static final int ANNOTATION
Kind constant (value 5) indicating an annotation binding. Bindings of this kind can be safely cast to IAnnotationBinding.

Since:
3.2
See Also:
getKind(), IAnnotationBinding, Constant Field Values

MEMBER_VALUE_PAIR

static final int MEMBER_VALUE_PAIR
Kind constant (value 6) indicating a member value pair binding. Bindings of this kind can be safely cast to IMemberValuePairBinding.

Since:
3.2
See Also:
getKind(), IMemberValuePairBinding, Constant Field Values
Method Detail

getAnnotations


IAnnotationBinding[] getAnnotations()
Return the resolved annotations associated with this binding.
  • Package bindings - these are annotations on a package declaration.
  • Type bindings - these are annotations on a class, interface, enum, or annotation type declaration. The result is the same regardless of whether the type is parameterized.
  • Method bindings - these are annotations on a method or constructor declaration. The result is the same regardless of whether the method is parameterized.
  • Variable bindings - these are annotations on a field, enum constant, or formal parameter declaration.
  • Annotation bindings - an empty array is always returned
  • Member value pair bindings - an empty array is always returned

Returns:
the list of resolved annotations, or the empty list if there are no annotations associated with the object
Since:
3.2

getKind

int getKind()
Returns the kind of bindings this is. That is one of the kind constants: PACKAGE, TYPE, VARIABLE, METHOD, ANNOTATION, or MEMBER_VALUE_PAIR.

Note that additional kinds might be added in the future, so clients should not assume this list is exhaustive and should program defensively, e.g. by having a reasonable default in a switch statement.

Returns:
one of the kind constants

getName


String getName()
Returns the name of this binding. Details of the name are specified with each specific kind of binding.

Returns:
the name of this binding

getModifiers

int getModifiers()
Returns the modifiers for this binding.

Note that deprecated is not included among the modifiers. Use isDeprecated to find out whether a binding is deprecated.

Returns:
the bit-wise or of Modifier constants
See Also:
Modifier

isDeprecated

boolean isDeprecated()
Return whether this binding is for something that is deprecated. A deprecated class, interface, field, method, or constructor is one that is marked with the 'deprecated' tag in its Javadoc comment.

Returns:
true if this binding is deprecated, and false otherwise

isRecovered

boolean isRecovered()
Return whether this binding is created because the bindings recovery is enabled. This binding is considered to be incomplete. Its internal state might be incomplete.

Returns:
true if this binding is a recovered binding, and false otherwise
Since:
3.3

isSynthetic

boolean isSynthetic()
Returns whether this binding is synthetic. A synthetic binding is one that was made up by the compiler, rather than something declared in the source code. Note that default constructors (the 0-argument constructor that the compiler generates for class declarations with no explicit constructors declarations) are not generally considered synthetic (although they may be if the class itself is synthetic). But see IMethodBinding.isDefaultConstructor for cases where the compiled-generated default constructor can be recognized instead.

Returns:
true if this binding is synthetic, and false otherwise
See Also:
IMethodBinding.isDefaultConstructor()

getJavaElement


IJavaElement getJavaElement()
Returns the Java element that corresponds to this binding. Returns null if this binding has no corresponding Java element.

For array types, this method returns the Java element that corresponds to the array's element type. For raw and parameterized types, this method returns the Java element of the erasure. For annotations, this method returns the Java element of the annotation (i.e. an IAnnotation).

Here are the cases where a null should be expected:

  • primitive types, including void
  • null type
  • wildcard types
  • capture types
  • array types of any of the above
  • the "length" field of an array type
  • the default constructor of a source class
  • the constructor of an anonymous class
  • member value pairs
For all other kind of type, method, variable, annotation and package bindings, this method returns non-null.

Returns:
the Java element that corresponds to this binding, or null if none
Since:
3.1

getKey


String getKey()
Returns the key for this binding.

Within a connected cluster of bindings (for example, all bindings reachable from a given AST), each binding will have a distinct keys. The keys are generated in a manner that is predictable and as stable as possible. This last property makes these keys useful for comparing bindings between disconnected clusters of bindings (for example, the bindings between the "before" and "after" ASTs of the same compilation unit).

The exact details of how the keys are generated is unspecified. However, it is a function of the following information:

  • packages - the name of the package (for an unnamed package, some internal id)
  • classes or interfaces - the VM name of the type and the key of its package
  • array types - the key of the component type and number of dimensions
  • primitive types - the name of the primitive type
  • fields - the name of the field and the key of its declaring type
  • methods - the name of the method, the key of its declaring type, and the keys of the parameter types
  • constructors - the key of its declaring class, and the keys of the parameter types
  • local variables - the name of the local variable, the index of the declaring block relative to its parent, the key of its method
  • local types - the name of the type, the index of the declaring block relative to its parent, the key of its method
  • anonymous types - the occurence count of the anonymous type relative to its declaring type, the key of its declaring type
  • enum types - treated like classes
  • annotation types - treated like interfaces
  • type variables - the name of the type variable and the key of the generic type or generic method that declares that type variable
  • wildcard types - the key of the optional wildcard type bound
  • capture type bindings - the key of the wildcard captured
  • generic type instances - the key of the generic type and the keys of the type arguments used to instantiate it, and whether the instance is explicit (a parameterized type reference) or implicit (a raw type reference)
  • generic method instances - the key of the generic method and the keys of the type arguments used to instantiate it, and whether the instance is explicit (a parameterized method reference) or implicit (a raw method reference)
  • members of generic type instances - the key of the generic type instance and the key of the corresponding member in the generic type
  • annotations - the key of the annotated element and the key of the annotation type

Note that the key for member value pair bindings is not yet implemented. This returns null for this kind of bindings.
Recovered bindings have a unique key.

Returns:
the key for this binding

equals

boolean equals(
Object obj)
There is no special definition of equality for bindings; equality is simply object identity. Within the context of a single cluster of bindings, each binding is represented by a distinct object. However, between different clusters of bindings, the binding objects may or may not be different; in these cases, the client should compare bindings using isEqualTo(IBinding), which checks their keys.

Overrides:
equals in class Object
Parameters:
obj -
Returns:

isEqualTo

boolean isEqualTo(
IBinding binding)
Returns whether this binding has the same key as that of the given binding. Within the context of a single cluster of bindings, each binding is represented by a distinct object. However, between different clusters of bindings, the binding objects may or may not be different objects; in these cases, the binding keys are used where available.

Parameters:
binding - the other binding, or null
Returns:
true if the given binding is the identical object as this binding, or if the keys of both bindings are the same string; false if the given binding is null, or if the bindings do not have the same key, or if one or both of the bindings have no key
Since:
3.1
See Also:
getKey()

toString


String toString()
Returns a string representation of this binding suitable for debugging purposes only.

Overrides:
toString in class Object
Returns:
a debug string

Eclipse JDT
Release 3.5

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

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire