harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lvj...@apache.org
Subject svn commit: r648676 - in /harmony/enhanced/classlib/trunk/modules/text/src: main/java/java/text/Normalizer.java test/java/org/apache/harmony/text/tests/java/text/NormalizerTest.java
Date Wed, 16 Apr 2008 12:08:34 GMT
Author: lvjing
Date: Wed Apr 16 05:08:33 2008
New Revision: 648676

URL: http://svn.apache.org/viewvc?rev=648676&view=rev
Log:
Apply patch for HARMONY-5740, [java6][classlib][text] - add new java6 class java.text.Normalizer

Added:
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Normalizer.java 
 (with props)
    harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NormalizerTest.java
  (with props)

Added: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Normalizer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Normalizer.java?rev=648676&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Normalizer.java (added)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Normalizer.java Wed
Apr 16 05:08:33 2008
@@ -0,0 +1,89 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.text;
+
+import org.apache.harmony.luni.util.NotImplementedException;
+
+/**
+ * This class provider Unicode Normalization functions, which transform Unicode
+ * text into an equivalent composed or decomposed form, allowing for easier
+ * sorting and searching of text.
+ * 
+ * @since 1.6
+ */
+public final class Normalizer {
+
+    /**
+     * This enum providers constants of normalization forms defined in Unicode
+     * Standard Annex #15 Unicode Normalization Forms.
+     * 
+     * @since 1.6
+     */
+    public static enum Form {
+        /**
+         * Canonical decomposition.
+         */
+        NFD,
+        /**
+         * Canonical decomposition followed by canonical composition.
+         */
+        NFC,
+        /**
+         * Compatibility decomposition.
+         */
+        NFKD,
+        /**
+         * Compatibility decomposition followed by canonical composition.
+         */
+        NFKC
+    }
+
+    /**
+     * Normalize the given sequence of char <code>src</code> according to the
+     * specified normalization form.
+     * 
+     * @param src
+     *            The sequence of char values.
+     * @param form
+     *            The specified normalization form.
+     * @return The normalized String
+     * 
+     * @exception NullPointerException
+     *                If <code>src</code> or <code>form</code> is
null.
+     */
+    public static String normalize(CharSequence src, Form form) {
+        throw new NotImplementedException();
+    }
+
+    /**
+     * Test wheather the given sequence of char <code>src</code> is normalized
+     * according to the specified normalization form.
+     * 
+     * @param src
+     *            The sequence of char values.
+     * @param form
+     *            The specified normalization form.
+     * @return true if <code>src</code> is normalized; false otherwise.
+     * 
+     * @exception NullPointerException
+     *                If <code>src</code> or <code>form</code> is
null.
+     */
+    public static boolean isNormalized(CharSequence src, Form form) {
+        throw new NotImplementedException();
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Normalizer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NormalizerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NormalizerTest.java?rev=648676&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NormalizerTest.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NormalizerTest.java
Wed Apr 16 05:08:33 2008
@@ -0,0 +1,74 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.text.tests.java.text;
+
+import java.text.Normalizer.Form;
+
+import junit.framework.TestCase;
+
+public class NormalizerTest extends TestCase {
+    /**
+     * @tests java.text.Normalizer.Form#values()
+     */
+    public void test_form_values() throws Exception {
+        Form[] forms = Form.values();
+        assertEquals(4, forms.length);
+        assertEquals(Form.NFD, forms[0]);
+        assertEquals(Form.NFC, forms[1]);
+        assertEquals(Form.NFKD, forms[2]);
+        assertEquals(Form.NFKC, forms[3]);
+    }
+
+    /**
+     * @tests java.text.Normalizer.Form#valueOf(String)
+     */
+    public void test_form_valueOfLjava_lang_String() {
+        try {
+            Form.valueOf(null);
+            fail("Should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // expected
+        }
+
+        assertEquals(Form.NFC, Form.valueOf("NFC"));
+        assertEquals(Form.NFD, Form.valueOf("NFD"));
+        assertEquals(Form.NFKC, Form.valueOf("NFKC"));
+        assertEquals(Form.NFKD, Form.valueOf("NFKD"));
+
+        try {
+            Form.valueOf("not exist");
+            fail("Should throw IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try {
+            Form.valueOf("nfc");
+            fail("Should throw IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+        
+        try {
+            Form.valueOf("NFC ");
+            fail("Should throw IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NormalizerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message