logln("EN sort:");
try {
en = (RuleBasedCollator)Collator.getInstance(
new Locale("en", ""));
for (int j=0; j<cases.length; j++) {
CollationKey key = en.getCollationKey(cases[j]);
if (j>0) {
CollationKey prevKey = en.getCollationKey(cases[j-1]);
if (key.compareTo(prevKey)<0) {
errln("Error! EN test["+j+"]:"+"source:" + cases[j]+
"is not greater than previous test.");
}
}
/*
if ( key.compareTo(expectingKey)!=0) {
errln("Error! Test case["+i+"]:"+"source:" + key.getSourceString());
errln("expecting:"+prettify(expectingKey)+ "got:"+ prettify(key));
}
*/
logln("String:"+cases[j]+" Key:"+ prettify(key));
}
} catch (Exception e) {
warnln("Error creating Vietnese collator");
return;
}
// Test ja sort
RuleBasedCollator ja = null;
logln("JA sort:");
try {
ja = (RuleBasedCollator)Collator.getInstance(
new Locale("ja", ""));
for (int j=0; j<cases.length; j++) {
CollationKey key = ja.getCollationKey(cases[j]);
if (j>0) {
CollationKey prevKey = ja.getCollationKey(cases[j-1]);
if (key.compareTo(prevKey)<0) {
errln("Error! JA test["+j+"]:"+"source:" + cases[j]+
"is not greater than previous test.");
}
}
logln("String:"+cases[j]+" Key:"+ prettify(key));
}
} catch (Exception e) {
warnln("Error creating Vietnese collator");
return;
}
for(int i = 0; i < rules.length; i++) {
RuleBasedCollator coll = null;
logln("Tailoring rule:"+rules[i]);
try {
coll = new RuleBasedCollator(rules[i]);
} catch (Exception e) {
warnln("Unable to open collator with rules " + rules[i]);
}
for (int j=0; j<cases.length; j++) {
CollationKey key = coll.getCollationKey(cases[j]);
if (j>0) {
CollationKey prevKey = coll.getCollationKey(cases[j-1]);
if (i==1 && j==3) {
if (key.compareTo(prevKey)>0) {
errln("Error! Rule:"+rules[i]+" test["+j+"]:"+"source:"+
cases[j]+"is not greater than previous test.");
}