Index: src/test/java/org/apache/harmony/luni/tests/java/lang/CharacterTest.java =================================================================== --- src/test/java/org/apache/harmony/luni/tests/java/lang/CharacterTest.java (revision 443179) +++ src/test/java/org/apache/harmony/luni/tests/java/lang/CharacterTest.java (working copy) @@ -1199,6 +1199,53 @@ assertTrue("'2' returned false", Character.isUnicodeIdentifierPart('2')); assertTrue("'+' returned true", !Character.isUnicodeIdentifierPart('+')); } + + /** + * @tests java.lang.Character#isUnicodeIdentifierPart(int) + */ + public void test_isUnicodeIdentifierPart_I() { + assertTrue(Character.isUnicodeIdentifierPart((int)'a')); + assertTrue(Character.isUnicodeIdentifierPart((int)'2')); + assertFalse(Character.isUnicodeIdentifierPart((int)'+')); + + assertTrue(Character.isUnicodeIdentifierPart(0x1FA9)); + assertTrue(Character.isUnicodeIdentifierPart(0x1D400)); + assertTrue(Character.isUnicodeIdentifierPart(0x1D622)); + assertTrue(Character.isUnicodeIdentifierPart(0x10000)); + + assertTrue(Character.isUnicodeIdentifierPart(0x0030)); + assertTrue(Character.isUnicodeIdentifierPart(0x0035)); + assertTrue(Character.isUnicodeIdentifierPart(0x0039)); + + assertTrue(Character.isUnicodeIdentifierPart(0x0660)); + assertTrue(Character.isUnicodeIdentifierPart(0x0665)); + assertTrue(Character.isUnicodeIdentifierPart(0x0669)); + + assertTrue(Character.isUnicodeIdentifierPart(0x06F0)); + assertTrue(Character.isUnicodeIdentifierPart(0x06F5)); + assertTrue(Character.isUnicodeIdentifierPart(0x06F9)); + + assertTrue(Character.isUnicodeIdentifierPart(0x0966)); + assertTrue(Character.isUnicodeIdentifierPart(0x096A)); + assertTrue(Character.isUnicodeIdentifierPart(0x096F)); + + assertTrue(Character.isUnicodeIdentifierPart(0xFF10)); + assertTrue(Character.isUnicodeIdentifierPart(0xFF15)); + assertTrue(Character.isUnicodeIdentifierPart(0xFF19)); + + assertTrue(Character.isUnicodeIdentifierPart(0x1D7CE)); + assertTrue(Character.isUnicodeIdentifierPart(0x1D7D8)); + + assertTrue(Character.isUnicodeIdentifierPart(0x16EE)); + assertTrue(Character.isUnicodeIdentifierPart(0xFE33)); + assertTrue(Character.isUnicodeIdentifierPart(0xFF10)); + assertTrue(Character.isUnicodeIdentifierPart(0x1D165)); + assertTrue(Character.isUnicodeIdentifierPart(0x1D167)); + assertTrue(Character.isUnicodeIdentifierPart(0x1D173)); + + assertFalse(Character.isUnicodeIdentifierPart(0x10FFFF)); + assertFalse(Character.isUnicodeIdentifierPart(0x110000)); + } /** * @tests java.lang.Character#isUnicodeIdentifierStart(char) @@ -1213,7 +1260,35 @@ assertTrue("'+' returned true", !Character .isUnicodeIdentifierStart('+')); } + + /** + * @tests java.lang.Character#isUnicodeIdentifierStart(int) + */ + public void test_isUnicodeIdentifierStart_I() { + + assertTrue(Character.isUnicodeIdentifierStart((int) 'a')); + assertFalse(Character.isUnicodeIdentifierStart((int) '2')); + assertFalse(Character.isUnicodeIdentifierStart((int) '+')); + assertTrue(Character.isUnicodeIdentifierStart(0x1FA9)); + assertTrue(Character.isUnicodeIdentifierStart(0x1D400)); + assertTrue(Character.isUnicodeIdentifierStart(0x1D622)); + assertTrue(Character.isUnicodeIdentifierStart(0x10000)); + + assertTrue(Character.isUnicodeIdentifierStart(0x16EE)); + + // number is not a valid start of a Unicode identifier + assertFalse(Character.isUnicodeIdentifierStart(0x0030)); + assertFalse(Character.isUnicodeIdentifierStart(0x0039)); + assertFalse(Character.isUnicodeIdentifierStart(0x0660)); + assertFalse(Character.isUnicodeIdentifierStart(0x0669)); + assertFalse(Character.isUnicodeIdentifierStart(0x06F0)); + assertFalse(Character.isUnicodeIdentifierStart(0x06F9)); + + assertFalse(Character.isUnicodeIdentifierPart(0x10FFFF)); + assertFalse(Character.isUnicodeIdentifierPart(0x110000)); + } + /** * @tests java.lang.Character#isUpperCase(char) */ @@ -1307,6 +1382,20 @@ // Test for method char java.lang.Character.toLowerCase(char) assertEquals("Failed to change case", 't', Character.toLowerCase('T')); } + + /** + * @tests java.lang.Character#toLowerCase(int) + */ + public void test_toLowerCase_I() { + assertEquals((int)'t', Character.toLowerCase((int)'T')); + + assertEquals(0x10428, Character.toLowerCase(0x10400)); + assertEquals(0x10428, Character.toLowerCase(0x10428)); + + assertEquals(0x1D504, Character.toLowerCase(0x1D504)); + assertEquals(0x10FFFD, Character.toLowerCase(0x10FFFD)); + assertEquals(0x110000, Character.toLowerCase(0x110000)); + } /** * @tests java.lang.Character#toString() @@ -1329,6 +1418,21 @@ assertEquals("Incorrect title case for 1", '1', Character.toTitleCase('1')); } + + /** + * @tests java.lang.Character#toTitleCase(int) + */ + public void test_toTitleCase_I() { + assertEquals((int)'A', Character.toTitleCase((int)'a')); + assertEquals((int)'A', Character.toTitleCase((int)'A')); + assertEquals((int)'1', Character.toTitleCase((int)'1')); + + assertEquals(0x10400, Character.toTitleCase(0x10428)); + assertEquals(0x10400, Character.toTitleCase(0x10400)); + + assertEquals(0x10FFFF, Character.toTitleCase(0x10FFFF)); + assertEquals(0x110000, Character.toTitleCase(0x110000)); + } /** * @tests java.lang.Character#toUpperCase(char) @@ -1342,4 +1446,19 @@ assertEquals("Incorrect upper case for 1", '1', Character.toUpperCase('1')); } + + /** + * @tests java.lang.Character#toUpperCase(int) + */ + public void test_toUpperCase_I() { + assertEquals((int)'A', Character.toUpperCase((int)'a')); + assertEquals((int)'A', Character.toUpperCase((int)'A')); + assertEquals((int)'1', Character.toUpperCase((int)'1')); + + assertEquals(0x10400, Character.toUpperCase(0x10428)); + assertEquals(0x10400, Character.toUpperCase(0x10400)); + + assertEquals(0x10FFFF, Character.toUpperCase(0x10FFFF)); + assertEquals(0x110000, Character.toUpperCase(0x110000)); + } } Index: src/main/java/java/lang/Character.java =================================================================== --- src/main/java/java/lang/Character.java (revision 443179) +++ src/main/java/java/lang/Character.java (working copy) @@ -32,7 +32,7 @@ * *
* Character data is based upon the Unicode Standard, 4.0. The Unicode - * specification, character tables and other information is available at http://www.unicode.org/. *
* @@ -424,7 +424,7 @@ /** *
- * Minimum value of a supplementary code point - U+0010000.
+ * Minimum value of a supplementary code point - U+010000.
*
c is null.
+ * Compares the receiver to the specified Character to determine the
+ * relative ordering.
+ *
+ * @param c
+ * the Character
+ * @return an int < 0 if this Character is less than the specified
+ * Character, 0 if they are equal, and > 0 if this Character is
+ * greater
+ * @throws NullPointerException
+ * if c is null.
* @since 1.2
- */
+ */
public int compareTo(Character c) {
return value - c.value;
}
@@ -2716,14 +2717,14 @@
}
/**
- * Answers whether the character is valid as any character except the first
- * in a Java identifier.
- *
- * @param c
- * the character
- * @return true when the character is valid as part of a Java identifier,
- * false otherwise
- */
+ * Answers whether the character is a valid part of a Unicode identifier as
+ * other than the first character.
+ *
+ * @param c
+ * the character
+ * @return true when the character is valid as part of a Java identifier,
+ * false otherwise
+ */
public static boolean isJavaIdentifierPart(char c) {
// Optimized case for ASCII
if (c < 128) {
@@ -2739,8 +2740,8 @@
}
/**
- * Answers whether the character is a valid initial character for a Java
- * identifier.
+ * Answers whether the character is a valid part of a Unicode identifier as
+ * other than the first character.
*
* @param c
* the character
@@ -2943,14 +2944,14 @@
}
/**
- * Answers whether the character is valid as any character except the first
- * in a Unicode identifier.
- *
- * @param c
- * the character
- * @return true when the character is valid as part of a Unicode identifier,
- * false otherwise
- */
+ * Answers whether the character is valid as part of a Unicode identifier as
+ * other than the first character.
+ *
+ * @param c
+ * the character
+ * @return true when the character is valid as part of a Unicode identifier,
+ * false otherwise
+ */
public static boolean isUnicodeIdentifierPart(char c) {
int type = getType(c);
return (type >= UPPERCASE_LETTER && type <= OTHER_LETTER)
@@ -2959,6 +2960,19 @@
|| type == NON_SPACING_MARK || type == COMBINING_SPACING_MARK
|| isIdentifierIgnorable(c);
}
+
+ /**
+ * Answers whether the character is valid as part of a Unicode identifier as
+ * other than the first character.
+ *
+ * @param codePoint
+ * the character, including supplementary characters
+ * @return true when the character is valid as part of a Unicode identifier,
+ * false otherwise
+ */
+ public static boolean isUnicodeIdentifierPart(int codePoint) {
+ return UCharacter.isUnicodeIdentifierPart(codePoint);
+ }
/**
* Answers whether the character is a valid initial character for a Unicode
@@ -2974,6 +2988,19 @@
return (type >= UPPERCASE_LETTER && type <= OTHER_LETTER)
|| type == LETTER_NUMBER;
}
+
+ /**
+ * Answers whether the character is a valid initial character for a Unicode
+ * identifier.
+ *
+ * @param codePoint
+ * the character, including supplementary characters
+ * @return true when the character is a valid start of a Unicode identifier,
+ * false otherwise
+ */
+ public static boolean isUnicodeIdentifierStart(int codePoint) {
+ return UCharacter.isUnicodeIdentifierStart(codePoint);
+ }
/**
* Answers whether the character is an upper case letter.
@@ -3052,14 +3079,14 @@
}
/**
- * Answers the lower case equivalent for the character when the character is
- * an upper case letter, otherwise answer the character.
- *
- * @param c
- * the character
- * @return if c is not a lower case character then
- * its lower case counterpart, otherwise just c
- */
+ * Answers the lower case equivalent for the character when the character is
+ * an upper case letter, otherwise answers the character.
+ *
+ * @param c
+ * the character
+ * @return if c is not a lower case character then its lower case
+ * counterpart, otherwise just c
+ */
public static char toLowerCase(char c) {
// Optimized case for ASCII
if ('A' <= c && c <= 'Z') {
@@ -3088,6 +3115,19 @@
}
return c;
}
+
+ /**
+ * Answers the lower case equivalent for the character when the character is
+ * an upper case letter, otherwise answers the character.
+ *
+ * @param codePoint
+ * the character, including supplementary characters
+ * @return if codePoint is not a lower case character then its lower case
+ * counterpart, otherwise just codePoint
+ */
+ public static int toLowerCase(int codePoint) {
+ return UCharacter.toLowerCase(codePoint);
+ }
/**
* Answers a string containing a concise, human-readable description of the
@@ -3112,7 +3152,7 @@
}
/**
- * Answers the title case equivalent for the character, otherwise answer the
+ * Answers the title case equivalent for the character, otherwise answers the
* character.
*
* @param c
@@ -3129,16 +3169,28 @@
}
return toUpperCase(c);
}
+
+ /**
+ * Answers the title case equivalent for the character, otherwise answers the
+ * character.
+ *
+ * @param codePoint
+ * the character
+ * @return the title case equivalent of the character
+ */
+ public static int toTitleCase(int codePoint) {
+ return UCharacter.toTitleCase(codePoint);
+ }
/**
- * Answers the upper case equivalent for the character when the character is
- * a lower case letter, otherwise answer the character.
- *
- * @param c
- * the character
- * @return if c is not an upper case character then
- * its upper case counterpart, otherwise just c
- */
+ * Answers the upper case equivalent for the character when the character is
+ * a lower case letter, otherwise answers the character.
+ *
+ * @param c
+ * the character
+ * @return if c is not an upper case character then its upper case
+ * counterpart, otherwise just c
+ */
public static char toUpperCase(char c) {
// Optimized case for ASCII
if ('a' <= c && c <= 'z') {
@@ -3167,4 +3219,18 @@
}
return c;
}
+
+ /**
+ * Answers the upper case equivalent for the character when the character is
+ * a lower case letter, otherwise answers the character.
+ *
+ * @param codePoint
+ * the character, including supplementary characters
+ * @return if codePoint is not an upper case character then its upper case
+ * counterpart, otherwise just codePoint
+ */
+ public static int toUpperCase(int codePoint) {
+ return UCharacter.toUpperCase(codePoint);
+ }
+
}