Added Character.isJavaIdentifierStart(int), isJavaIdentifierPart(int) and made isJavaIdentifierStart(char), isJavaIdentifierPart(char) more compact.

This commit is contained in:
Marcin Olawski 2015-02-06 20:07:51 +01:00
parent ab3ee4c6e2
commit 6f8a8b9436

View File

@ -175,32 +175,22 @@ public final class Character implements Comparable<Character> {
}
public static boolean isJavaIdentifierStart(char ch) {
if (isLetter(ch)){
return true;
return isLetter(ch) || ch == '$' || ch == '_';
//TODO: add if (getType(ch)==LETTER_NUMBER) || getType(ch)==CURRENCY_SYMBOL
}
if (ch == '$'){ //TODO: if (getType(ch)==CURRENCY_SYMBOL)
return true;
}
if (ch == '_'){
return true;
}
//TODO: if (getType(ch)==LETTER_NUMBER) return true
return false;
public static boolean isJavaIdentifierStart(int c) {
return canCastToChar(c) && isJavaIdentifierStart((char) c);
}
public static boolean isJavaIdentifierPart(char ch) {
if (isJavaIdentifierStart(ch)){
return true;
}
if (isDigit(ch)){
return true;
}
return isJavaIdentifierStart(ch) || isDigit(ch);
//TODO:Check for numeric letters (such as a Roman numeral character),combining marks,non-spacing marks
//if (isIdentifierIgnorable(ch)) return true
//add isIdentifierIgnorable(ch)
}
return false;
public static boolean isJavaIdentifierPart(int c) {
return canCastToChar(c) && isJavaIdentifierPart((char) c);
}
public static int toCodePoint(char high, char low) {