1.1 --- a/emul/mini/src/main/java/java/lang/Character.java Wed Jan 23 23:17:03 2013 +0100
1.2 +++ b/emul/mini/src/main/java/java/lang/Character.java Wed Jan 23 23:17:46 2013 +0100
1.3 @@ -1895,7 +1895,140 @@
1.4 static int getType(int x) {
1.5 throw new UnsupportedOperationException();
1.6 }
1.7 -
1.8 +
1.9 + /**
1.10 + * Determines if the specified character is
1.11 + * permissible as the first character in a Java identifier.
1.12 + * <p>
1.13 + * A character may start a Java identifier if and only if
1.14 + * one of the following conditions is true:
1.15 + * <ul>
1.16 + * <li> {@link #isLetter(char) isLetter(ch)} returns {@code true}
1.17 + * <li> {@link #getType(char) getType(ch)} returns {@code LETTER_NUMBER}
1.18 + * <li> {@code ch} is a currency symbol (such as {@code '$'})
1.19 + * <li> {@code ch} is a connecting punctuation character (such as {@code '_'}).
1.20 + * </ul>
1.21 + *
1.22 + * <p><b>Note:</b> This method cannot handle <a
1.23 + * href="#supplementary"> supplementary characters</a>. To support
1.24 + * all Unicode characters, including supplementary characters, use
1.25 + * the {@link #isJavaIdentifierStart(int)} method.
1.26 + *
1.27 + * @param ch the character to be tested.
1.28 + * @return {@code true} if the character may start a Java identifier;
1.29 + * {@code false} otherwise.
1.30 + * @see Character#isJavaIdentifierPart(char)
1.31 + * @see Character#isLetter(char)
1.32 + * @see Character#isUnicodeIdentifierStart(char)
1.33 + * @see javax.lang.model.SourceVersion#isIdentifier(CharSequence)
1.34 + * @since 1.1
1.35 + */
1.36 + public static boolean isJavaIdentifierStart(char ch) {
1.37 + return isJavaIdentifierStart((int)ch);
1.38 + }
1.39 +
1.40 + /**
1.41 + * Determines if the character (Unicode code point) is
1.42 + * permissible as the first character in a Java identifier.
1.43 + * <p>
1.44 + * A character may start a Java identifier if and only if
1.45 + * one of the following conditions is true:
1.46 + * <ul>
1.47 + * <li> {@link #isLetter(int) isLetter(codePoint)}
1.48 + * returns {@code true}
1.49 + * <li> {@link #getType(int) getType(codePoint)}
1.50 + * returns {@code LETTER_NUMBER}
1.51 + * <li> the referenced character is a currency symbol (such as {@code '$'})
1.52 + * <li> the referenced character is a connecting punctuation character
1.53 + * (such as {@code '_'}).
1.54 + * </ul>
1.55 + *
1.56 + * @param codePoint the character (Unicode code point) to be tested.
1.57 + * @return {@code true} if the character may start a Java identifier;
1.58 + * {@code false} otherwise.
1.59 + * @see Character#isJavaIdentifierPart(int)
1.60 + * @see Character#isLetter(int)
1.61 + * @see Character#isUnicodeIdentifierStart(int)
1.62 + * @see javax.lang.model.SourceVersion#isIdentifier(CharSequence)
1.63 + * @since 1.5
1.64 + */
1.65 + public static boolean isJavaIdentifierStart(int codePoint) {
1.66 + return
1.67 + ('A' <= codePoint && codePoint <= 'Z') ||
1.68 + ('a' <= codePoint && codePoint <= 'z');
1.69 + }
1.70 +
1.71 + /**
1.72 + * Determines if the specified character may be part of a Java
1.73 + * identifier as other than the first character.
1.74 + * <p>
1.75 + * A character may be part of a Java identifier if any of the following
1.76 + * are true:
1.77 + * <ul>
1.78 + * <li> it is a letter
1.79 + * <li> it is a currency symbol (such as {@code '$'})
1.80 + * <li> it is a connecting punctuation character (such as {@code '_'})
1.81 + * <li> it is a digit
1.82 + * <li> it is a numeric letter (such as a Roman numeral character)
1.83 + * <li> it is a combining mark
1.84 + * <li> it is a non-spacing mark
1.85 + * <li> {@code isIdentifierIgnorable} returns
1.86 + * {@code true} for the character
1.87 + * </ul>
1.88 + *
1.89 + * <p><b>Note:</b> This method cannot handle <a
1.90 + * href="#supplementary"> supplementary characters</a>. To support
1.91 + * all Unicode characters, including supplementary characters, use
1.92 + * the {@link #isJavaIdentifierPart(int)} method.
1.93 + *
1.94 + * @param ch the character to be tested.
1.95 + * @return {@code true} if the character may be part of a
1.96 + * Java identifier; {@code false} otherwise.
1.97 + * @see Character#isIdentifierIgnorable(char)
1.98 + * @see Character#isJavaIdentifierStart(char)
1.99 + * @see Character#isLetterOrDigit(char)
1.100 + * @see Character#isUnicodeIdentifierPart(char)
1.101 + * @see javax.lang.model.SourceVersion#isIdentifier(CharSequence)
1.102 + * @since 1.1
1.103 + */
1.104 + public static boolean isJavaIdentifierPart(char ch) {
1.105 + return isJavaIdentifierPart((int)ch);
1.106 + }
1.107 +
1.108 + /**
1.109 + * Determines if the character (Unicode code point) may be part of a Java
1.110 + * identifier as other than the first character.
1.111 + * <p>
1.112 + * A character may be part of a Java identifier if any of the following
1.113 + * are true:
1.114 + * <ul>
1.115 + * <li> it is a letter
1.116 + * <li> it is a currency symbol (such as {@code '$'})
1.117 + * <li> it is a connecting punctuation character (such as {@code '_'})
1.118 + * <li> it is a digit
1.119 + * <li> it is a numeric letter (such as a Roman numeral character)
1.120 + * <li> it is a combining mark
1.121 + * <li> it is a non-spacing mark
1.122 + * <li> {@link #isIdentifierIgnorable(int)
1.123 + * isIdentifierIgnorable(codePoint)} returns {@code true} for
1.124 + * the character
1.125 + * </ul>
1.126 + *
1.127 + * @param codePoint the character (Unicode code point) to be tested.
1.128 + * @return {@code true} if the character may be part of a
1.129 + * Java identifier; {@code false} otherwise.
1.130 + * @see Character#isIdentifierIgnorable(int)
1.131 + * @see Character#isJavaIdentifierStart(int)
1.132 + * @see Character#isLetterOrDigit(int)
1.133 + * @see Character#isUnicodeIdentifierPart(int)
1.134 + * @see javax.lang.model.SourceVersion#isIdentifier(CharSequence)
1.135 + * @since 1.5
1.136 + */
1.137 + public static boolean isJavaIdentifierPart(int codePoint) {
1.138 + return isJavaIdentifierStart(codePoint) ||
1.139 + ('0' <= codePoint && codePoint <= '9');
1.140 + }
1.141 +
1.142 /**
1.143 * Converts the character argument to lowercase using case
1.144 * mapping information from the UnicodeData file.