# HG changeset patch # User Jaroslav Tulach # Date 1358979466 -3600 # Node ID 6bfc15870186d743700576d9eef3dc3cdf653c01 # Parent ded0000c296299efe7d9774e60b7f1fbf90a57f8 We need isJavaIdentifierStart/Part for the ServiceLoader diff -r ded0000c2962 -r 6bfc15870186 emul/mini/src/main/java/java/lang/Character.java --- a/emul/mini/src/main/java/java/lang/Character.java Wed Jan 23 23:17:03 2013 +0100 +++ b/emul/mini/src/main/java/java/lang/Character.java Wed Jan 23 23:17:46 2013 +0100 @@ -1895,7 +1895,140 @@ static int getType(int x) { throw new UnsupportedOperationException(); } - + + /** + * Determines if the specified character is + * permissible as the first character in a Java identifier. + *

+ * A character may start a Java identifier if and only if + * one of the following conditions is true: + *

+ * + *

Note: This method cannot handle supplementary characters. To support + * all Unicode characters, including supplementary characters, use + * the {@link #isJavaIdentifierStart(int)} method. + * + * @param ch the character to be tested. + * @return {@code true} if the character may start a Java identifier; + * {@code false} otherwise. + * @see Character#isJavaIdentifierPart(char) + * @see Character#isLetter(char) + * @see Character#isUnicodeIdentifierStart(char) + * @see javax.lang.model.SourceVersion#isIdentifier(CharSequence) + * @since 1.1 + */ + public static boolean isJavaIdentifierStart(char ch) { + return isJavaIdentifierStart((int)ch); + } + + /** + * Determines if the character (Unicode code point) is + * permissible as the first character in a Java identifier. + *

+ * A character may start a Java identifier if and only if + * one of the following conditions is true: + *

+ * + * @param codePoint the character (Unicode code point) to be tested. + * @return {@code true} if the character may start a Java identifier; + * {@code false} otherwise. + * @see Character#isJavaIdentifierPart(int) + * @see Character#isLetter(int) + * @see Character#isUnicodeIdentifierStart(int) + * @see javax.lang.model.SourceVersion#isIdentifier(CharSequence) + * @since 1.5 + */ + public static boolean isJavaIdentifierStart(int codePoint) { + return + ('A' <= codePoint && codePoint <= 'Z') || + ('a' <= codePoint && codePoint <= 'z'); + } + + /** + * Determines if the specified character may be part of a Java + * identifier as other than the first character. + *

+ * A character may be part of a Java identifier if any of the following + * are true: + *

+ * + *

Note: This method cannot handle supplementary characters. To support + * all Unicode characters, including supplementary characters, use + * the {@link #isJavaIdentifierPart(int)} method. + * + * @param ch the character to be tested. + * @return {@code true} if the character may be part of a + * Java identifier; {@code false} otherwise. + * @see Character#isIdentifierIgnorable(char) + * @see Character#isJavaIdentifierStart(char) + * @see Character#isLetterOrDigit(char) + * @see Character#isUnicodeIdentifierPart(char) + * @see javax.lang.model.SourceVersion#isIdentifier(CharSequence) + * @since 1.1 + */ + public static boolean isJavaIdentifierPart(char ch) { + return isJavaIdentifierPart((int)ch); + } + + /** + * Determines if the character (Unicode code point) may be part of a Java + * identifier as other than the first character. + *

+ * A character may be part of a Java identifier if any of the following + * are true: + *

+ * + * @param codePoint the character (Unicode code point) to be tested. + * @return {@code true} if the character may be part of a + * Java identifier; {@code false} otherwise. + * @see Character#isIdentifierIgnorable(int) + * @see Character#isJavaIdentifierStart(int) + * @see Character#isLetterOrDigit(int) + * @see Character#isUnicodeIdentifierPart(int) + * @see javax.lang.model.SourceVersion#isIdentifier(CharSequence) + * @since 1.5 + */ + public static boolean isJavaIdentifierPart(int codePoint) { + return isJavaIdentifierStart(codePoint) || + ('0' <= codePoint && codePoint <= '9'); + } + /** * Converts the character argument to lowercase using case * mapping information from the UnicodeData file.