From ab3ee4c6e28f3912e04fe42f9f8e3d2b222290fb Mon Sep 17 00:00:00 2001 From: Marcin Olawski Date: Fri, 6 Feb 2015 15:26:40 +0100 Subject: [PATCH] Add Character.isJavaIdentifierStart(char ch) and isJavaIdentifierPart(char ch) --- classpath/java/lang/Character.java | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/classpath/java/lang/Character.java b/classpath/java/lang/Character.java index f1b535171d..0c84a84209 100644 --- a/classpath/java/lang/Character.java +++ b/classpath/java/lang/Character.java @@ -174,6 +174,35 @@ public final class Character implements Comparable { return ch <= '\u001F' || (ch >= '\u007F' && ch <= '\u009F'); } + 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; + } + + public static boolean isJavaIdentifierPart(char ch) { + if (isJavaIdentifierStart(ch)){ + return true; + } + if (isDigit(ch)){ + return true; + } + + //TODO:Check for numeric letters (such as a Roman numeral character),combining marks,non-spacing marks + //if (isIdentifierIgnorable(ch)) return true + + return false; + } + public static int toCodePoint(char high, char low) { return (((high & 0x3FF) << 10) | (low & 0x3FF)) + 0x10000; }