From 561281135513ae7696d0dc77e5e9987ac952d403 Mon Sep 17 00:00:00 2001 From: Doug Felt Date: Wed, 9 Jun 2004 18:08:35 +0000 Subject: [PATCH] ICU-3830 make propertiesTests pass with propertiesBasic module, fix UScript X-SVN-Rev: 15814 --- icu4j/build.xml | 4 ++ .../ibm/icu/dev/test/lang/TestUScript.java | 41 ++++++++----------- icu4j/src/com/ibm/icu/lang/UScript.java | 37 ++++++++++------- 3 files changed, 44 insertions(+), 38 deletions(-) diff --git a/icu4j/build.xml b/icu4j/build.xml index 990b0fd3d1..760284f4cd 100644 --- a/icu4j/build.xml +++ b/icu4j/build.xml @@ -602,6 +602,10 @@ + + + + 0 ){ - if(noData()){ - errln("Number of Errors in UScript.getCode() : " + numErrors); - }else{ - warnln("Could not find locale data"); + reportDataErrors(numErrors); + } + + private void reportDataErrors(int numErrors) { + if (numErrors >0) { + if (isModularBuild()) { + // assume missing locale data, so not an error, just a warning + if (!noData()) { + // if nodata is set don't even warn + warnln("Could not find locale data"); + } + } else { + errln("encountered " + numErrors + " errors."); } } - } + public void TestMultipleCode(){ final String[] testNames = { "ja" ,"ko_KR","zh","zh_TW"}; final int[][] expected = { @@ -96,15 +104,9 @@ public class TestUScript extends TestFmwk { numErrors++; } } - if(numErrors >0 ){ - if(noData()){ - errln("Number of Errors in UScript.getCode() : " + numErrors); - }else{ - warnln("Could not find locale data"); - } - } - + reportDataErrors(numErrors); } + public void TestGetCode(){ final String[] testNames={ @@ -168,16 +170,9 @@ public class TestUScript extends TestFmwk { numErrors++; } } - if(numErrors >0 ){ - if (!noData()) { - warnln("Could not find locale data"); - }else{ - errln("Number of Errors in UScript.getCode() : " + numErrors); - } - } - - + reportDataErrors(numErrors); } + public void TestGetName(){ final int[] testCodes={ diff --git a/icu4j/src/com/ibm/icu/lang/UScript.java b/icu4j/src/com/ibm/icu/lang/UScript.java index 4d0aa8af4a..215a1543f9 100755 --- a/icu4j/src/com/ibm/icu/lang/UScript.java +++ b/icu4j/src/com/ibm/icu/lang/UScript.java @@ -14,6 +14,7 @@ import com.ibm.icu.util.ULocale; import com.ibm.icu.util.UResourceBundle; import java.util.Locale; +import java.util.MissingResourceException; /** * A class to reflect UTR #24: Script Names @@ -274,49 +275,49 @@ public final class UScript { * New script in Unicode 4 * @draft ICU 2.6 * */ - public static final int BRAILLE = 46; /* Brai */ - /** + public static final int BRAILLE = 46; /* Brai */ + /** * Cypriot * New script in Unicode 4 * @draft ICU 2.6 * */ - public static final int CYPRIOT = 47; /* Cprt */ + public static final int CYPRIOT = 47; /* Cprt */ /** * Limbu * New script in Unicode 4 * @draft ICU 2.6 - * */ - public static final int LIMBU = 48; /* Limb */ + * */ + public static final int LIMBU = 48; /* Limb */ /** * Linear B * New script in Unicode 4 * @draft ICU 2.6 * */ - public static final int LINEAR_B = 49; /* Linb */ + public static final int LINEAR_B = 49; /* Linb */ /** * Osmanya * New script in Unicode 4 * @draft ICU 2.6 * */ - public static final int OSMANYA = 50; /* Osma */ + public static final int OSMANYA = 50; /* Osma */ /** * Shavian * New script in Unicode 4 * @draft ICU 2.6 * */ - public static final int SHAVIAN = 51; /* Shaw */ + public static final int SHAVIAN = 51; /* Shaw */ /** * Tai Le * New script in Unicode 4 * @draft ICU 2.6 * */ - public static final int TAI_LE = 52; /* Tale */ + public static final int TAI_LE = 52; /* Tale */ /** * Ugaritic * New script in Unicode 4 * @draft ICU 2.6 * */ - public static final int UGARITIC = 53; /* Ugar */ + public static final int UGARITIC = 53; /* Ugar */ /** * New script code in Unicode 4.0.1 * @draft ICU 3.0 @@ -338,10 +339,16 @@ public final class UScript { * @param Locale the locale. */ private static int[] findCodeFromLocale(ULocale locale) { - ICUResourceBundle rb = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, locale); + ICUResourceBundle rb; + try { + rb = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, locale); + } + catch (MissingResourceException e) { + return null; + } // if rb is not a strict fallback of the requested locale, return null - if(rb==null || !LocaleUtility.isFallbackOf(rb.getULocale().toString(), locale.toString())){ + if(!LocaleUtility.isFallbackOf(rb.getULocale().toString(), locale.toString())){ return null; } ICUResourceBundle sub = rb.get("LocaleScript"); @@ -349,9 +356,9 @@ public final class UScript { int[] result = new int[sub.getSize()]; int w = 0; for (int i = 0; i < result.length; ++i) { - int code = UCharacter.getPropertyValueEnum(UProperty.SCRIPT, - sub.getString(i)); - result[w++] = code; + int code = UCharacter.getPropertyValueEnum(UProperty.SCRIPT, + sub.getString(i)); + result[w++] = code; }