JavaScript Development Tools
Release 3.2

org.eclipse.wst.jsdt.core
Class Signature

java.lang.Object
  extended by org.eclipse.wst.jsdt.core.Signature

public final class Signature
extends Object

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

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

Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.


Field Summary
static char[] ANY
           
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.
static char C_ANY
          Character constant indicating any type in a signature.
static char C_ARRAY
          Character constant indicating an array type in a signature.
static char C_COLON
          Character constant indicating the colon in a signature.
static char C_COMPILATION_UNIT
          Character constant indicating a compilation unit.
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_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_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.
static int CLASS_TYPE_SIGNATURE
          Kind constant for a class type signature.
static String SIG_ANY
           
static String SIG_COMPILATION_UNIT
           
static String SIG_VOID
          String constant for the signature of result type void.
 
Method Summary
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 String createArraySignature(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 String createMethodSignature(String[] parameterTypes, String returnType)
          Creates a method signature from the given parameter and return type signatures.
static String createTypeSignature(char[] typeName, boolean isResolved)
          Creates a new type signature from the given type name encoded as a character array.
static String createTypeSignature(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(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 String getElementType(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(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 String getQualifier(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 String getReturnType(String methodSignature)
          Extracts the return type from the given method signature.
static char[] getSignatureQualifier(char[] typeSignature)
          Returns package fragment of a type signature.
static String getSignatureQualifier(String typeSignature)
          Returns package fragment of a type signature.
static char[] getSignatureSimpleName(char[] typeSignature)
          Returns type fragment of a type signature.
static String getSignatureSimpleName(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 String getSimpleName(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 int getTypeSignatureKind(char[] typeSignature)
          Returns the kind of type signature encoded by the given string.
static int getTypeSignatureKind(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 String getTypeVariable(String formalTypeParameterSignature)
          Extracts the type variable name from the given formal type parameter 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 String toQualifiedName(String[] segments)
          Converts the given array of qualified name segments to a qualified name.
static String toString(String signature)
          Converts the given type signature to a readable string.
static String toString(String methodSignature, String methodName, String[] parameterNames, boolean fullyQualifyTypeNames, boolean includeReturnType)
          Converts the given method signature to a readable string.
static String toString(String methodSignature, String methodName, String[] parameterNames, boolean fullyQualifyTypeNames, boolean includeReturnType, boolean isVarArgs)
          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_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 ':'. 3.0

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_ANY

public static final char C_ANY
Character constant indicating any type in a signature. Value is 'A'.

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_COMPILATION_UNIT

public static final char C_COMPILATION_UNIT
Character constant indicating a compilation unit. Value is 'X'.

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

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

SIG_ANY

public static final String SIG_ANY
See Also:
Constant Field Values

SIG_COMPILATION_UNIT

public static final String SIG_COMPILATION_UNIT
See Also:
Constant Field Values

CLASS_TYPE_SIGNATURE

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

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.

See Also:
getTypeSignatureKind(String), Constant Field Values

ARRAY_TYPE_SIGNATURE

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

See Also:
getTypeSignatureKind(String), Constant Field Values

ANY

public static final char[] ANY
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 signature
arrayCount - the desired number of levels of array nesting
Returns:
the encoded array type signature

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 signature
arrayCount - the desired number of levels of array nesting
Returns:
the encoded array 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.

Parameters:
parameterTypes - the list of parameter type signatures
returnType - the return type signature
Returns:
the encoded method signature

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 to createMethodSignature(parameterTypes, returnType).

Parameters:
parameterTypes - the list of parameter type signatures
returnType - the return type signature
Returns:
the encoded method signature
See Also:
createMethodSignature(char[][], char[])

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 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.

Parameters:
typeName - the possibly qualified type name
isResolved - true if the type name is to be considered resolved (for example, a type name from a binary class file), and false if 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)

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. 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.

Parameters:
typeName - the possibly qualified type name
isResolved - true if the type name is to be considered resolved (for example, a type name from a binary class file), and false if 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 name
isResolved - true if the type name is to be considered resolved (for example, a type name from a binary class file), and false if 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 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

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

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

getParameterCount

public static int getParameterCount(char[] 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

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, or #TYPE_VARIABLE_SIGNATURE, or #CAPTURE_TYPE_SIGNATURE
Throws:
IllegalArgumentException - if this is not a type signature

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, or #TYPE_VARIABLE_SIGNATURE, or #CAPTURE_TYPE_SIGNATURE
Throws:
IllegalArgumentException - if this is not a type signature

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

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

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

getTypeVariable

public static char[] getTypeVariable(char[] 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

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

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

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 '.')

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 '.')

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 '.')

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 '.')

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

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

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

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 convert
methodName - the name of the method to insert in the result, or null if no method name is to be included
parameterNames - the parameter names to insert in the result, or null if no parameter names are to be included; if supplied, the number of parameter names must match that of the method signature
fullyQualifyTypeNames - true if type names should be fully qualified, and false to use only simple names
includeReturnType - true if the return type is to be included
Returns:
the char array representation of the method signature

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 convert
methodName - the name of the method to insert in the result, or null if no method name is to be included
parameterNames - the parameter names to insert in the result, or null if no parameter names are to be included; if supplied, the number of parameter names must match that of the method signature
fullyQualifyTypeNames - true if type names should be fully qualified, and false to use only simple names
includeReturnType - true if the return type is to be included
isVargArgs - true if the last argument should be displayed as a variable argument, false otherwise.
Returns:
the char array representation of the method signature

toCharArray

public static char[] toCharArray(char[] signature)
                          throws 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'}
 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 not syntactically correct

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

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 convert
methodName - the name of the method to insert in the result, or null if no method name is to be included
parameterNames - the parameter names to insert in the result, or null if no parameter names are to be included; if supplied, the number of parameter names must match that of the method signature
fullyQualifyTypeNames - true if type names should be fully qualified, and false to use only simple names
includeReturnType - true if 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 convert
methodName - the name of the method to insert in the result, or null if no method name is to be included
parameterNames - the parameter names to insert in the result, or null if no parameter names are to be included; if supplied, the number of parameter names must match that of the method signature
fullyQualifyTypeNames - true if type names should be fully qualified, and false to use only simple names
includeReturnType - true if the return type is to be included
isVarArgs - true if the last argument should be displayed as a variable argument, false otherwise
Returns:
the string representation of the method signature
See Also:
toCharArray(char[], char[], char[][], boolean, boolean)

JavaScript Development Tools
Release 3.2

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