Package org.eclipse.jdt.core
Class BindingKey
- java.lang.Object
-
- org.eclipse.jdt.core.BindingKey
-
public final class BindingKey extends java.lang.ObjectUtility class to decode or create a binding key.This class is not intended to be subclassed by clients.
- Since:
- 3.1
- See Also:
IBinding.getKey()
-
-
Constructor Summary
Constructors Constructor Description BindingKey(java.lang.String key)Creates a new binding key.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.lang.StringcreateArrayTypeBindingKey(java.lang.String typeKey, int arrayDimension)Creates a new array type binding key from the given type binding key and the given array dimension.static java.lang.StringcreateParameterizedTypeBindingKey(java.lang.String genericTypeKey, java.lang.String[] argumentTypeKeys)Creates a new parameterized type binding key from the given generic type binding key and the given argument type binding keys.static java.lang.StringcreateTypeBindingKey(java.lang.String typeName)Creates a new type binding key from the given type name.static java.lang.StringcreateTypeVariableBindingKey(java.lang.String typeVariableName, java.lang.String declaringKey)Creates a new type variable binding key from the given type variable name and the given declaring key.static java.lang.StringcreateWilcardTypeBindingKey(java.lang.String typeKey, char kind)Deprecated.This method is missing crucial information necessary for proper wildcard binding key creation.static java.lang.StringcreateWildcardTypeBindingKey(java.lang.String genericTypeKey, char boundKind, java.lang.String boundTypeKey, int rank)Creates a new wildcard type binding key from the given generic type binding key, the given wildcard kind (one ofSignature.C_STAR,Signature.C_SUPER, orSignature.C_EXTENDSthe given bound type binding key and the given rank.BindingKeygetDeclaringType()Returns the binding key of the declaring type of the element represented by this binding key.java.lang.String[]getThrownExceptions()Returns the thrown exception signatures of the element represented by this binding key.java.lang.String[]getTypeArguments()Returns the type argument signatures of the element represented by this binding key.booleanisParameterizedMethod()Returns whether this binding key represents a parameterized method, or if its declaring method is a parameterized method.booleanisParameterizedType()Returns whether this binding key represents a parameterized type, or if its declaring type is a parameterized type.booleanisRawType()Returns whether this binding key represents a raw type.java.lang.StringtoSignature()Transforms this binding key into a resolved signature.java.lang.StringtoString()
-
-
-
Method Detail
-
createArrayTypeBindingKey
public static java.lang.String createArrayTypeBindingKey(java.lang.String typeKey, int arrayDimension)Creates a new array type binding key from the given type binding key and the given array dimension.For example:
createArrayTypeBindingKey("Ljava/lang/Object;", 1) -> "[Ljava/lang/Object;" createArrayTypeBindingKey("I", 2) -> "[[I"- Parameters:
typeKey- the binding key of the given typearrayDimension- the given array dimension- Returns:
- a new array type binding key
-
createParameterizedTypeBindingKey
public static java.lang.String createParameterizedTypeBindingKey(java.lang.String genericTypeKey, java.lang.String[] argumentTypeKeys)Creates a new parameterized type binding key from the given generic type binding key and the given argument type binding keys. If the argument type keys array is empty, then a raw type binding key is created.For example:
createParameterizedTypeBindingKey( "Ljava/util/Map<TK;TV;>;", new String[] {"Ljava/lang/String;", "Ljava/lang/Object;"}) -> "Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;" createParameterizedTypeBindingKey( "Ljava/util/List<TE;>;", new String[] {}) -> "Ljava/util/List<>;"- Parameters:
genericTypeKey- the binding key of the generic typeargumentTypeKeys- the possibly empty list of binding keys of argument types- Returns:
- a new parameterized type binding key
-
createTypeBindingKey
public static java.lang.String createTypeBindingKey(java.lang.String typeName)
Creates a new type binding key from the given type name. The type name must be either a fully qualified name, an array type name or a primitive type name. If the type name is fully qualified, then it is expected to be dot-based. Note that inner types, generic types and parameterized types are not supported.For example:
createTypeBindingKey("int") -> "I" createTypeBindingKey("java.lang.String") -> "Ljava/lang/String;" createTypeBindingKey("boolean[]") -> "[Z"- Parameters:
typeName- the possibly qualified type name- Returns:
- a new type binding key
-
createTypeVariableBindingKey
public static java.lang.String createTypeVariableBindingKey(java.lang.String typeVariableName, java.lang.String declaringKey)Creates a new type variable binding key from the given type variable name and the given declaring key. The declaring key can either be a type binding key or a method binding key.For example:
createTypeVariableBindingKey("T", "Ljava/util/List<TE;>;") -> "Ljava/util/List<TE;>;:TT;" createTypeVariableBindingKey("SomeTypeVariable", "Lp/X;.foo()V") -> "Lp/X;.foo()V:TSomeTypeVariable;"- Parameters:
typeVariableName- the name of the given type variabledeclaringKey- the binding key of the type or method the type variable belongs to- Returns:
- a new type variable binding key
-
createWilcardTypeBindingKey
public static java.lang.String createWilcardTypeBindingKey(java.lang.String typeKey, char kind)Deprecated.This method is missing crucial information necessary for proper wildcard binding key creation.Creates a new wildcard type binding key from the given type binding key and the given wildcard kind (one ofSignature.C_STAR,Signature.C_SUPER, orSignature.C_EXTENDS. If the wildcard isSignature.C_STAR, the given type binding key is ignored.For example:
createWilcardTypeBindingKey(null, Signature.C_STAR) -> "*" createWilcardTypeBindingKey("Ljava/util/List<TE;>;", Signature.C_SUPER) -> "-Ljava/util/List<TE;>;" createWilcardTypeBindingKey("Ljava/util/ArrayList;", Signature.C_EXTENDS) -> "+Ljava/util/ArrayList;"- Parameters:
typeKey- the binding key of the given typekind- one ofSignature.C_STAR,Signature.C_SUPER, orSignature.C_EXTENDS- Returns:
- a new wildcard type binding key
- See Also:
createWildcardTypeBindingKey(String, char, String, int)
-
createWildcardTypeBindingKey
public static java.lang.String createWildcardTypeBindingKey(java.lang.String genericTypeKey, char boundKind, java.lang.String boundTypeKey, int rank)Creates a new wildcard type binding key from the given generic type binding key, the given wildcard kind (one ofSignature.C_STAR,Signature.C_SUPER, orSignature.C_EXTENDSthe given bound type binding key and the given rank. If the wildcard kind isSignature.C_STAR, the given bound type binding key is ignored.For example:
createWildcardTypeBindingKey("Ljava/util/ArrayList;", Signature.C_STAR, null, 0) -> "Ljava/util/ArrayList;{0}*" createWildcardTypeBindingKey("Ljava/util/ArrayList;", Signature.C_SUPER, "Ljava/lang/String;", 0) -> "Ljava/util/ArrayList;{0}-Ljava/lang/String;" createWildcardTypeBindingKey("Ljava/util/HashMap;", Signature.C_EXTENDS, "Ljava/lang/String;", 1) -> "Ljava/util/HashMap;{1}+Ljava/lang/String;"- Parameters:
genericTypeKey- the binding key of the generic typeboundKind- one ofSignature.C_STAR,Signature.C_SUPER, orSignature.C_EXTENDSboundTypeKey- the binding key of the bounding type.rank- the relative position of this wild card type in the parameterization of the generic type.- Returns:
- a new wildcard type binding key
- Since:
- 3.5
-
getDeclaringType
public BindingKey getDeclaringType()
Returns the binding key of the declaring type of the element represented by this binding key. If the binding key does not represent a member or if the member doesn't have a declaring type, returnsnull.Note that only binding keys for references to methods and fields are fully supported. The binding keys for declarations will not have type parameters.
- Returns:
- the type binding key or
null - Since:
- 3.7.1
-
getThrownExceptions
public java.lang.String[] getThrownExceptions()
Returns the thrown exception signatures of the element represented by this binding key. If this binding key does not represent a method or does not throw any exception, returns an empty array.- Returns:
- the thrown exceptions signatures
- Since:
- 3.3
-
getTypeArguments
public java.lang.String[] getTypeArguments()
Returns the type argument signatures of the element represented by this binding key. If this binding key doesn't represent a parameterized type or a parameterized method, returns an empty array.- Returns:
- the type argument signatures
-
isRawType
public boolean isRawType()
Returns whether this binding key represents a raw type.- Returns:
- whether this binding key represents a raw type
-
isParameterizedType
public boolean isParameterizedType()
Returns whether this binding key represents a parameterized type, or if its declaring type is a parameterized type.- Returns:
- whether this binding key represents a parameterized type
-
isParameterizedMethod
public boolean isParameterizedMethod()
Returns whether this binding key represents a parameterized method, or if its declaring method is a parameterized method.- Returns:
- whether this binding key represents a parameterized method
-
toSignature
public java.lang.String toSignature()
Transforms this binding key into a resolved signature. If this binding key represents a field, the returned signature is the field type's signature.- Returns:
- the resolved signature for this binding key
- Since:
- 3.2
- See Also:
Signature
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-