ICU-3549 getDisplayName should work for any id that falls back to one the factory supports

X-SVN-Rev: 15073
This commit is contained in:
Doug Felt 2004-04-28 02:33:11 +00:00
parent c54e347f0f
commit 9417951257
4 changed files with 28 additions and 8 deletions

View File

@ -552,6 +552,7 @@ public class TestFmwk extends AbstractTestLog {
}
}
catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
System.out.println("encountered exception, exiting");
}
@ -1155,7 +1156,9 @@ public class TestFmwk extends AbstractTestLog {
// msg("***" + name + "*** not found or not valid.", WARN, true, true);
if (inDocMode()) {
if (!warnings) {
stack.flush();
if (stack != null) {
stack.flush();
}
log.println(" *** Target not found or not valid.");
log.flush();
needLineFeed = false;

View File

@ -105,7 +105,7 @@ public class ICUServiceTest extends TestFmwk
}
}
public void testAPI() {
public void TestAPI() {
// create a service using locale keys,
ICUService service = new TestService();
@ -317,7 +317,10 @@ public class ICUServiceTest extends TestFmwk
displayName = service.getDisplayName(id, Locale.US);
logln("found query: " + gal + " with display name: " + displayName);
confirmBoolean("31) found display name for query", displayName == null);
// this is no longer a bug, we want to return display names for anything
// that a factory handles. since we handle it, we should return a display
// name. see jb3549
// confirmBoolean("31) found display name for query", displayName == null);
} else {
errln("30) service could not find entry for " + id);
}
@ -332,7 +335,8 @@ public class ICUServiceTest extends TestFmwk
displayName = service.getDisplayName(id, Locale.US);
logln("found actual: " + bozo + " with display name: " + displayName);
confirmBoolean("33) found display name for query", displayName == null);
// see above and jb3549
// confirmBoolean("33) found display name for query", displayName == null);
} else {
errln("32) service could not find entry for " + id);
}

View File

@ -449,14 +449,15 @@ public class ICULocaleService extends ICUService {
* Return a localized name for the locale represented by id.
*/
public String getDisplayName(String id, Locale locale) {
if (isSupportedID(id)) {
// assume if the user called this on us, we must have handled some fallback of this id
// if (isSupportedID(id)) {
if (locale == null) {
return id;
}
Locale loc = LocaleUtility.getLocaleFromName(id);
return loc.getDisplayName(locale);
}
return null;
// }
// return null;
}
/**

View File

@ -635,7 +635,19 @@ public class ICUService extends ICUNotifier {
public String getDisplayName(String id, Locale locale) {
Map m = getVisibleIDMap();
Factory f = (Factory)m.get(id);
return f != null ? f.getDisplayName(id, locale) : null;
if (f != null) {
return f.getDisplayName(id, locale);
}
Key key = createKey(id);
while (key.fallback()) {
f = (Factory)m.get(key.currentID());
if (f != null) {
return f.getDisplayName(id, locale);
}
}
return null;
}
/**