ICU-1491 make special inverse mapping case insensitive

X-SVN-Rev: 6934
This commit is contained in:
Alan Liu 2001-11-15 23:38:31 +00:00
parent 6db2e24326
commit fdd3dc6fd0
4 changed files with 30 additions and 22 deletions

View File

@ -5,8 +5,8 @@
******************************************************************************* *******************************************************************************
* *
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/translit/TransliteratorTest.java,v $ * $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/translit/TransliteratorTest.java,v $
* $Date: 2001/11/15 22:20:29 $ * $Date: 2001/11/15 23:38:31 $
* $Revision: 1.69 $ * $Revision: 1.70 $
* *
***************************************************************************************** *****************************************************************************************
*/ */
@ -2013,7 +2013,7 @@ public class TransliteratorTest extends TestFmwk {
public void TestIDForms() { public void TestIDForms() {
String DATA[] = { String DATA[] = {
"NFC", "NFD", "NFC", "NFD",
"NFD", "NFC", "nfd", "NFC", // make sure case is ignored
"Any-NFKD", "Any-NFKC", "Any-NFKD", "Any-NFKC",
"Null", "Null", "Null", "Null",
"Latin-Greek/UNGEGN", "Greek-Latin/UNGEGN", "Latin-Greek/UNGEGN", "Greek-Latin/UNGEGN",

View File

@ -5,8 +5,8 @@
******************************************************************************* *******************************************************************************
* *
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/Transliterator.java,v $ * $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/Transliterator.java,v $
* $Date: 2001/11/15 22:19:34 $ * $Date: 2001/11/15 23:38:01 $
* $Revision: 1.52 $ * $Revision: 1.53 $
* *
***************************************************************************************** *****************************************************************************************
*/ */
@ -242,7 +242,7 @@ import com.ibm.util.Utility;
* <p>Copyright &copy; IBM Corporation 1999. All rights reserved. * <p>Copyright &copy; IBM Corporation 1999. All rights reserved.
* *
* @author Alan Liu * @author Alan Liu
* @version $RCSfile: Transliterator.java,v $ $Revision: 1.52 $ $Date: 2001/11/15 22:19:34 $ * @version $RCSfile: Transliterator.java,v $ $Revision: 1.53 $ $Date: 2001/11/15 23:38:01 $
*/ */
public abstract class Transliterator { public abstract class Transliterator {
/** /**
@ -1313,7 +1313,8 @@ public abstract class Transliterator {
// Handle special, non-canonical inverse mappings, // Handle special, non-canonical inverse mappings,
// e.g. inverse(Any-NFC) = Any-NFD and vice versa. // e.g. inverse(Any-NFC) = Any-NFD and vice versa.
if (source.equals(ANY)) { if (source.equals(ANY)) {
String inverseTarget = (String) specialInverses.get(target); String inverseTarget = (String) specialInverses.get(
new CaseInsensitiveString(target));
if (inverseTarget != null) { if (inverseTarget != null) {
// If the original ID contained "Any-" then make the // If the original ID contained "Any-" then make the
// special inverse "Any-Foo"; otherwise make it "Foo". // special inverse "Any-Foo"; otherwise make it "Foo".
@ -1594,13 +1595,16 @@ public abstract class Transliterator {
* <p>The relevant IDs must still be registered separately as * <p>The relevant IDs must still be registered separately as
* factories or classes. * factories or classes.
* *
* <p>Only the target is specified. Special inverses always have * <p>Only the targets are specified. Special inverses always
* the form Any-Target1 <=> Any-Target2. * have the form Any-Target1 <=> Any-Target2. The target should
* have canonical casing (the casing desired to be produced when
* an inverse is formed) and should contain no whitespace or other
* extraneous characters.
*/ */
public static void registerSpecialInverses(String target1, String target2) { public static void registerSpecialInverses(String target1, String target2) {
specialInverses.put(target1, target2); specialInverses.put(new CaseInsensitiveString(target1), target2);
if (!target1.equalsIgnoreCase(target2)) { if (!target1.equalsIgnoreCase(target2)) {
specialInverses.put(target2, target1); specialInverses.put(new CaseInsensitiveString(target2), target1);
} }
} }

View File

@ -5,8 +5,8 @@
******************************************************************************* *******************************************************************************
* *
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/test/translit/Attic/TransliteratorTest.java,v $ * $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/test/translit/Attic/TransliteratorTest.java,v $
* $Date: 2001/11/15 22:20:29 $ * $Date: 2001/11/15 23:38:31 $
* $Revision: 1.69 $ * $Revision: 1.70 $
* *
***************************************************************************************** *****************************************************************************************
*/ */
@ -2013,7 +2013,7 @@ public class TransliteratorTest extends TestFmwk {
public void TestIDForms() { public void TestIDForms() {
String DATA[] = { String DATA[] = {
"NFC", "NFD", "NFC", "NFD",
"NFD", "NFC", "nfd", "NFC", // make sure case is ignored
"Any-NFKD", "Any-NFKC", "Any-NFKD", "Any-NFKC",
"Null", "Null", "Null", "Null",
"Latin-Greek/UNGEGN", "Greek-Latin/UNGEGN", "Latin-Greek/UNGEGN", "Greek-Latin/UNGEGN",

View File

@ -5,8 +5,8 @@
******************************************************************************* *******************************************************************************
* *
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/text/Attic/Transliterator.java,v $ * $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/text/Attic/Transliterator.java,v $
* $Date: 2001/11/15 22:19:34 $ * $Date: 2001/11/15 23:38:01 $
* $Revision: 1.52 $ * $Revision: 1.53 $
* *
***************************************************************************************** *****************************************************************************************
*/ */
@ -242,7 +242,7 @@ import com.ibm.util.Utility;
* <p>Copyright &copy; IBM Corporation 1999. All rights reserved. * <p>Copyright &copy; IBM Corporation 1999. All rights reserved.
* *
* @author Alan Liu * @author Alan Liu
* @version $RCSfile: Transliterator.java,v $ $Revision: 1.52 $ $Date: 2001/11/15 22:19:34 $ * @version $RCSfile: Transliterator.java,v $ $Revision: 1.53 $ $Date: 2001/11/15 23:38:01 $
*/ */
public abstract class Transliterator { public abstract class Transliterator {
/** /**
@ -1313,7 +1313,8 @@ public abstract class Transliterator {
// Handle special, non-canonical inverse mappings, // Handle special, non-canonical inverse mappings,
// e.g. inverse(Any-NFC) = Any-NFD and vice versa. // e.g. inverse(Any-NFC) = Any-NFD and vice versa.
if (source.equals(ANY)) { if (source.equals(ANY)) {
String inverseTarget = (String) specialInverses.get(target); String inverseTarget = (String) specialInverses.get(
new CaseInsensitiveString(target));
if (inverseTarget != null) { if (inverseTarget != null) {
// If the original ID contained "Any-" then make the // If the original ID contained "Any-" then make the
// special inverse "Any-Foo"; otherwise make it "Foo". // special inverse "Any-Foo"; otherwise make it "Foo".
@ -1594,13 +1595,16 @@ public abstract class Transliterator {
* <p>The relevant IDs must still be registered separately as * <p>The relevant IDs must still be registered separately as
* factories or classes. * factories or classes.
* *
* <p>Only the target is specified. Special inverses always have * <p>Only the targets are specified. Special inverses always
* the form Any-Target1 <=> Any-Target2. * have the form Any-Target1 <=> Any-Target2. The target should
* have canonical casing (the casing desired to be produced when
* an inverse is formed) and should contain no whitespace or other
* extraneous characters.
*/ */
public static void registerSpecialInverses(String target1, String target2) { public static void registerSpecialInverses(String target1, String target2) {
specialInverses.put(target1, target2); specialInverses.put(new CaseInsensitiveString(target1), target2);
if (!target1.equalsIgnoreCase(target2)) { if (!target1.equalsIgnoreCase(target2)) {
specialInverses.put(target2, target1); specialInverses.put(new CaseInsensitiveString(target2), target1);
} }
} }