]> granicus.if.org Git - icu/commitdiff
ICU-8864 Use fallback mechanism for empty string in ICUResourceTableAccess get method
authorMichael Ow <mow@svn.icu-project.org>
Mon, 3 Oct 2011 19:17:07 +0000 (19:17 +0000)
committerMichael Ow <mow@svn.icu-project.org>
Mon, 3 Oct 2011 19:17:07 +0000 (19:17 +0000)
X-SVN-Rev: 30782

icu4j/main/classes/core/src/com/ibm/icu/impl/ICUResourceTableAccess.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java

index 561124ec2958c80cf7cdda4beae3fea8ad861f72..939cf6bf4d45646910ff7aa08806d7732482b841 100644 (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
index cd01c5539259fa76ff770897a2f98e79089dd2f1..bd9f013e8856ad607d441ed2343c9727b9d58c99 100644 (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]);
             }