From 0a4585a175b0197f0c62bb02461a4065386334b4 Mon Sep 17 00:00:00 2001 From: Philippe Liard Date: Thu, 11 Aug 2011 13:32:08 +0000 Subject: [PATCH] JAVA,GEODATA: Fix broken test after US data split commit. --- .../geocoding/PhoneNumberOfflineGeocoder.java | 20 ++++++------------ .../geocoding/testing_data/1201_en | Bin 0 -> 27 bytes .../geocoding/testing_data/1212_en | Bin 0 -> 49 bytes .../geocoding/testing_data/1617_en | Bin 0 -> 35 bytes .../geocoding/testing_data/1650_en | Bin 0 -> 54 bytes .../geocoding/testing_data/1989_en | Bin 0 -> 27 bytes .../phonenumbers/geocoding/testing_data/1_en | Bin 112 -> 0 bytes .../geocoding/testing_data/config | Bin 38 -> 86 bytes 8 files changed, 6 insertions(+), 14 deletions(-) create mode 100644 java/test/com/google/i18n/phonenumbers/geocoding/testing_data/1201_en create mode 100644 java/test/com/google/i18n/phonenumbers/geocoding/testing_data/1212_en create mode 100644 java/test/com/google/i18n/phonenumbers/geocoding/testing_data/1617_en create mode 100644 java/test/com/google/i18n/phonenumbers/geocoding/testing_data/1650_en create mode 100644 java/test/com/google/i18n/phonenumbers/geocoding/testing_data/1989_en delete mode 100644 java/test/com/google/i18n/phonenumbers/geocoding/testing_data/1_en diff --git a/java/src/com/google/i18n/phonenumbers/geocoding/PhoneNumberOfflineGeocoder.java b/java/src/com/google/i18n/phonenumbers/geocoding/PhoneNumberOfflineGeocoder.java index 7725fdb72..30118bb7a 100644 --- a/java/src/com/google/i18n/phonenumbers/geocoding/PhoneNumberOfflineGeocoder.java +++ b/java/src/com/google/i18n/phonenumbers/geocoding/PhoneNumberOfflineGeocoder.java @@ -110,19 +110,6 @@ public class PhoneNumberOfflineGeocoder { return instance; } - /** - * Preload the data file for the given language and country calling code, so that a future lookup - * for this language and country calling code will not incur any file loading. - * - * @param locale specifies the language of the data file to load - * @param countryCallingCode specifies the country calling code of phone numbers that are - * contained by the file to be loaded - */ - public void loadDataFile(Locale locale, int countryCallingCode) { - instance.getPhonePrefixDescriptions(countryCallingCode, locale.getLanguage(), "", - locale.getCountry()); - } - /** * Returns the customary display name in the given language for the given territory the phone * number is from. @@ -185,8 +172,13 @@ public class PhoneNumberOfflineGeocoder { */ private String getAreaDescriptionForNumber( PhoneNumber number, String lang, String script, String region) { + int countryCallingCode = number.getCountryCode(); + // As the NANPA data is split into multiple files covering 3-digit areas, use a phone number + // prefix of 4 digits for NANPA instead, e.g. 1650. + int phonePrefix = (countryCallingCode != 1) ? + countryCallingCode : (1000 + (int) (number.getNationalNumber() / 10000000)); AreaCodeMap phonePrefixDescriptions = - getPhonePrefixDescriptions(number.getCountryCode(), lang, script, region); + getPhonePrefixDescriptions(phonePrefix, lang, script, region); return (phonePrefixDescriptions != null) ? phonePrefixDescriptions.lookup(number) : ""; } } diff --git a/java/test/com/google/i18n/phonenumbers/geocoding/testing_data/1201_en b/java/test/com/google/i18n/phonenumbers/geocoding/testing_data/1201_en new file mode 100644 index 0000000000000000000000000000000000000000..9af68fa937f2d8eda8fb76c62c097d8e1b026fc2 GIT binary patch literal 27 ccmZ4UmVvcglmQ4B85meLGBEjhLD&o|07g>-fB*mh literal 0 HcmV?d00001 diff --git a/java/test/com/google/i18n/phonenumbers/geocoding/testing_data/1212_en b/java/test/com/google/i18n/phonenumbers/geocoding/testing_data/1212_en new file mode 100644 index 0000000000000000000000000000000000000000..0c3d5d84d095e650dcfc2297f465f4fa99e6a9b0 GIT binary patch literal 49 xcmZ4UmVvcgn*j)z7#LXgFfjQ=G6*&HF!1=LmMcW&7iH@x07byE3@kvJ9RLGm2*v;a literal 0 HcmV?d00001 diff --git a/java/test/com/google/i18n/phonenumbers/geocoding/testing_data/1617_en b/java/test/com/google/i18n/phonenumbers/geocoding/testing_data/1617_en new file mode 100644 index 0000000000000000000000000000000000000000..b4f7c1d7bab9e4469275bccd792131affe1742c2 GIT binary patch literal 35 lcmZ4UmVvcgmH`MD86?*6GjKWO7nkJc=_vR*g2fmZ*a3?y25JBR literal 0 HcmV?d00001 diff --git a/java/test/com/google/i18n/phonenumbers/geocoding/testing_data/1650_en b/java/test/com/google/i18n/phonenumbers/geocoding/testing_data/1650_en new file mode 100644 index 0000000000000000000000000000000000000000..a95364eab02fc6d03b7f7f9eedc0d5e928f290fc GIT binary patch literal 54 zcmZ4UmVve0fB^`Y7#P@!7?_+L86*t_7zBOuOY=$+GxHR}GE>WS6oA5DB@8S;njHWt CfC-cU literal 0 HcmV?d00001 diff --git a/java/test/com/google/i18n/phonenumbers/geocoding/testing_data/1989_en b/java/test/com/google/i18n/phonenumbers/geocoding/testing_data/1989_en new file mode 100644 index 0000000000000000000000000000000000000000..40d871604b5061fa38ee0dc240f659d0fa48aee4 GIT binary patch literal 27 ccmZ4UmVvcglmQ4B85r1)GBEi%Lf8x}07oVRjQ{`u literal 0 HcmV?d00001 diff --git a/java/test/com/google/i18n/phonenumbers/geocoding/testing_data/1_en b/java/test/com/google/i18n/phonenumbers/geocoding/testing_data/1_en deleted file mode 100644 index a3850da173fb69b2f20438060124ff17270d8a09..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 112 zcmZ4UmVvcAivbAO85meLGBEjh0qH$JI+B5bt%!li*%2spl!3|DkwK`jhk?g0wOk=G zzbIQr0jNS^9X|t?Q+{ztex8m3P=%zS0E3`!eraAwVrHH~SY~RujsnO41|}e80a*e7 DFvJ%k diff --git a/java/test/com/google/i18n/phonenumbers/geocoding/testing_data/config b/java/test/com/google/i18n/phonenumbers/geocoding/testing_data/config index ab7bf471f9e757b5b33d49bc626612e2e4529e97..0731ac85a687f462159d3a051dfd1550887d75a5 100644 GIT binary patch literal 86 zcmZ4UmVvcAfPsO54Tyt)n2CWYJD-6mHIIRTWh0Q!2xad