int len = signature.length();
int j = Strings.skipWhitespaces(signature, 0);
int k = Strings.anyOf(signature, "( \t\n\r", j);
k = Strings.skipWhitespaces(signature, k);
if (k >= len)
throw new IllegalSyntaxException(signature);
String returnType = null;
char cc = signature.charAt(k);
if (cc != '(') {
//skip the return type
returnType = signature.substring(j, k).trim();
//
j = k;
k = signature.indexOf('(', j + 1);
if (k < 0)
throw new IllegalSyntaxException(signature);
}
String method = signature.substring(j, k).trim();
Collection argTypes = new LinkedList();
Collection argNames = new LinkedList();
do {
j = Strings.skipWhitespaces(signature, k + 1);
if (signature.charAt(j) == ')') break;
k = Strings.anyOf(signature, ",) \t\n\r", j);
k = Strings.skipWhitespaces(signature, k);
if (k >= len)
throw new IllegalSyntaxException(signature);
argTypes.add(signature.substring(j, k).trim());
cc = signature.charAt(k);
if (cc != ',' && cc != ')') { //parameter name found
k = Strings.anyOf(signature, ",) \t\n\r", j = k);
k = Strings.skipWhitespaces(signature, k);
argNames.add(signature.substring(j, k).trim());
k = Strings.anyOf(signature, ",)", k);
if (k >= len)
throw new IllegalSyntaxException(signature);
} else {
argNames.add(""); //no name specified
}
} while (signature.charAt(k) == ',');