Commit b6e8336a authored by Elliott Hughes's avatar Elliott Hughes Committed by Gerrit Code Review
Browse files

Merge "Implement Character.isAlphabetic and Character.isIdeographic."

parents 9642a650 2d99feb3
......@@ -2594,6 +2594,13 @@ public final class Character implements Serializable, Comparable<Character> {
return (char) ((codePoint & 0x3ff) | 0xdc00);
}
/**
* Returns true if the given code point is alphabetic. That is,
* if it is in any of the Lu, Ll, Lt, Lm, Lo, Nl, or Other_Alphabetic categories.
* @since 1.7
*/
public static native boolean isAlphabetic(int codePoint);
/**
* Returns true if the given code point is in the Basic Multilingual Plane (BMP).
* Such code points can be represented by a single {@code char}.
......@@ -2676,6 +2683,12 @@ public final class Character implements Serializable, Comparable<Character> {
return isIdentifierIgnorable((int) c);
}
/**
* Returns true if the given code point is a CJKV ideographic character.
* @since 1.7
*/
public static native boolean isIdeographic(int codePoint);
/**
* Indicates whether the specified code point is ignorable in a Java or
* Unicode identifier.
......
......@@ -135,6 +135,14 @@ static int Character_ofImpl(JNIEnv*, jclass, jint codePoint) {
return ublock_getCode(codePoint);
}
static jboolean Character_isAlphabetic(JNIEnv*, jclass, jint codePoint) {
return u_hasBinaryProperty(codePoint, UCHAR_ALPHABETIC);
}
static jboolean Character_isIdeographic(JNIEnv*, jclass, jint codePoint) {
return u_hasBinaryProperty(codePoint, UCHAR_IDEOGRAPHIC);
}
static JNINativeMethod gMethods[] = {
NATIVE_METHOD(Character, digitImpl, "!(II)I"),
NATIVE_METHOD(Character, forNameImpl, "(Ljava/lang/String;)I"),
......@@ -142,9 +150,11 @@ static JNINativeMethod gMethods[] = {
NATIVE_METHOD(Character, getNameImpl, "(I)Ljava/lang/String;"),
NATIVE_METHOD(Character, getNumericValueImpl, "!(I)I"),
NATIVE_METHOD(Character, getTypeImpl, "!(I)I"),
NATIVE_METHOD(Character, isAlphabetic, "!(I)Z"),
NATIVE_METHOD(Character, isDefinedImpl, "!(I)Z"),
NATIVE_METHOD(Character, isDigitImpl, "!(I)Z"),
NATIVE_METHOD(Character, isIdentifierIgnorableImpl, "!(I)Z"),
NATIVE_METHOD(Character, isIdeographic, "!(I)Z"),
NATIVE_METHOD(Character, isLetterImpl, "!(I)Z"),
NATIVE_METHOD(Character, isLetterOrDigitImpl, "!(I)Z"),
NATIVE_METHOD(Character, isLowerCaseImpl, "!(I)Z"),
......
......@@ -171,4 +171,22 @@ public class CharacterTest extends junit.framework.TestCase {
assertEquals(Character.UnicodeBlock.CYRILLIC_SUPPLEMENTARY, Character.UnicodeBlock.forName("Cyrillic Supplementary"));
assertEquals(Character.UnicodeBlock.CYRILLIC_SUPPLEMENTARY, Character.UnicodeBlock.forName("Cyrillic Supplement"));
}
public void test_isAlphabetic() throws Exception {
assertTrue(Character.isAlphabetic('A'));
assertTrue(Character.isAlphabetic('a'));
assertFalse(Character.isAlphabetic('1'));
assertTrue(Character.isAlphabetic(0x113c)); // Hangul j
}
public void test_isIdeographic() throws Exception {
assertFalse(Character.isIdeographic('A'));
assertFalse(Character.isIdeographic('a'));
assertFalse(Character.isIdeographic('1'));
assertFalse(Character.isIdeographic(0x113c)); // Hangul j
assertTrue(Character.isIdeographic(0x4db5));
assertTrue(Character.isIdeographic(0x2f999));
assertFalse(Character.isIdeographic(0x2f99)); // Kangxi radical shell
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment