harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r446549 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/lang/Character.java test/java/org/apache/harmony/luni/tests/java/lang/CharacterTest.java
Date Fri, 15 Sep 2006 08:44:21 GMT
Author: hindessm
Date: Fri Sep 15 01:44:20 2006
New Revision: 446549

URL: http://svn.apache.org/viewvc?view=rev&rev=446549
Log:
Applying patch from "[#HARMONY-1460] [classlib][luni]new method
toUpperCase(int),toTitleCase(int),toLowerCase(int),isUnicodeIdentifierStart(int),isUnicodeIdentifierPart(int)
in j.l.Character".

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/CharacterTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java?view=diff&rev=446549&r1=446548&r2=446549
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java
Fri Sep 15 01:44:20 2006
@@ -32,7 +32,7 @@
  * 
  * <p>
  * Character data is based upon the Unicode Standard, 4.0. The Unicode
- * specification, character tables and other information is available at <a
+ * specification, character tables and other information are available at <a
  * href="http://www.unicode.org/">http://www.unicode.org/</a>.
  * </p>
  * 
@@ -424,7 +424,7 @@
 
     /**
      * <p>
-     * Minimum value of a supplementary code point - <code>U+0010000</code>.
+     * Minimum value of a supplementary code point - <code>U+010000</code>.
      * </p>
      * 
      * @since 1.5
@@ -523,16 +523,16 @@
 		}
 
 		/**
-		 * Compares the specified object to this Subset and answer if they are
-		 * equal. The object must be the same instance of Subset.
-		 * 
-		 * @param object
-		 *            the object to compare
-		 * @return true if the specified object is equal to this Subset, false
-		 *         otherwise
-		 * 
-		 * @see #hashCode
-		 */
+         * Compares the specified object to this Subset and answers true if they
+         * are equal. The object must be the same instance of Subset.
+         * 
+         * @param object
+         *            the object to compare
+         * @return true if the specified object is equal to this Subset, false
+         *         otherwise
+         * 
+         * @see #hashCode
+         */
 		@Override
         public final boolean equals(Object object) {
 			return super.equals(object);
@@ -569,7 +569,7 @@
     public static final class UnicodeBlock extends Subset {
         /**
          * The &quot;Surrogates Area&quot; Unicode Block. 
-         * @deprecated As of Java 5, this block as been replaced by {@link #HIGH_SURROGATES},
{@link #HIGH_PRIVATE_USE_SURROGATES} and {@link #LOW_SURROGATES}.
+         * @deprecated As of Java 5, this block has been replaced by {@link #HIGH_SURROGATES},
{@link #HIGH_PRIVATE_USE_SURROGATES} and {@link #LOW_SURROGATES}.
          */
         @Deprecated
         public static final UnicodeBlock SURROGATES_AREA = new UnicodeBlock("SURROGATES_AREA",
0x0, 0x0);
@@ -1665,17 +1665,18 @@
 	}
 
 	/**
-	 * Compare 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 <code>c</code> is <code>null</code>.
+     * 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 <code>c</code> is <code>null</code>.
      * @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 <code>c</code> is <b>not</b> a lower case character
then
-	 *         its lower case counterpart, otherwise just <code>c</code>
-	 */
+     * 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 <code>c</code> is <b>not</b> an upper case character
then
-	 *         its upper case counterpart, otherwise just <code>c</code>
-	 */
+     * 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);
+    }
+
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/CharacterTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/CharacterTest.java?view=diff&rev=446549&r1=446548&r2=446549
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/CharacterTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/CharacterTest.java
Fri Sep 15 01:44:20 2006
@@ -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,6 +1260,34 @@
         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)
@@ -1341,5 +1445,20 @@
                 'A', Character.toUpperCase('A'));
         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));
     }
 }



Mime
View raw message