Class Signature
- java.lang.Object
-
- org.eclipse.jdt.core.Signature
-
public final class Signature extends Object
Provides methods for encoding and decoding type and method signature strings.Signatures obtained from parsing source files (i.e. files with one of the
Java-like extensions) differ subtly from ones obtained from pre-compiled binary (".class") files in class names are usually left unresolved in the former. For example, the normal resolved form of the type "String" embeds the class's package name ("Ljava.lang.String;" or "Ljava/lang/String;"), whereas the unresolved form contains only what is written "QString;".Generic types introduce to the Java language in J2SE 1.5 add three new facets to signatures: type variables, parameterized types with type arguments, and formal type parameters. Rich signatures containing these facets only occur when dealing with code that makes overt use of the new language features. All other code, and certainly all Java code written or compiled with J2SE 1.4 or earlier, involved only simple signatures.
Note that the "Q", "!", "|" and "&" formats are specific to Eclipse; the remainder are specified in the JVM spec.
Due to historical reasons Eclipse uses "|" format for Intersection and "&" for Union which is opposite to their usage in source code.
The syntax for a type signature is:
TypeSignature ::= "B" // byte | "C" // char | "D" // double | "F" // float | "I" // int | "J" // long | "S" // short | "V" // void | "Z" // boolean | "T" + Identifier + ";" // type variable | "[" + TypeSignature // array X[] | "!" + TypeSignature // capture-of ? | "|" + TypeSignature + (":" + TypeSignature)+ // intersection type | ResolvedClassTypeSignature | UnresolvedClassTypeSignature ResolvedClassTypeSignature ::= // resolved named type (in compiled code) "L" + Identifier + OptionalTypeArguments ( ( "." | "/" ) + Identifier + OptionalTypeArguments )* + ";" | OptionalTypeParameters + "L" + Identifier + ( ( "." | "/" ) + Identifier )* + ";" UnresolvedClassTypeSignature ::= // unresolved named type (in source code) "Q" + Identifier + OptionalTypeArguments ( ( "." | "/" ) + Identifier + OptionalTypeArguments )* + ";" | OptionalTypeParameters "Q" + Identifier + ( ( "." | "/" ) + Identifier )* + ";" OptionalTypeArguments ::= "<" + TypeArgument+ + ">" | TypeArgument ::= | TypeSignature | "*" // wildcard ? | "+" TypeSignature // wildcard ? extends X | "-" TypeSignature // wildcard ? super X OptionalTypeParameters ::= "<" + FormalTypeParameterSignature+ + ">" |Examples:
"[[I"denotesint[][]"Ljava.lang.String;"denotesjava.lang.Stringin compiled code"QString;"denotesStringin source code"Qjava.lang.String;"denotesjava.lang.Stringin source code"[QString;"denotesString[]in source code"QMap<QString;*>;"denotesMap<String,?>in source code"Qjava.util.List<V>;"denotesjava.util.List<V>in source code"<E>Ljava.util.List;"denotes<E>java.util.Listin source code
The syntax for a method signature is:
MethodSignature ::= OptionalTypeParameters + "(" + ParamTypeSignature* + ")" + ReturnTypeSignature ParamTypeSignature ::= TypeSignature ReturnTypeSignature ::= TypeSignatureExamples:
"()I"denotesint foo()"([Ljava.lang.String;)V"denotesvoid foo(java.lang.String[])in compiled code"(QString;)QObject;"denotesObject foo(String)in source code
The syntax for a formal type parameter signature is:
FormalTypeParameterSignature ::= TypeVariableName + OptionalClassBound + InterfaceBound* TypeVariableName ::= Identifier OptionalClassBound ::= ":" | ":" + TypeSignature InterfaceBound ::= ":" + TypeSignatureExamples:
"X:"denotesX"X:QReader;"denotesX extends Readerin source code"X:QReader;:QSerializable;"denotesX extends Reader & Serializablein source code
This class provides static methods and constants only.
Note: An empty signature is considered to be syntactically incorrect. So most methods will throw an IllegalArgumentException if an empty signature is provided.
- Restriction:
- This class is not intended to be instantiated by clients.
-
-
Field Summary
Fields Modifier and Type Field Description static intARRAY_TYPE_SIGNATUREKind constant for an array type signature.static intBASE_TYPE_SIGNATUREKind constant for a base (primitive or void) type signature.static charC_ARRAYCharacter constant indicating an array type in a signature.static charC_BOOLEANCharacter constant indicating the primitive type boolean in a signature.static charC_BYTECharacter constant indicating the primitive type byte in a signature.static charC_CAPTURECharacter constant indicating a capture of a wildcard type in a signature.static charC_CHARCharacter constant indicating the primitive type char in a signature.static charC_COLONCharacter constant indicating the colon in a signature.static charC_DOLLARCharacter constant indicating the dollar in a signature.static charC_DOTCharacter constant indicating the dot in a signature.static charC_DOUBLECharacter constant indicating the primitive type double in a signature.static charC_EXCEPTION_STARTCharacter constant indicating an exception in a signature.static charC_EXTENDSCharacter constant indicating a bound wildcard type argument in a signature with extends clause.static charC_FLOATCharacter constant indicating the primitive type float in a signature.static charC_GENERIC_ENDCharacter constant indicating the end of a generic type list in a signature.static charC_GENERIC_STARTCharacter constant indicating the start of a formal type parameter (or type argument) list in a signature.static charC_INTCharacter constant indicating the primitive type int in a signature.static charC_INTERSECTIONCharacter constant indicating an intersection type in a signature.static charC_LONGCharacter constant indicating the primitive type long in a signature.static charC_NAME_ENDCharacter constant indicating the end of a named type in a signature.static charC_PARAM_ENDCharacter constant indicating the end of a parameter type list in a signature.static charC_PARAM_STARTCharacter constant indicating the start of a parameter type list in a signature.static charC_RESOLVEDCharacter constant indicating the start of a resolved, named type in a signature.static charC_SEMICOLONCharacter constant indicating the semicolon in a signature.static charC_SHORTCharacter constant indicating the primitive type short in a signature.static charC_STARCharacter constant indicating an unbound wildcard type argument in a signature.static charC_SUPERCharacter constant indicating a bound wildcard type argument in a signature with super clause.static charC_TYPE_VARIABLECharacter constant indicating the start of a resolved type variable in a signature.static charC_UNIONCharacter constant indicating a union type in a signature.static charC_UNRESOLVEDCharacter constant indicating the start of an unresolved, named type in a signature.static charC_VOIDCharacter constant indicating result type void in a signature.static intCAPTURE_TYPE_SIGNATUREKind constant for the capture of a wildcard type signature.static intCLASS_TYPE_SIGNATUREKind constant for a class type signature.static intINTERSECTION_TYPE_SIGNATUREKind constant for the intersection type signature.static StringSIG_BOOLEANString constant for the signature of the primitive type boolean.static StringSIG_BYTEString constant for the signature of the primitive type byte.static StringSIG_CHARString constant for the signature of the primitive type char.static StringSIG_DOUBLEString constant for the signature of the primitive type double.static StringSIG_FLOATString constant for the signature of the primitive type float.static StringSIG_INTString constant for the signature of the primitive type int.static StringSIG_LONGString constant for the signature of the primitive type long.static StringSIG_SHORTString constant for the signature of the primitive type short.static StringSIG_VOIDString constant for the signature of result type void.static intTYPE_VARIABLE_SIGNATUREKind constant for a type variable signature.static intUNION_TYPE_SIGNATUREKind constant for the union type signature.static intWILDCARD_TYPE_SIGNATUREKind constant for a wildcard type signature.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static char[]createArraySignature(char[] typeSignature, int arrayCount)Creates a new type signature with the given amount of array nesting added to the given type signature.static StringcreateArraySignature(String typeSignature, int arrayCount)Creates a new type signature with the given amount of array nesting added to the given type signature.static char[]createCharArrayTypeSignature(char[] typeName, boolean isResolved)Creates a new type signature from the given type name encoded as a character array.static StringcreateIntersectionTypeSignature(char[][] typeSignatures)Creates a new intersection type signature from the given type signatures.static StringcreateIntersectionTypeSignature(String[] typeSignatures)Creates a new intersection type signature from the given type signatures.static char[]createMethodSignature(char[][] parameterTypes, char[] returnType)Creates a method signature from the given parameter and return type signatures.static StringcreateMethodSignature(String[] parameterTypes, String returnType)Creates a method signature from the given parameter and return type signatures.static char[]createTypeParameterSignature(char[] typeParameterName, char[][] boundSignatures)Creates a new type parameter signature with the given name and bounds.static StringcreateTypeParameterSignature(String typeParameterName, String[] boundSignatures)Creates a new type parameter signature with the given name and bounds.static StringcreateTypeSignature(char[] typeName, boolean isResolved)Creates a new type signature from the given type name encoded as a character array.static StringcreateTypeSignature(String typeName, boolean isResolved)Creates a new type signature from the given type name.static StringcreateUnionTypeSignature(String[] typeSignatures)Creates a new union type signature from the given type signatures.static intgetArrayCount(char[] typeSignature)Returns the array count (array nesting depth) of the given type signature.static intgetArrayCount(String typeSignature)Returns the array count (array nesting depth) of the given type signature.static char[]getElementType(char[] typeSignature)Returns the type signature without any array nesting.static StringgetElementType(String typeSignature)Returns the type signature without any array nesting.static char[][]getIntersectionTypeBounds(char[] intersectionTypeSignature)Extracts the type bounds' signatures from the given intersection type signature.static String[]getIntersectionTypeBounds(String intersectionTypeSignature)Extracts the type bounds' signatures from the given intersection type signature.static intgetParameterCount(char[] methodSignature)Returns the number of parameter types in the given method signature.static intgetParameterCount(String methodSignature)Returns the number of parameter types in the given method signature.static char[][]getParameterTypes(char[] methodSignature)Extracts the parameter type signatures from the given method signature.static String[]getParameterTypes(String methodSignature)Extracts the parameter type signatures from the given method signature.static char[]getQualifier(char[] name)Returns a char array containing all but the last segment of the given dot-separated qualified name.static StringgetQualifier(String name)Returns a string containing all but the last segment of the given dot-separated qualified name.static char[]getReturnType(char[] methodSignature)Extracts the return type from the given method signature.static StringgetReturnType(String methodSignature)Extracts the return type from the given method signature.static char[]getSignatureQualifier(char[] typeSignature)Returns package fragment of a type signature.static StringgetSignatureQualifier(String typeSignature)Returns package fragment of a type signature.static char[]getSignatureSimpleName(char[] typeSignature)Returns type fragment of a type signature.static StringgetSignatureSimpleName(String typeSignature)Returns type fragment of a type signature.static char[]getSimpleName(char[] name)Returns the last segment of the given dot-separated qualified name.static StringgetSimpleName(String name)Returns the last segment of the given dot-separated qualified name.static char[][]getSimpleNames(char[] name)Returns all segments of the given dot-separated qualified name.static String[]getSimpleNames(String name)Returns all segments of the given dot-separated qualified name.static char[][]getThrownExceptionTypes(char[] methodSignature)Extracts the thrown exception type signatures from the given method signature if any The method signature is expected to be dot-based.static String[]getThrownExceptionTypes(String methodSignature)Extracts the thrown exception type signatures from the given method signature if any The method signature is expected to be dot-based.static char[][]getTypeArguments(char[] parameterizedTypeSignature)Extracts the type argument signatures from the given type signature.static String[]getTypeArguments(String parameterizedTypeSignature)Extracts the type argument signatures from the given type signature.static char[]getTypeErasure(char[] parameterizedTypeSignature)Extracts the type erasure signature from the given parameterized type signature.static StringgetTypeErasure(String parameterizedTypeSignature)Extracts the type erasure signature from the given parameterized type signature.static char[][]getTypeParameterBounds(char[] formalTypeParameterSignature)Extracts the class and interface bounds from the given formal type parameter signature.static String[]getTypeParameterBounds(String formalTypeParameterSignature)Extracts the class and interface bounds from the given formal type parameter signature.static char[][]getTypeParameters(char[] methodOrTypeSignature)Extracts the type parameter signatures from the given method or type signature.static String[]getTypeParameters(String methodOrTypeSignature)Extracts the type parameter signatures from the given method or type signature.static intgetTypeSignatureKind(char[] typeSignature)Returns the kind of type signature encoded by the given string.static intgetTypeSignatureKind(String typeSignature)Returns the kind of type signature encoded by the given string.static char[]getTypeVariable(char[] formalTypeParameterSignature)Extracts the type variable name from the given formal type parameter signature.static StringgetTypeVariable(String formalTypeParameterSignature)Extracts the type variable name from the given formal type parameter signature.static String[]getUnionTypeBounds(String unionSignature)Extracts the type bounds' signatures from the given union type signature.static char[]removeCapture(char[] methodOrTypeSignature)Removes any capture information from the given type or method signature and returns the resulting signature.static StringremoveCapture(String methodOrTypeSignature)Removes any capture information from the given type or method signature and returns the resulting signature.static char[]toCharArray(char[] signature)Converts the given type signature to a readable string.static char[]toCharArray(char[] methodSignature, char[] methodName, char[][] parameterNames, boolean fullyQualifyTypeNames, boolean includeReturnType)Converts the given method signature to a readable form.static char[]toCharArray(char[] methodSignature, char[] methodName, char[][] parameterNames, boolean fullyQualifyTypeNames, boolean includeReturnType, boolean isVargArgs)Converts the given method signature to a readable form.static char[]toQualifiedName(char[][] segments)Converts the given array of qualified name segments to a qualified name.static StringtoQualifiedName(String[] segments)Converts the given array of qualified name segments to a qualified name.static StringtoString(String signature)Converts the given type signature to a readable string.static StringtoString(String methodSignature, String methodName, String[] parameterNames, boolean fullyQualifyTypeNames, boolean includeReturnType)Converts the given method signature to a readable string.static StringtoString(String methodSignature, String methodName, String[] parameterNames, boolean fullyQualifyTypeNames, boolean includeReturnType, boolean isVarArgs)Converts the given method signature to a readable string.
-
-
-
Field Detail
-
ARRAY_TYPE_SIGNATURE
public static final int ARRAY_TYPE_SIGNATURE
Kind constant for an array type signature.- Since:
- 3.0
- See Also:
getTypeSignatureKind(String), Constant Field Values
-
BASE_TYPE_SIGNATURE
public static final int BASE_TYPE_SIGNATURE
Kind constant for a base (primitive or void) type signature.- Since:
- 3.0
- See Also:
getTypeSignatureKind(String), Constant Field Values
-
C_ARRAY
public static final char C_ARRAY
Character constant indicating an array type in a signature. Value is'['.- See Also:
- Constant Field Values
-
C_BOOLEAN
public static final char C_BOOLEAN
Character constant indicating the primitive type boolean in a signature. Value is'Z'.- See Also:
- Constant Field Values
-
C_BYTE
public static final char C_BYTE
Character constant indicating the primitive type byte in a signature. Value is'B'.- See Also:
- Constant Field Values
-
C_CAPTURE
public static final char C_CAPTURE
Character constant indicating a capture of a wildcard type in a signature. Value is'!'.- Since:
- 3.1
- See Also:
- Constant Field Values
-
C_CHAR
public static final char C_CHAR
Character constant indicating the primitive type char in a signature. Value is'C'.- See Also:
- Constant Field Values
-
C_COLON
public static final char C_COLON
Character constant indicating the colon in a signature. Value is':'.- Since:
- 3.0
- See Also:
- Constant Field Values
-
C_DOLLAR
public static final char C_DOLLAR
Character constant indicating the dollar in a signature. Value is'$'.- See Also:
- Constant Field Values
-
C_DOT
public static final char C_DOT
Character constant indicating the dot in a signature. Value is'.'.- See Also:
- Constant Field Values
-
C_DOUBLE
public static final char C_DOUBLE
Character constant indicating the primitive type double in a signature. Value is'D'.- See Also:
- Constant Field Values
-
C_EXCEPTION_START
public static final char C_EXCEPTION_START
Character constant indicating an exception in a signature. Value is'^'.- Since:
- 3.1
- See Also:
- Constant Field Values
-
C_EXTENDS
public static final char C_EXTENDS
Character constant indicating a bound wildcard type argument in a signature with extends clause. Value is'+'.- Since:
- 3.1
- See Also:
- Constant Field Values
-
C_FLOAT
public static final char C_FLOAT
Character constant indicating the primitive type float in a signature. Value is'F'.- See Also:
- Constant Field Values
-
C_GENERIC_END
public static final char C_GENERIC_END
Character constant indicating the end of a generic type list in a signature. Value is'>'.- Since:
- 3.0
- See Also:
- Constant Field Values
-
C_GENERIC_START
public static final char C_GENERIC_START
Character constant indicating the start of a formal type parameter (or type argument) list in a signature. Value is'<'.- Since:
- 3.0
- See Also:
- Constant Field Values
-
C_INT
public static final char C_INT
Character constant indicating the primitive type int in a signature. Value is'I'.- See Also:
- Constant Field Values
-
C_INTERSECTION
public static final char C_INTERSECTION
Character constant indicating an intersection type in a signature. Value is'|'.- Since:
- 3.7.1
- See Also:
- Constant Field Values
-
C_UNION
public static final char C_UNION
Character constant indicating a union type in a signature. Value is'&'.- Since:
- 3.14
- See Also:
- Constant Field Values
-
C_LONG
public static final char C_LONG
Character constant indicating the primitive type long in a signature. Value is'J'.- See Also:
- Constant Field Values
-
C_NAME_END
public static final char C_NAME_END
Character constant indicating the end of a named type in a signature. Value is';'.- See Also:
- Constant Field Values
-
C_PARAM_END
public static final char C_PARAM_END
Character constant indicating the end of a parameter type list in a signature. Value is')'.- See Also:
- Constant Field Values
-
C_PARAM_START
public static final char C_PARAM_START
Character constant indicating the start of a parameter type list in a signature. Value is'('.- See Also:
- Constant Field Values
-
C_RESOLVED
public static final char C_RESOLVED
Character constant indicating the start of a resolved, named type in a signature. Value is'L'.- See Also:
- Constant Field Values
-
C_SEMICOLON
public static final char C_SEMICOLON
Character constant indicating the semicolon in a signature. Value is';'.- See Also:
- Constant Field Values
-
C_SHORT
public static final char C_SHORT
Character constant indicating the primitive type short in a signature. Value is'S'.- See Also:
- Constant Field Values
-
C_STAR
public static final char C_STAR
Character constant indicating an unbound wildcard type argument in a signature. Value is'*'.- Since:
- 3.0
- See Also:
- Constant Field Values
-
C_SUPER
public static final char C_SUPER
Character constant indicating a bound wildcard type argument in a signature with super clause. Value is'-'.- Since:
- 3.1
- See Also:
- Constant Field Values
-
C_TYPE_VARIABLE
public static final char C_TYPE_VARIABLE
Character constant indicating the start of a resolved type variable in a signature. Value is'T'.- Since:
- 3.0
- See Also:
- Constant Field Values
-
C_UNRESOLVED
public static final char C_UNRESOLVED
Character constant indicating the start of an unresolved, named type in a signature. Value is'Q'.- See Also:
- Constant Field Values
-
C_VOID
public static final char C_VOID
Character constant indicating result type void in a signature. Value is'V'.- See Also:
- Constant Field Values
-
CAPTURE_TYPE_SIGNATURE
public static final int CAPTURE_TYPE_SIGNATURE
Kind constant for the capture of a wildcard type signature.- Since:
- 3.1
- See Also:
getTypeSignatureKind(String), Constant Field Values
-
CLASS_TYPE_SIGNATURE
public static final int CLASS_TYPE_SIGNATURE
Kind constant for a class type signature.- Since:
- 3.0
- See Also:
getTypeSignatureKind(String), Constant Field Values
-
INTERSECTION_TYPE_SIGNATURE
public static final int INTERSECTION_TYPE_SIGNATURE
Kind constant for the intersection type signature.- Since:
- 3.7.1
- See Also:
getTypeSignatureKind(String), Constant Field Values
-
UNION_TYPE_SIGNATURE
public static final int UNION_TYPE_SIGNATURE
Kind constant for the union type signature.- Since:
- 3.14
- See Also:
getTypeSignatureKind(String), Constant Field Values
-
SIG_BOOLEAN
public static final String SIG_BOOLEAN
String constant for the signature of the primitive type boolean. Value is"Z".- See Also:
- Constant Field Values
-
SIG_BYTE
public static final String SIG_BYTE
String constant for the signature of the primitive type byte. Value is"B".- See Also:
- Constant Field Values
-
SIG_CHAR
public static final String SIG_CHAR
String constant for the signature of the primitive type char. Value is"C".- See Also:
- Constant Field Values
-
SIG_DOUBLE
public static final String SIG_DOUBLE
String constant for the signature of the primitive type double. Value is"D".- See Also:
- Constant Field Values
-
SIG_FLOAT
public static final String SIG_FLOAT
String constant for the signature of the primitive type float. Value is"F".- See Also:
- Constant Field Values
-
SIG_INT
public static final String SIG_INT
String constant for the signature of the primitive type int. Value is"I".- See Also:
- Constant Field Values
-
SIG_LONG
public static final String SIG_LONG
String constant for the signature of the primitive type long. Value is"J".- See Also:
- Constant Field Values
-
SIG_SHORT
public static final String SIG_SHORT
String constant for the signature of the primitive type short. Value is"S".- See Also:
- Constant Field Values
-
SIG_VOID
public static final String SIG_VOID
String constant for the signature of result type void. Value is"V".- See Also:
- Constant Field Values
-
TYPE_VARIABLE_SIGNATURE
public static final int TYPE_VARIABLE_SIGNATURE
Kind constant for a type variable signature.- Since:
- 3.0
- See Also:
getTypeSignatureKind(String), Constant Field Values
-
WILDCARD_TYPE_SIGNATURE
public static final int WILDCARD_TYPE_SIGNATURE
Kind constant for a wildcard type signature.- Since:
- 3.1
- See Also:
getTypeSignatureKind(String), Constant Field Values
-
-
Method Detail
-
createArraySignature
public static char[] createArraySignature(char[] typeSignature, int arrayCount)Creates a new type signature with the given amount of array nesting added to the given type signature.- Parameters:
typeSignature- the type signaturearrayCount- the desired number of levels of array nesting- Returns:
- the encoded array type signature
- Since:
- 2.0
-
createArraySignature
public static String createArraySignature(String typeSignature, int arrayCount)
Creates a new type signature with the given amount of array nesting added to the given type signature.- Parameters:
typeSignature- the type signaturearrayCount- the desired number of levels of array nesting- Returns:
- the encoded array type signature
-
createCharArrayTypeSignature
public static char[] createCharArrayTypeSignature(char[] typeName, boolean isResolved)Creates a new type signature from the given type name encoded as a character array. The type name may contain primitive types or array types or parameterized types or represent an intersection type in source code notation using&. This method is equivalent tocreateTypeSignature(new String(typeName),isResolved).toCharArray(), although more efficient for callers with character arrays rather than strings. If the type name is qualified, then it is expected to be dot-based.- Parameters:
typeName- the possibly qualified type nameisResolved-trueif the type name is to be considered resolved (for example, a type name from a binary class file), andfalseif the type name is to be considered unresolved (for example, a type name found in source code)- Returns:
- the encoded type signature
- Since:
- 2.0
- See Also:
createTypeSignature(java.lang.String,boolean)
-
createIntersectionTypeSignature
public static String createIntersectionTypeSignature(char[][] typeSignatures)
Creates a new intersection type signature from the given type signatures.The encoded type signature is dot-based.
- Parameters:
typeSignatures- the given type signatures- Returns:
- the encoded type signature
- Since:
- 3.7.1
-
createIntersectionTypeSignature
public static String createIntersectionTypeSignature(String[] typeSignatures)
Creates a new intersection type signature from the given type signatures.The encoded type signature is dot-based.
- Parameters:
typeSignatures- the given type signatures- Returns:
- the encoded type signature
- Since:
- 3.7.1
-
createUnionTypeSignature
public static String createUnionTypeSignature(String[] typeSignatures)
Creates a new union type signature from the given type signatures.The encoded type signature is dot-based.
- Parameters:
typeSignatures- the given type signatures- Returns:
- the encoded type signature
- Since:
- 3.14
-
createMethodSignature
public static char[] createMethodSignature(char[][] parameterTypes, char[] returnType)Creates a method signature from the given parameter and return type signatures. The encoded method signature is dot-based.- Parameters:
parameterTypes- the list of parameter type signaturesreturnType- the return type signature- Returns:
- the encoded method signature
- Since:
- 2.0
-
createMethodSignature
public static String createMethodSignature(String[] parameterTypes, String returnType)
Creates a method signature from the given parameter and return type signatures. The encoded method signature is dot-based. This method is equivalent tocreateMethodSignature(parameterTypes, returnType).- Parameters:
parameterTypes- the list of parameter type signaturesreturnType- the return type signature- Returns:
- the encoded method signature
- See Also:
createMethodSignature(char[][], char[])
-
createTypeParameterSignature
public static char[] createTypeParameterSignature(char[] typeParameterName, char[][] boundSignatures)Creates a new type parameter signature with the given name and bounds.- Parameters:
typeParameterName- the type parameter nameboundSignatures- the signatures of associated bounds or empty array if none- Returns:
- the encoded type parameter signature
- Since:
- 3.1
-
createTypeParameterSignature
public static String createTypeParameterSignature(String typeParameterName, String[] boundSignatures)
Creates a new type parameter signature with the given name and bounds.- Parameters:
typeParameterName- the type parameter nameboundSignatures- the signatures of associated bounds or empty array if none- Returns:
- the encoded type parameter signature
- Since:
- 3.1
-
createTypeSignature
public static String createTypeSignature(char[] typeName, boolean isResolved)
Creates a new type signature from the given type name encoded as a character array. The type name may contain primitive types, array types or parameterized types. This method is equivalent tocreateTypeSignature(new String(typeName),isResolved), although more efficient for callers with character arrays rather than strings. If the type name is qualified, then it is expected to be dot-based.- Parameters:
typeName- the possibly qualified type nameisResolved-trueif the type name is to be considered resolved (for example, a type name from a binary class file), andfalseif the type name is to be considered unresolved (for example, a type name found in source code)- Returns:
- the encoded type signature
- See Also:
createTypeSignature(java.lang.String,boolean)
-
createTypeSignature
public static String createTypeSignature(String typeName, boolean isResolved)
Creates a new type signature from the given type name. If the type name is qualified, then it is expected to be dot-based. The type name may contain primitive types or array types. However, parameterized types are not supported.For example:
createTypeSignature("int", hucairz) -> "I" createTypeSignature("java.lang.String", true) -> "Ljava.lang.String;" createTypeSignature("String", false) -> "QString;" createTypeSignature("java.lang.String", false) -> "Qjava.lang.String;" createTypeSignature("int []", false) -> "[I"- Parameters:
typeName- the possibly qualified type nameisResolved-trueif the type name is to be considered resolved (for example, a type name from a binary class file), andfalseif the type name is to be considered unresolved (for example, a type name found in source code)- Returns:
- the encoded type signature
-
getArrayCount
public static int getArrayCount(char[] typeSignature) throws IllegalArgumentExceptionReturns the array count (array nesting depth) of the given type signature.- Parameters:
typeSignature- the type signature- Returns:
- the array nesting depth, or 0 if not an array
- Throws:
IllegalArgumentException- if the signature is not syntactically correct- Since:
- 2.0
-
getArrayCount
public static int getArrayCount(String typeSignature) throws IllegalArgumentException
Returns the array count (array nesting depth) of the given type signature.- Parameters:
typeSignature- the type signature- Returns:
- the array nesting depth, or 0 if not an array
- Throws:
IllegalArgumentException- if the signature is not syntactically correct
-
getElementType
public static char[] getElementType(char[] typeSignature) throws IllegalArgumentExceptionReturns the type signature without any array nesting.For example:
getElementType({'[', '[', 'I'}) --> {'I'}.- Parameters:
typeSignature- the type signature- Returns:
- the type signature without arrays
- Throws:
IllegalArgumentException- if the signature is not syntactically correct- Since:
- 2.0
-
getElementType
public static String getElementType(String typeSignature) throws IllegalArgumentException
Returns the type signature without any array nesting.For example:
getElementType("[[I") --> "I".- Parameters:
typeSignature- the type signature- Returns:
- the type signature without arrays
- Throws:
IllegalArgumentException- if the signature is not syntactically correct
-
getIntersectionTypeBounds
public static char[][] getIntersectionTypeBounds(char[] intersectionTypeSignature) throws IllegalArgumentExceptionExtracts the type bounds' signatures from the given intersection type signature. Returns an empty array if the type signature is not an intersection type signature.- Parameters:
intersectionTypeSignature- the intersection type signature- Returns:
- the signatures of the type bounds
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect- Since:
- 3.7.1
-
getIntersectionTypeBounds
public static String[] getIntersectionTypeBounds(String intersectionTypeSignature) throws IllegalArgumentException
Extracts the type bounds' signatures from the given intersection type signature. Returns an empty array if the type signature is not an intersection type signature.- Parameters:
intersectionTypeSignature- the intersection type signature- Returns:
- the signatures of the type bounds
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect- Since:
- 3.7.1
-
getUnionTypeBounds
public static String[] getUnionTypeBounds(String unionSignature) throws IllegalArgumentException
Extracts the type bounds' signatures from the given union type signature. Returns an empty array if the type signature is not an union type signature.- Parameters:
unionSignature- the union type signature- Returns:
- the signatures of the type bounds
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect- Since:
- 3.14
-
getParameterCount
public static int getParameterCount(char[] methodSignature) throws IllegalArgumentExceptionReturns the number of parameter types in the given method signature.- Parameters:
methodSignature- the method signature- Returns:
- the number of parameters
- Throws:
IllegalArgumentException- if the signature is not syntactically correct- Since:
- 2.0
-
getParameterCount
public static int getParameterCount(String methodSignature) throws IllegalArgumentException
Returns the number of parameter types in the given method signature.- Parameters:
methodSignature- the method signature- Returns:
- the number of parameters
- Throws:
IllegalArgumentException- if the signature is not syntactically correct
-
getParameterTypes
public static char[][] getParameterTypes(char[] methodSignature) throws IllegalArgumentExceptionExtracts the parameter type signatures from the given method signature. The method signature is expected to be dot-based.- Parameters:
methodSignature- the method signature- Returns:
- the list of parameter type signatures
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect- Since:
- 2.0
-
getParameterTypes
public static String[] getParameterTypes(String methodSignature) throws IllegalArgumentException
Extracts the parameter type signatures from the given method signature. The method signature is expected to be dot-based.- Parameters:
methodSignature- the method signature- Returns:
- the list of parameter type signatures
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect
-
getQualifier
public static char[] getQualifier(char[] name)
Returns a char array containing all but the last segment of the given dot-separated qualified name. Returns the empty char array if it is not qualified.For example:
getQualifier({'j', 'a', 'v', 'a', '.', 'l', 'a', 'n', 'g', '.', 'O', 'b', 'j', 'e', 'c', 't'}) -> {'j', 'a', 'v', 'a', '.', 'l', 'a', 'n', 'g'} getQualifier({'O', 'u', 't', 'e', 'r', '.', 'I', 'n', 'n', 'e', 'r'}) -> {'O', 'u', 't', 'e', 'r'} getQualifier({'j', 'a', 'v', 'a', '.', 'u', 't', 'i', 'l', '.', 'L', 'i', 's', 't', '<', 'j', 'a', 'v', 'a', '.', 'l', 'a', 'n', 'g', '.', 'S', 't', 'r', 'i', 'n', 'g', '>'}) -> {'j', 'a', 'v', 'a', '.', 'u', 't', 'i', 'l'}- Parameters:
name- the name- Returns:
- the qualifier prefix, or the empty char array if the name contains no dots
- Throws:
NullPointerException- if name is null- Since:
- 2.0
-
getQualifier
public static String getQualifier(String name)
Returns a string containing all but the last segment of the given dot-separated qualified name. Returns the empty string if it is not qualified.For example:
getQualifier("java.lang.Object") -> "java.lang" getQualifier("Outer.Inner") -> "Outer" getQualifier("java.util.List<java.lang.String>") -> "java.util"- Parameters:
name- the name- Returns:
- the qualifier prefix, or the empty string if the name contains no dots
- Throws:
NullPointerException- if name is null
-
getReturnType
public static char[] getReturnType(char[] methodSignature) throws IllegalArgumentExceptionExtracts the return type from the given method signature. The method signature is expected to be dot-based.- Parameters:
methodSignature- the method signature- Returns:
- the type signature of the return type
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect- Since:
- 2.0
-
getReturnType
public static String getReturnType(String methodSignature) throws IllegalArgumentException
Extracts the return type from the given method signature. The method signature is expected to be dot-based.- Parameters:
methodSignature- the method signature- Returns:
- the type signature of the return type
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect
-
getSignatureQualifier
public static char[] getSignatureQualifier(char[] typeSignature)
Returns package fragment of a type signature. The package fragment separator must be '.' and the type fragment separator must be '$'.For example:
getSignatureQualifier({'L', 'j', 'a', 'v', 'a', '.', 'u', 't', 'i', 'l', '.', 'M', 'a', 'p', '$', 'E', 'n', 't', 'r', 'y', ';'}) -> {'j', 'a', 'v', 'a', '.', 'u', 't', 'i', 'l'}- Parameters:
typeSignature- the type signature- Returns:
- the package fragment (separators are '.')
- Since:
- 3.1
-
getSignatureQualifier
public static String getSignatureQualifier(String typeSignature)
Returns package fragment of a type signature. The package fragment separator must be '.' and the type fragment separator must be '$'.For example:
getSignatureQualifier("Ljava.util.Map$Entry") -> "java.util"- Parameters:
typeSignature- the type signature- Returns:
- the package fragment (separators are '.')
- Since:
- 3.1
-
getSignatureSimpleName
public static char[] getSignatureSimpleName(char[] typeSignature)
Returns type fragment of a type signature. The package fragment separator must be '.' and the type fragment separator must be '$'.For example:
getSignatureSimpleName({'L', 'j', 'a', 'v', 'a', '.', 'u', 't', 'i', 'l', '.', 'M', 'a', 'p', '$', 'E', 'n', 't', 'r', 'y', ';'}) -> {'M', 'a', 'p', '.', 'E', 'n', 't', 'r', 'y'}- Parameters:
typeSignature- the type signature- Returns:
- the type fragment (separators are '.')
- Since:
- 3.1
-
getSignatureSimpleName
public static String getSignatureSimpleName(String typeSignature)
Returns type fragment of a type signature. The package fragment separator must be '.' and the type fragment separator must be '$'.For example:
getSignatureSimpleName("Ljava.util.Map$Entry") -> "Map.Entry"- Parameters:
typeSignature- the type signature- Returns:
- the type fragment (separators are '.')
- Since:
- 3.1
-
getSimpleName
public static char[] getSimpleName(char[] name)
Returns the last segment of the given dot-separated qualified name. Returns the given name if it is not qualified.For example:
getSimpleName({'j', 'a', 'v', 'a', '.', 'l', 'a', 'n', 'g', '.', 'O', 'b', 'j', 'e', 'c', 't'}) -> {'O', 'b', 'j', 'e', 'c', 't'}- Parameters:
name- the name- Returns:
- the last segment of the qualified name
- Throws:
NullPointerException- if name is null- Since:
- 2.0
-
getSimpleName
public static String getSimpleName(String name)
Returns the last segment of the given dot-separated qualified name. Returns the given name if it is not qualified.For example:
getSimpleName("java.lang.Object") -> "Object"getSimpleName("java.util.Map<java.lang.String, java.lang.Object>") -> "Map<String,Object>"- Parameters:
name- the name- Returns:
- the last segment of the qualified name
- Throws:
NullPointerException- if name is null
-
getSimpleNames
public static char[][] getSimpleNames(char[] name)
Returns all segments of the given dot-separated qualified name. Returns an array with only the given name if it is not qualified. Returns an empty array if the name is empty.For example:
getSimpleNames({'j', 'a', 'v', 'a', '.', 'l', 'a', 'n', 'g', '.', 'O', 'b', 'j', 'e', 'c', 't'}) -> {{'j', 'a', 'v', 'a'}, {'l', 'a', 'n', 'g'}, {'O', 'b', 'j', 'e', 'c', 't'}} getSimpleNames({'O', 'b', 'j', 'e', 'c', 't'}) -> {{'O', 'b', 'j', 'e', 'c', 't'}} getSimpleNames({}) -> {} getSimpleNames({'j', 'a', 'v', 'a', '.', 'u', 't', 'i', 'l', '.', 'L', 'i', 's', 't', '<', 'j', 'a', 'v', 'a', '.', 'l', 'a', 'n', 'g', '.', 'S', 't', 'r', 'i', 'n', 'g', '>'}) -> {{'j', 'a', 'v', 'a'}, {'l', 'a', 'n', 'g'}, {'L', 'i', 's', 't', '<', 'j', 'a', 'v', 'a', '.', 'l', 'a', 'n', 'g', '.', 'S', 't', 'r', 'i', 'n', 'g'}}- Parameters:
name- the name- Returns:
- the list of simple names, possibly empty
- Throws:
NullPointerException- if name is null- Since:
- 2.0
-
getSimpleNames
public static String[] getSimpleNames(String name)
Returns all segments of the given dot-separated qualified name. Returns an array with only the given name if it is not qualified. Returns an empty array if the name is empty.For example:
getSimpleNames("java.lang.Object") -> {"java", "lang", "Object"} getSimpleNames("Object") -> {"Object"} getSimpleNames("") -> {} getSimpleNames("java.util.List<java.lang.String>") -> {"java", "util", "List<java.lang.String>"}- Parameters:
name- the name- Returns:
- the list of simple names, possibly empty
- Throws:
NullPointerException- if name is null
-
getThrownExceptionTypes
public static char[][] getThrownExceptionTypes(char[] methodSignature) throws IllegalArgumentExceptionExtracts the thrown exception type signatures from the given method signature if any The method signature is expected to be dot-based.- Parameters:
methodSignature- the method signature- Returns:
- the list of thrown exception type signatures
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect- Since:
- 3.1
-
getThrownExceptionTypes
public static String[] getThrownExceptionTypes(String methodSignature) throws IllegalArgumentException
Extracts the thrown exception type signatures from the given method signature if any The method signature is expected to be dot-based.- Parameters:
methodSignature- the method signature- Returns:
- the list of thrown exception type signatures
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect- Since:
- 3.1
-
getTypeArguments
public static char[][] getTypeArguments(char[] parameterizedTypeSignature) throws IllegalArgumentExceptionExtracts the type argument signatures from the given type signature. Returns an empty array if the type signature is not a parameterized type signature.- Parameters:
parameterizedTypeSignature- the parameterized type signature- Returns:
- the signatures of the type arguments
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect- Since:
- 3.1
-
getTypeArguments
public static String[] getTypeArguments(String parameterizedTypeSignature) throws IllegalArgumentException
Extracts the type argument signatures from the given type signature. Returns an empty array if the type signature is not a parameterized type signature.- Parameters:
parameterizedTypeSignature- the parameterized type signature- Returns:
- the signatures of the type arguments
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect- Since:
- 3.1
-
getTypeErasure
public static char[] getTypeErasure(char[] parameterizedTypeSignature) throws IllegalArgumentExceptionExtracts the type erasure signature from the given parameterized type signature. Returns the given type signature if it is not parameterized.- Parameters:
parameterizedTypeSignature- the parameterized type signature- Returns:
- the signature of the type erasure
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect- Since:
- 3.1
-
getTypeErasure
public static String getTypeErasure(String parameterizedTypeSignature) throws IllegalArgumentException
Extracts the type erasure signature from the given parameterized type signature. Returns the given type signature if it is not parameterized.- Parameters:
parameterizedTypeSignature- the parameterized type signature- Returns:
- the signature of the type erasure
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect- Since:
- 3.1
-
getTypeParameterBounds
public static char[][] getTypeParameterBounds(char[] formalTypeParameterSignature) throws IllegalArgumentExceptionExtracts the class and interface bounds from the given formal type parameter signature. The class bound, if present, is listed before the interface bounds. The signature is expected to be dot-based.- Parameters:
formalTypeParameterSignature- the formal type parameter signature- Returns:
- the (possibly empty) list of type signatures for the bounds
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect- Since:
- 3.0
-
getTypeParameterBounds
public static String[] getTypeParameterBounds(String formalTypeParameterSignature) throws IllegalArgumentException
Extracts the class and interface bounds from the given formal type parameter signature. The class bound, if present, is listed before the interface bounds. The signature is expected to be dot-based.- Parameters:
formalTypeParameterSignature- the formal type parameter signature- Returns:
- the (possibly empty) list of type signatures for the bounds
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect- Since:
- 3.0
-
getTypeParameters
public static char[][] getTypeParameters(char[] methodOrTypeSignature) throws IllegalArgumentExceptionExtracts the type parameter signatures from the given method or type signature. The method or type signature is expected to be dot-based.- Parameters:
methodOrTypeSignature- the method or type signature- Returns:
- the list of type parameter signatures
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect- Since:
- 3.1
-
getTypeParameters
public static String[] getTypeParameters(String methodOrTypeSignature) throws IllegalArgumentException
Extracts the type parameter signatures from the given method or type signature. The method or type signature is expected to be dot-based.- Parameters:
methodOrTypeSignature- the method or type signature- Returns:
- the list of type parameter signatures
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect- Since:
- 3.1
-
getTypeSignatureKind
public static int getTypeSignatureKind(char[] typeSignature)
Returns the kind of type signature encoded by the given string.- Parameters:
typeSignature- the type signature string- Returns:
- the kind of type signature; one of the kind constants:
ARRAY_TYPE_SIGNATURE,CLASS_TYPE_SIGNATURE,BASE_TYPE_SIGNATURE, orTYPE_VARIABLE_SIGNATURE, or (since 3.1)WILDCARD_TYPE_SIGNATUREorCAPTURE_TYPE_SIGNATURE, or (since 3.7)INTERSECTION_TYPE_SIGNATURE - Throws:
IllegalArgumentException- if this is not a type signature- Since:
- 3.0
-
getTypeSignatureKind
public static int getTypeSignatureKind(String typeSignature)
Returns the kind of type signature encoded by the given string.- Parameters:
typeSignature- the type signature string- Returns:
- the kind of type signature; one of the kind constants:
ARRAY_TYPE_SIGNATURE,CLASS_TYPE_SIGNATURE,BASE_TYPE_SIGNATURE, orTYPE_VARIABLE_SIGNATURE, or (since 3.1)WILDCARD_TYPE_SIGNATUREorCAPTURE_TYPE_SIGNATUREor (since 3.7)INTERSECTION_TYPE_SIGNATURE - Throws:
IllegalArgumentException- if this is not a type signature- Since:
- 3.0
-
getTypeVariable
public static char[] getTypeVariable(char[] formalTypeParameterSignature) throws IllegalArgumentExceptionExtracts the type variable name from the given formal type parameter signature. The signature is expected to be dot-based.- Parameters:
formalTypeParameterSignature- the formal type parameter signature- Returns:
- the name of the type variable
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect- Since:
- 3.0
-
getTypeVariable
public static String getTypeVariable(String formalTypeParameterSignature) throws IllegalArgumentException
Extracts the type variable name from the given formal type parameter signature. The signature is expected to be dot-based.- Parameters:
formalTypeParameterSignature- the formal type parameter signature- Returns:
- the name of the type variable
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect- Since:
- 3.0
-
removeCapture
public static char[] removeCapture(char[] methodOrTypeSignature)
Removes any capture information from the given type or method signature and returns the resulting signature. Returns the type or method signature itself if no capture information is present.For example (using equivalent string-based method):
removeCapture("LTest<!+Ljava.lang.Throwable;>;") will return: "LTest<+Ljava.lang.Throwable;>;"- Parameters:
methodOrTypeSignature- the signature which may have been captured- Returns:
- a new signature without capture information or the signature itself if no specific capture information is present
- Throws:
NullPointerException- ifmethodOrTypeSignatureis null- Since:
- 3.1
-
removeCapture
public static String removeCapture(String methodOrTypeSignature)
Removes any capture information from the given type or method signature and returns the resulting signature. Returns the type or method signature itself if no capture information is present.For example:
removeCapture("LTest<!+Ljava.lang.Throwable;>;") will return: "LTest<+Ljava.lang.Throwable;>;"- Parameters:
methodOrTypeSignature- the signature which may have been captured- Returns:
- a new signature without capture information or the signature itself if no specific capture information is present
- Throws:
NullPointerException- ifmethodOrTypeSignatureis null- Since:
- 3.1
-
toCharArray
public static char[] toCharArray(char[] signature) throws IllegalArgumentExceptionConverts the given type signature to a readable string. The signature is expected to be dot-based.For example:
toString({'[', 'L', 'j', 'a', 'v', 'a', '.', 'l', 'a', 'n', 'g', '.', 'S', 't', 'r', 'i', 'n', 'g', ';'}) -> {'j', 'a', 'v', 'a', '.', 'l', 'a', 'n', 'g', '.', 'S', 't', 'r', 'i', 'n', 'g', '[', ']'} toString({'I'}) -> {'i', 'n', 't'} toString({'+', 'L', 'O', 'b', 'j', 'e', 'c', 't', ';'}) -> {'?', ' ', 'e', 'x', 't', 'e', 'n', 'd', 's', ' ', 'O', 'b', 'j', 'e', 'c', 't'}Note: This method assumes that a type signature containing a
'$'is an inner type signature. While this is correct in most cases, someone could define a non-inner type name containing a'$'. Handling this correctly in all cases would have required resolving the signature, which generally not feasible.- Parameters:
signature- the type signature- Returns:
- the string representation of the type
- Throws:
IllegalArgumentException- if the signature is syntactically incorrect- Since:
- 2.0
-
toCharArray
public static char[] toCharArray(char[] methodSignature, char[] methodName, char[][] parameterNames, boolean fullyQualifyTypeNames, boolean includeReturnType)Converts the given method signature to a readable form. The method signature is expected to be dot-based.For example:
toString("([Ljava.lang.String;)V", "main", new String[] {"args"}, false, true) -> "void main(String[] args)"- Parameters:
methodSignature- the method signature to convertmethodName- the name of the method to insert in the result, ornullif no method name is to be includedparameterNames- the parameter names to insert in the result, ornullif no parameter names are to be included; if supplied, the number of parameter names must match that of the method signaturefullyQualifyTypeNames-trueif type names should be fully qualified, andfalseto use only simple namesincludeReturnType-trueif the return type is to be included- Returns:
- the char array representation of the method signature
- Throws:
IllegalArgumentException- if the method signature is syntactically incorrect- Since:
- 2.0
-
toCharArray
public static char[] toCharArray(char[] methodSignature, char[] methodName, char[][] parameterNames, boolean fullyQualifyTypeNames, boolean includeReturnType, boolean isVargArgs)Converts the given method signature to a readable form. The method signature is expected to be dot-based.For example:
toString("([Ljava.lang.String;)V", "main", new String[] {"args"}, false, true) -> "void main(String[] args)"- Parameters:
methodSignature- the method signature to convertmethodName- the name of the method to insert in the result, ornullif no method name is to be includedparameterNames- the parameter names to insert in the result, ornullif no parameter names are to be included; if supplied, the number of parameter names must match that of the method signaturefullyQualifyTypeNames-trueif type names should be fully qualified, andfalseto use only simple namesincludeReturnType-trueif the return type is to be includedisVargArgs-trueif the last argument should be displayed as a variable argument,falseotherwise.- Returns:
- the char array representation of the method signature
- Throws:
IllegalArgumentException- if the method signature is syntactically incorrect- Since:
- 3.1
-
toQualifiedName
public static char[] toQualifiedName(char[][] segments)
Converts the given array of qualified name segments to a qualified name.For example:
toQualifiedName({{'j', 'a', 'v', 'a'}, {'l', 'a', 'n', 'g'}, {'O', 'b', 'j', 'e', 'c', 't'}}) -> {'j', 'a', 'v', 'a', '.', 'l', 'a', 'n', 'g', '.', 'O', 'b', 'j', 'e', 'c', 't'} toQualifiedName({{'O', 'b', 'j', 'e', 'c', 't'}}) -> {'O', 'b', 'j', 'e', 'c', 't'} toQualifiedName({{}}) -> {}- Parameters:
segments- the list of name segments, possibly empty- Returns:
- the dot-separated qualified name, or the empty string
- Since:
- 2.0
-
toQualifiedName
public static String toQualifiedName(String[] segments)
Converts the given array of qualified name segments to a qualified name.For example:
toQualifiedName(new String[] {"java", "lang", "Object"}) -> "java.lang.Object" toQualifiedName(new String[] {"Object"}) -> "Object" toQualifiedName(new String[0]) -> ""- Parameters:
segments- the list of name segments, possibly empty- Returns:
- the dot-separated qualified name, or the empty string
-
toString
public static String toString(String signature) throws IllegalArgumentException
Converts the given type signature to a readable string. The signature is expected to be dot-based.For example:
toString("[Ljava.lang.String;") -> "java.lang.String[]" toString("I") -> "int" toString("+QObject;") -> "? extends Object"Note: This method assumes that a type signature containing a
'$'is an inner type signature. While this is correct in most cases, someone could define a non-inner type name containing a'$'. Handling this correctly in all cases would have required resolving the signature, which generally not feasible.- Parameters:
signature- the type signature- Returns:
- the string representation of the type
- Throws:
IllegalArgumentException- if the signature is not syntactically correct
-
toString
public static String toString(String methodSignature, String methodName, String[] parameterNames, boolean fullyQualifyTypeNames, boolean includeReturnType)
Converts the given method signature to a readable string. The method signature is expected to be dot-based.- Parameters:
methodSignature- the method signature to convertmethodName- the name of the method to insert in the result, ornullif no method name is to be includedparameterNames- the parameter names to insert in the result, ornullif no parameter names are to be included; if supplied, the number of parameter names must match that of the method signaturefullyQualifyTypeNames-trueif type names should be fully qualified, andfalseto use only simple namesincludeReturnType-trueif the return type is to be included- Returns:
- the string representation of the method signature
- See Also:
toCharArray(char[], char[], char[][], boolean, boolean)
-
toString
public static String toString(String methodSignature, String methodName, String[] parameterNames, boolean fullyQualifyTypeNames, boolean includeReturnType, boolean isVarArgs)
Converts the given method signature to a readable string. The method signature is expected to be dot-based.- Parameters:
methodSignature- the method signature to convertmethodName- the name of the method to insert in the result, ornullif no method name is to be includedparameterNames- the parameter names to insert in the result, ornullif no parameter names are to be included; if supplied, the number of parameter names must match that of the method signaturefullyQualifyTypeNames-trueif type names should be fully qualified, andfalseto use only simple namesincludeReturnType-trueif the return type is to be includedisVarArgs-trueif the last argument should be displayed as a variable argument,falseotherwise- Returns:
- the string representation of the method signature
- Since:
- 3.1
- See Also:
toCharArray(char[], char[], char[][], boolean, boolean)
-
-