ICU-8864 Use fallback mechanism for empty string in ICUResourceTableAccess get method

X-SVN-Rev: 30782
This commit is contained in:
Michael Ow 2011-10-03 19:17:07 +00:00
parent f6b6ce837f
commit 46fc0ce9da
2 changed files with 9 additions and 5 deletions

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2009, International Business Machines Corporation and *
* Copyright (C) 2009-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -31,6 +31,7 @@ public class ICUResourceTableAccess {
*/
public static String getTableString(ICUResourceBundle bundle, String tableName,
String subtableName, String item) {
String result = null;
try {
for (;;) {
// special case currency
@ -50,7 +51,8 @@ public class ICUResourceTableAccess {
if (stable != null) {
ICUResourceBundle sbundle = lookup(stable, item);
if (sbundle != null) {
return sbundle.getString(); // possible real exception
result = sbundle.getString(); // possible real exception
break;
}
}
@ -65,7 +67,8 @@ public class ICUResourceTableAccess {
}
ICUResourceBundle sbundle = lookup(table, currentName);
if (sbundle != null) {
return sbundle.getString(); // possible real exception
result = sbundle.getString(); // possible real exception
break;
}
}
@ -93,7 +96,8 @@ public class ICUResourceTableAccess {
// not a string. That will throw an exception, which we catch and ignore here.
}
return item;
// If the result is empty return item instead
return ((result != null && result.length() > 0) ? result : item);
}
// utility to make the call sites in the above code cleaner

View File

@ -690,7 +690,7 @@ public final class ICUResourceBundleTest extends TestFmwk {
errln("Could not get localized country for "+ locales[i]);
hasLocalizedCountryFor(locales[i], locales[i]);
}
if(!hasLocalizedLanguageFor(locales[i], locales[i])){
if(!hasLocalizedLanguageFor(locales[i], locales[i]) && (locales[i].getLanguage().compareTo("nmg") != 0)){
errln("Could not get localized language for "+ locales[i]);
}