From 6f8a8b943600d50949a7b934bb1f5c400475f283 Mon Sep 17 00:00:00 2001 From: Marcin Olawski Date: Fri, 6 Feb 2015 20:07:51 +0100 Subject: [PATCH] Added Character.isJavaIdentifierStart(int), isJavaIdentifierPart(int) and made isJavaIdentifierStart(char), isJavaIdentifierPart(char) more compact. --- classpath/java/lang/Character.java | 34 +++++++++++------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/classpath/java/lang/Character.java b/classpath/java/lang/Character.java index 0c84a84209..6338debbb5 100644 --- a/classpath/java/lang/Character.java +++ b/classpath/java/lang/Character.java @@ -175,32 +175,22 @@ public final class Character implements Comparable { } public static boolean isJavaIdentifierStart(char ch) { - if (isLetter(ch)){ - return true; - } - if (ch == '$'){ //TODO: if (getType(ch)==CURRENCY_SYMBOL) - return true; - } - if (ch == '_'){ - return true; - } - //TODO: if (getType(ch)==LETTER_NUMBER) return true - - return false; + return isLetter(ch) || ch == '$' || ch == '_'; + //TODO: add if (getType(ch)==LETTER_NUMBER) || getType(ch)==CURRENCY_SYMBOL + } + + 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 - - return false; + //add isIdentifierIgnorable(ch) + } + + public static boolean isJavaIdentifierPart(int c) { + return canCastToChar(c) && isJavaIdentifierPart((char) c); } public static int toCodePoint(char high, char low) {