ICU-20 ID of inverse of CompoundTransliterator is wrong

X-SVN-Rev: 4416
This commit is contained in:
Alan Liu 2001-03-30 23:33:20 +00:00
parent df949741f4
commit b63956af35
6 changed files with 88 additions and 16 deletions

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/translit/TransliteratorTest.java,v $
* $Date: 2001/03/30 23:23:27 $
* $Revision: 1.29 $
* $Date: 2001/03/30 23:33:20 $
* $Revision: 1.30 $
*
*****************************************************************************************
*/
@ -694,6 +694,21 @@ public class TransliteratorTest extends TestFmwk {
"q\\u0075izzical");
}
/**
* Test IDs of inverses of compound transliterators. (J20)
*/
public void TestCompoundInverseID() {
String ID = "Latin-Jamo;Jamo-Hangul";
Transliterator t = Transliterator.getInstance(ID);
Transliterator u = t.getInverse();
String exp = "Hangul-Jamo;Jamo-Latin";
String got = u.getID();
if (!got.equals(exp)) {
errln("FAIL: Inverse of " + ID + " is " + got +
", expected " + exp);
}
}
/**
* Inverse of "Null" should be "Null". (J21)
*/

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/CompoundTransliterator.java,v $
* $Date: 2000/06/28 20:49:54 $
* $Revision: 1.11 $
* $Date: 2001/03/30 23:33:06 $
* $Revision: 1.12 $
*
*****************************************************************************************
*/
@ -35,7 +35,7 @@ import java.util.Vector;
* <p>Copyright &copy; IBM Corporation 1999. All rights reserved.
*
* @author Alan Liu
* @version $RCSfile: CompoundTransliterator.java,v $ $Revision: 1.11 $ $Date: 2000/06/28 20:49:54 $
* @version $RCSfile: CompoundTransliterator.java,v $ $Revision: 1.12 $ $Date: 2001/03/30 23:33:06 $
*/
public class CompoundTransliterator extends Transliterator {
@ -104,6 +104,19 @@ public class CompoundTransliterator extends Transliterator {
trans[i] = getInstance(list[direction==FORWARD ? i : (list.length-1-i)],
direction);
}
// If the direction is REVERSE then we need to fix the ID.
if (direction == REVERSE) {
StringBuffer newID = new StringBuffer();
for (int i=0; i<list.length; ++i) {
if (i > 0) {
newID.append(';');
}
newID.append(trans[i].getID());
}
setID(newID.toString());
}
computeMaximumContextLength();
if (filter != null) {
setFilter(filter);

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/Transliterator.java,v $
* $Date: 2001/03/30 23:24:30 $
* $Revision: 1.28 $
* $Date: 2001/03/30 23:33:06 $
* $Revision: 1.29 $
*
*****************************************************************************************
*/
@ -240,7 +240,7 @@ import com.ibm.text.resources.ResourceReader;
* <p>Copyright &copy; IBM Corporation 1999. All rights reserved.
*
* @author Alan Liu
* @version $RCSfile: Transliterator.java,v $ $Revision: 1.28 $ $Date: 2001/03/30 23:24:30 $
* @version $RCSfile: Transliterator.java,v $ $Revision: 1.29 $ $Date: 2001/03/30 23:33:06 $
*/
public abstract class Transliterator {
/**
@ -657,6 +657,14 @@ public abstract class Transliterator {
return ID;
}
/**
* Set the programmatic identifier for this transliterator. Only
* for use by subclasses.
*/
protected final void setID(String id) {
ID = id;
}
/**
* Returns a name for this transliterator that is appropriate for
* display to the user in the default locale. See {@link

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/test/translit/Attic/TransliteratorTest.java,v $
* $Date: 2001/03/30 23:23:27 $
* $Revision: 1.29 $
* $Date: 2001/03/30 23:33:20 $
* $Revision: 1.30 $
*
*****************************************************************************************
*/
@ -694,6 +694,21 @@ public class TransliteratorTest extends TestFmwk {
"q\\u0075izzical");
}
/**
* Test IDs of inverses of compound transliterators. (J20)
*/
public void TestCompoundInverseID() {
String ID = "Latin-Jamo;Jamo-Hangul";
Transliterator t = Transliterator.getInstance(ID);
Transliterator u = t.getInverse();
String exp = "Hangul-Jamo;Jamo-Latin";
String got = u.getID();
if (!got.equals(exp)) {
errln("FAIL: Inverse of " + ID + " is " + got +
", expected " + exp);
}
}
/**
* Inverse of "Null" should be "Null". (J21)
*/

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/text/Attic/CompoundTransliterator.java,v $
* $Date: 2000/06/28 20:49:54 $
* $Revision: 1.11 $
* $Date: 2001/03/30 23:33:06 $
* $Revision: 1.12 $
*
*****************************************************************************************
*/
@ -35,7 +35,7 @@ import java.util.Vector;
* <p>Copyright &copy; IBM Corporation 1999. All rights reserved.
*
* @author Alan Liu
* @version $RCSfile: CompoundTransliterator.java,v $ $Revision: 1.11 $ $Date: 2000/06/28 20:49:54 $
* @version $RCSfile: CompoundTransliterator.java,v $ $Revision: 1.12 $ $Date: 2001/03/30 23:33:06 $
*/
public class CompoundTransliterator extends Transliterator {
@ -104,6 +104,19 @@ public class CompoundTransliterator extends Transliterator {
trans[i] = getInstance(list[direction==FORWARD ? i : (list.length-1-i)],
direction);
}
// If the direction is REVERSE then we need to fix the ID.
if (direction == REVERSE) {
StringBuffer newID = new StringBuffer();
for (int i=0; i<list.length; ++i) {
if (i > 0) {
newID.append(';');
}
newID.append(trans[i].getID());
}
setID(newID.toString());
}
computeMaximumContextLength();
if (filter != null) {
setFilter(filter);

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/text/Attic/Transliterator.java,v $
* $Date: 2001/03/30 23:24:30 $
* $Revision: 1.28 $
* $Date: 2001/03/30 23:33:06 $
* $Revision: 1.29 $
*
*****************************************************************************************
*/
@ -240,7 +240,7 @@ import com.ibm.text.resources.ResourceReader;
* <p>Copyright &copy; IBM Corporation 1999. All rights reserved.
*
* @author Alan Liu
* @version $RCSfile: Transliterator.java,v $ $Revision: 1.28 $ $Date: 2001/03/30 23:24:30 $
* @version $RCSfile: Transliterator.java,v $ $Revision: 1.29 $ $Date: 2001/03/30 23:33:06 $
*/
public abstract class Transliterator {
/**
@ -657,6 +657,14 @@ public abstract class Transliterator {
return ID;
}
/**
* Set the programmatic identifier for this transliterator. Only
* for use by subclasses.
*/
protected final void setID(String id) {
ID = id;
}
/**
* Returns a name for this transliterator that is appropriate for
* display to the user in the default locale. See {@link