Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.jdt.core
Class Signature  view Signature download Signature.java

java.lang.Object
  extended byorg.eclipse.jdt.core.Signature

public final class Signature
extends java.lang.Object

Provides methods for encoding and decoding type and method signature strings.

Signatures obtained from parsing source (".java") files 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.

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[]
   | ResolvedClassTypeSignature
   | UnresolvedClassTypeSignature
 
 ResolvedClassTypeSignature ::= // resolved named type (in compiled code)
     "L" + Identifier + OptionalTypeArguments
           ( ( "." | "/" ) + Identifier + OptionalTypeArguments )* + ";"
 
 UnresolvedClassTypeSignature ::= // unresolved named type (in source code)
     "Q" + Identifier + OptionalTypeArguments
           ( ( "." | "/" ) + Identifier + OptionalTypeArguments )* + ";"
 
 OptionalTypeArguments ::=
     "<" + TypeArgument+ + ">" 
   |
 
 TypeArgument ::=
   | TypeSignature
   | "*" // wildcard ?
   | "+" TypeSignature // wildcard ? extends X
   | "-" TypeSignature // wildcard ? super X
 

Examples:

The syntax for a method signature is:

 MethodSignature ::= "(" + ParamTypeSignature* + ")" + ReturnTypeSignature
 ParamTypeSignature ::= TypeSignature
 ReturnTypeSignature ::= TypeSignature
 

Examples:

The syntax for a formal type parameter signature is:

 FormalTypeParameterSignature ::=
     TypeVariableName + OptionalClassBound + InterfaceBound*
 TypeVariableName ::= Identifier
 OptionalClassBound ::=
     ":"
   | ":" + TypeSignature
 InterfaceBound ::= 
     ":" + TypeSignature
 

Examples:

This class provides static methods and constants only; it is not intended to be instantiated or subclassed by clients.


Field Summary
static int ARRAY_TYPE_SIGNATURE
          Kind constant for an array type signature.
static int BASE_TYPE_SIGNATURE
          Kind constant for a base (primitive or void) type signature.
private static char[] BOOLEAN
           
private static char[] BYTE
           
static char C_ARRAY
          Character constant indicating an array type in a signature.
static char C_BOOLEAN
          Character constant indicating the primitive type boolean in a signature.
static char C_BYTE
          Character constant indicating the primitive type byte in a signature.
static char C_CHAR
          Character constant indicating the primitive type char in a signature.
static char C_COLON
          Character constant indicating the colon in a signature.
static char C_DOLLAR
          Character constant indicating the dollar in a signature.
static char C_DOT
          Character constant indicating the dot in a signature.
static char C_DOUBLE
          Character constant indicating the primitive type double in a signature.
static char C_FLOAT
          Character constant indicating the primitive type float in a signature.
static char C_GENERIC_END
          Character constant indicating the end of a generic type list in a signature.
static char C_GENERIC_START
          Character constant indicating the start of a formal type parameter (or type argument) list in a signature.
static char C_INT
          Character constant indicating the primitive type int in a signature.
static char C_LONG
          Character constant indicating the primitive type long in a signature.
static char C_NAME_END
          Character constant indicating the end of a named type in a signature.
static char C_PARAM_END
          Character constant indicating the end of a parameter type list in a signature.
static char C_PARAM_START
          Character constant indicating the start of a parameter type list in a signature.
static char C_RESOLVED
          Character constant indicating the start of a resolved, named type in a signature.
static char C_SEMICOLON
          Character constant indicating the semicolon in a signature.
static char C_SHORT
          Character constant indicating the primitive type short in a signature.
static char C_STAR
          Character constant indicating a wildcard type argument in a signature.
static char C_TYPE_VARIABLE
          Character constant indicating the start of a resolved type variable in a signature.
static char C_UNRESOLVED
          Character constant indicating the start of an unresolved, named type in a signature.
static char C_VOID
          Character constant indicating result type void in a signature.
private static char[] CHAR
           
static int CLASS_TYPE_SIGNATURE
          Kind constant for a class type signature.
private static char[] DOUBLE
           
private static java.lang.String EMPTY
           
private static char[] FLOAT
           
private static char[] INT
           
private static char[] LONG
           
private static char[] SHORT
           
static java.lang.String SIG_BOOLEAN
          String constant for the signature of the primitive type boolean.
static java.lang.String SIG_BYTE
          String constant for the signature of the primitive type byte.
static java.lang.String SIG_CHAR
          String constant for the signature of the primitive type char.
static java.lang.String SIG_DOUBLE
          String constant for the signature of the primitive type double.
static java.lang.String SIG_FLOAT
          String constant for the signature of the primitive type float.
static java.lang.String SIG_INT
          String constant for the signature of the primitive type int.
static java.lang.String SIG_LONG
          String constant for the signature of the primitive type long.
static java.lang.String SIG_SHORT
          String constant for the signature of the primitive type short.
static java.lang.String SIG_VOID
          String constant for the signature of result type void.
static int TYPE_VARIABLE_SIGNATURE
          Kind constant for a type variable signature.
private static char[] VOID
           
 
Constructor Summary
private Signature()
           
 
Method Summary
private static int appendArrayTypeSignature(char[] string, int start, boolean fullyQualifyTypeNames, java.lang.StringBuffer buffer)
          Scans the given string for an array type signature starting at the given index and appends it to the given buffer, and returns the index of the last character.
private static int appendClassTypeSignature(char[] string, int start, boolean fullyQualifyTypeNames, java.lang.StringBuffer buffer)
          Scans the given string for a class type signature starting at the given index and appends it to the given buffer, and returns the index of the last character.
private static int appendTypeArgumentSignature(char[] string, int start, boolean fullyQualifyTypeNames, java.lang.StringBuffer buffer)
          Scans the given string for a type argument signature starting at the given index and appends it to the given buffer, and returns the index of the last character.
private static int appendTypeArgumentSignatures(char[] string, int start, boolean fullyQualifyTypeNames, java.lang.StringBuffer buffer)
          Scans the given string for a list of type arguments signature starting at the given index and appends it to the given buffer, and returns the index of the last character.
private static int appendTypeSignature(char[] string, int start, boolean fullyQualifyTypeNames, java.lang.StringBuffer buffer)
          Scans the given string for a type signature starting at the given index and appends it to the given buffer, and returns the index of the last character.
private static boolean checkPrimitiveType(char[] primitiveTypeName, char[] typeName)
           
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 java.lang.String createArraySignature(java.lang.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 char[] createMethodSignature(char[][] parameterTypes, char[] returnType)
          Creates a method signature from the given parameter and return type signatures.
static java.lang.String createMethodSignature(java.lang.String[] parameterTypes, java.lang.String returnType)
          Creates a method signature from the given parameter and return type signatures.
static java.lang.String createTypeSignature(char[] typeName, boolean isResolved)
          Creates a new type signature from the given type name encoded as a character array.
static java.lang.String createTypeSignature(java.lang.String typeName, boolean isResolved)
          Creates a new type signature from the given type name.
static int getArrayCount(char[] typeSignature)
          Returns the array count (array nesting depth) of the given type signature.
static int getArrayCount(java.lang.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 java.lang.String getElementType(java.lang.String typeSignature)
          Returns the type signature without any array nesting.
static int getParameterCount(char[] methodSignature)
          Returns the number of parameter types in the given method signature.
static int getParameterCount(java.lang.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 java.lang.String[] getParameterTypes(java.lang.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 java.lang.String getQualifier(java.lang.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 java.lang.String getReturnType(java.lang.String methodSignature)
          Extracts the return type from the given method signature.
static char[] getSimpleName(char[] name)
          Returns the last segment of the given dot-separated qualified name.
static java.lang.String getSimpleName(java.lang.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 java.lang.String[] getSimpleNames(java.lang.String name)
          Returns all segments of the given dot-separated qualified name.
static char[][] getTypeParameterBounds(char[] formalTypeParameterSignature)
          Extracts the class and interface bounds from the given formal type parameter signature.
static java.lang.String[] getTypeParameterBounds(java.lang.String formalTypeParameterSignature)
          Extracts the class and interface bounds from the given formal type parameter signature.
static int getTypeSignatureKind(char[] typeSignature)
          Returns the kind of type signature encoded by the given string.
static int getTypeSignatureKind(java.lang.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 java.lang.String getTypeVariable(java.lang.String formalTypeParameterSignature)
          Extracts the type variable name from the given formal type parameter signature.
private static int scanArrayTypeSignature(char[] string, int start)
          Scans the given string for an array type signature starting at the given index and returns the index of the last character.
private static int scanBaseTypeSignature(char[] string, int start)
          Scans the given string for a base type signature starting at the given index and returns the index of the last character.
private static int scanClassTypeSignature(char[] string, int start)
          Scans the given string for a class type signature starting at the given index and returns the index of the last character.
private static int scanIdentifier(char[] string, int start)
          Scans the given string for an identifier starting at the given index and returns the index of the last character.
private static int scanTypeArgumentSignature(char[] string, int start)
          Scans the given string for a type argument signature starting at the given index and returns the index of the last character.
private static int scanTypeArgumentSignatures(char[] string, int start)
          Scans the given string for a list of type argument signatures starting at the given index and returns the index of the last character.
private static int scanTypeSignature(char[] string, int start)
          Scans the given string for a type signature starting at the given index and returns the index of the last character.
private static int scanTypeVariableSignature(char[] string, int start)
          Scans the given string for a type variable signature starting at the given index and returns the index of the last character.
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[] toQualifiedName(char[][] segments)
          Converts the given array of qualified name segments to a qualified name.
static java.lang.String toQualifiedName(java.lang.String[] segments)
          Converts the given array of qualified name segments to a qualified name.
static java.lang.String toString(java.lang.String signature)
          Converts the given type signature to a readable string.
static java.lang.String toString(java.lang.String methodSignature, java.lang.String methodName, java.lang.String[] parameterNames, boolean fullyQualifyTypeNames, boolean includeReturnType)
          Converts the given method signature to a readable string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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_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_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_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_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_SEMICOLON

public static final char C_SEMICOLON
Character constant indicating the semicolon in a signature. Value is ';'.

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_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_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_VOID

public static final char C_VOID
Character constant indicating result type void in a signature. Value is 'V'.

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_STAR

public static final char C_STAR
Character constant indicating a wildcard type argument in a signature. Value is '*'.

Since:
3.0
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_DOLLAR

public static final char C_DOLLAR
Character constant indicating the dollar in a signature. Value is '$'.

See Also:
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_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_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_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_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_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_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_GENERIC_END

public static final char C_GENERIC_END
Character constant indicating the end of a generic type list in a signature. Value is '%gt;'.

Since:
3.0
See Also:
Constant Field Values

SIG_BOOLEAN

public static final java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.String SIG_VOID
String constant for the signature of result type void. Value is "V".

See Also:
Constant Field Values

CLASS_TYPE_SIGNATURE

public static int CLASS_TYPE_SIGNATURE
Kind constant for a class type signature.

Since:
3.0
See Also:
getTypeSignatureKind(String) 55

BASE_TYPE_SIGNATURE

public static int BASE_TYPE_SIGNATURE
Kind constant for a base (primitive or void) type signature.

Since:
3.0
See Also:
getTypeSignatureKind(String) 55

TYPE_VARIABLE_SIGNATURE

public static int TYPE_VARIABLE_SIGNATURE
Kind constant for a type variable signature.

Since:
3.0
See Also:
getTypeSignatureKind(String) 55

ARRAY_TYPE_SIGNATURE

public static int ARRAY_TYPE_SIGNATURE
Kind constant for an array type signature.

Since:
3.0
See Also:
getTypeSignatureKind(String) 55

BOOLEAN

private static final char[] BOOLEAN

BYTE

private static final char[] BYTE

CHAR

private static final char[] CHAR

DOUBLE

private static final char[] DOUBLE

FLOAT

private static final char[] FLOAT

INT

private static final char[] INT

LONG

private static final char[] LONG

SHORT

private static final char[] SHORT

VOID

private static final char[] VOID

EMPTY

private static final java.lang.String EMPTY
Constructor Detail

Signature

private Signature()
Method Detail

checkPrimitiveType

private static boolean checkPrimitiveType(char[] primitiveTypeName,
                                          char[] typeName)

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.

Since:
2.0

createArraySignature

public static java.lang.String createArraySignature(java.lang.String typeSignature,
                                                    int arrayCount)
Creates a new type signature with the given amount of array nesting added to the given type signature.


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.

Since:
2.0

createMethodSignature

public static java.lang.String createMethodSignature(java.lang.String[] parameterTypes,
                                                     java.lang.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 to createMethodSignature(parameterTypes, returnType).


createTypeSignature

public static java.lang.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 or array types. However, parameterized types are not supported. This method is equivalent to createTypeSignature(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.


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. However, parameterized types are not supported. This method is equivalent to createTypeSignature(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.

Since:
2.0

createTypeSignature

public static java.lang.String createTypeSignature(java.lang.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"
 
 


getArrayCount

public static int getArrayCount(char[] typeSignature)
                         throws java.lang.IllegalArgumentException
Returns the array count (array nesting depth) of the given type signature.

Since:
2.0

getArrayCount

public static int getArrayCount(java.lang.String typeSignature)
                         throws java.lang.IllegalArgumentException
Returns the array count (array nesting depth) of the given type signature.


getElementType

public static char[] getElementType(char[] typeSignature)
                             throws java.lang.IllegalArgumentException
Returns the type signature without any array nesting.

For example:

 
 getElementType({'[', '[', 'I'}) --> {'I'}.
 
 

Since:
2.0

getElementType

public static java.lang.String getElementType(java.lang.String typeSignature)
                                       throws java.lang.IllegalArgumentException
Returns the type signature without any array nesting.

For example:

 
 getElementType("[[I") --> "I".
 
 


getParameterCount

public static int getParameterCount(char[] methodSignature)
                             throws java.lang.IllegalArgumentException
Returns the number of parameter types in the given method signature.

Since:
2.0

getTypeSignatureKind

public static int getTypeSignatureKind(char[] typeSignature)
Returns the kind of type signature encoded by the given string.

Since:
3.0

getTypeSignatureKind

public static int getTypeSignatureKind(java.lang.String typeSignature)
Returns the kind of type signature encoded by the given string.

Since:
3.0

scanTypeSignature

private static int scanTypeSignature(char[] string,
                                     int start)
Scans the given string for a type signature starting at the given index and returns the index of the last character.
 TypeSignature:
  |  BaseTypeSignature
  |  ArrayTypeSignature
  |  ClassTypeSignature
  |  TypeVariableSignature
 


scanBaseTypeSignature

private static int scanBaseTypeSignature(char[] string,
                                         int start)
Scans the given string for a base type signature starting at the given index and returns the index of the last character.
 BaseTypeSignature:
     B | C | D | F | I
   | J | S | V | Z
 
Note that although the base type "V" is only allowed in method return types, there is no syntactic ambiguity. This method will accept them anywhere without complaint.


scanArrayTypeSignature

private static int scanArrayTypeSignature(char[] string,
                                          int start)
Scans the given string for an array type signature starting at the given index and returns the index of the last character.
 ArrayTypeSignature:
     [ TypeSignature
 


scanTypeVariableSignature

private static int scanTypeVariableSignature(char[] string,
                                             int start)
Scans the given string for a type variable signature starting at the given index and returns the index of the last character.
 TypeVariableSignature:
     T Identifier ;
 


scanIdentifier

private static int scanIdentifier(char[] string,
                                  int start)
Scans the given string for an identifier starting at the given index and returns the index of the last character. Stop characters are: ";", ":", "<", ">", "/", ".".


scanClassTypeSignature

private static int scanClassTypeSignature(char[] string,
                                          int start)
Scans the given string for a class type signature starting at the given index and returns the index of the last character.
 ClassTypeSignature:
     { L | Q } Identifier
           { { / | . Identifier [ < TypeArgumentSignature* > ] }
           ;
 
Note that although all "/"-identifiers most come before "."-identifiers, there is no syntactic ambiguity. This method will accept them without complaint.


scanTypeArgumentSignatures

private static int scanTypeArgumentSignatures(char[] string,
                                              int start)
Scans the given string for a list of type argument signatures starting at the given index and returns the index of the last character.
 TypeArgumentSignatures:
     < TypeArgumentSignature* >
 
Note that although there is supposed to be at least one type argument, there is no syntactic ambiguity if there are none. This method will accept zero type argument signatures without complaint.


scanTypeArgumentSignature

private static int scanTypeArgumentSignature(char[] string,
                                             int start)
Scans the given string for a type argument signature starting at the given index and returns the index of the last character.
 TypeArgumentSignature:
     *
  |  + TypeSignature
  |  - TypeSignature
  |  TypeSignature
 
Note that although base types are not allowed in type arguments, there is no syntactic ambiguity. This method will accept them without complaint.


getParameterCount

public static int getParameterCount(java.lang.String methodSignature)
                             throws java.lang.IllegalArgumentException
Returns the number of parameter types in the given method signature.


getParameterTypes

public static char[][] getParameterTypes(char[] methodSignature)
                                  throws java.lang.IllegalArgumentException
Extracts the parameter type signatures from the given method signature. The method signature is expected to be dot-based.

Since:
2.0

getParameterTypes

public static java.lang.String[] getParameterTypes(java.lang.String methodSignature)
                                            throws java.lang.IllegalArgumentException
Extracts the parameter type signatures from the given method signature. The method signature is expected to be dot-based.


getTypeVariable

public static java.lang.String getTypeVariable(java.lang.String formalTypeParameterSignature)
                                        throws java.lang.IllegalArgumentException
Extracts the type variable name from the given formal type parameter signature. The signature is expected to be dot-based.

Since:
3.0

getTypeVariable

public static char[] getTypeVariable(char[] formalTypeParameterSignature)
                              throws java.lang.IllegalArgumentException
Extracts the type variable name from the given formal type parameter signature. The signature is expected to be dot-based.

Since:
3.0

getTypeParameterBounds

public static char[][] getTypeParameterBounds(char[] formalTypeParameterSignature)
                                       throws java.lang.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.

Since:
3.0

getTypeParameterBounds

public static java.lang.String[] getTypeParameterBounds(java.lang.String formalTypeParameterSignature)
                                                 throws java.lang.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.

Since:
3.0

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'}
 
 

Since:
2.0

getQualifier

public static java.lang.String getQualifier(java.lang.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"
 
 


getReturnType

public static char[] getReturnType(char[] methodSignature)
                            throws java.lang.IllegalArgumentException
Extracts the return type from the given method signature. The method signature is expected to be dot-based.

Since:
2.0

getReturnType

public static java.lang.String getReturnType(java.lang.String methodSignature)
                                      throws java.lang.IllegalArgumentException
Extracts the return type from the given method signature. The method signature is expected to be dot-based.


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'}
 
 

Since:
2.0

getSimpleName

public static java.lang.String getSimpleName(java.lang.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"
 
 


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("") -> {}
 
 

Since:
2.0

getSimpleNames

public static java.lang.String[] getSimpleNames(java.lang.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("") -> {}
 
 


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)"
 
 

Since:
2.0

toCharArray

public static char[] toCharArray(char[] signature)
                          throws java.lang.IllegalArgumentException
Converts 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'}
 
 

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.

Since:
2.0

appendTypeSignature

private static int appendTypeSignature(char[] string,
                                       int start,
                                       boolean fullyQualifyTypeNames,
                                       java.lang.StringBuffer buffer)
Scans the given string for a type signature starting at the given index and appends it to the given buffer, and returns the index of the last character.


appendArrayTypeSignature

private static int appendArrayTypeSignature(char[] string,
                                            int start,
                                            boolean fullyQualifyTypeNames,
                                            java.lang.StringBuffer buffer)
Scans the given string for an array type signature starting at the given index and appends it to the given buffer, and returns the index of the last character.


appendClassTypeSignature

private static int appendClassTypeSignature(char[] string,
                                            int start,
                                            boolean fullyQualifyTypeNames,
                                            java.lang.StringBuffer buffer)
Scans the given string for a class type signature starting at the given index and appends it to the given buffer, and returns the index of the last character.


appendTypeArgumentSignatures

private static int appendTypeArgumentSignatures(char[] string,
                                                int start,
                                                boolean fullyQualifyTypeNames,
                                                java.lang.StringBuffer buffer)
Scans the given string for a list of type arguments signature starting at the given index and appends it to the given buffer, and returns the index of the last character.


appendTypeArgumentSignature

private static int appendTypeArgumentSignature(char[] string,
                                               int start,
                                               boolean fullyQualifyTypeNames,
                                               java.lang.StringBuffer buffer)
Scans the given string for a type argument signature starting at the given index and appends it to the given buffer, and returns the index of the last character.


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({{}}) -> {}
 
 

Since:
2.0

toQualifiedName

public static java.lang.String toQualifiedName(java.lang.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]) -> ""
 
 


toString

public static java.lang.String toString(java.lang.String signature)
                                 throws java.lang.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"
 
 

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.


toString

public static java.lang.String toString(java.lang.String methodSignature,
                                        java.lang.String methodName,
                                        java.lang.String[] parameterNames,
                                        boolean fullyQualifyTypeNames,
                                        boolean includeReturnType)
Converts the given method signature to a readable string. The method signature is expected to be dot-based.