Commits

Anonymous committed 4349441

Java: Fix geocoder to return empty string for Global Networks numbers.
Review URL: http://codereview.appspot.com/5557071

  • Participants
  • Parent commits 0ec4ecd
  • Branches default

Comments (0)

Files changed (2)

java/geocoder/src/com/google/i18n/phonenumbers/geocoding/PhoneNumberOfflineGeocoder.java

    * Returns the customary display name in the given language for the given region.
    */
   private String getRegionDisplayName(String regionCode, Locale language) {
-    return (regionCode == null || regionCode.equals("ZZ"))
+    return (regionCode == null || regionCode.equals("ZZ") ||
+            regionCode.equals(PhoneNumberUtil.REGION_CODE_FOR_NON_GEO_ENTITY))
         ? "" : new Locale("", regionCode).getDisplayCountry(language);
   }
 

java/geocoder/test/com/google/i18n/phonenumbers/geocoding/PhoneNumberOfflineGeocoderTest.java

       new PhoneNumber().setCountryCode(61).setNationalNumber(236618300L);
   private static final PhoneNumber NUMBER_WITH_INVALID_COUNTRY_CODE =
       new PhoneNumber().setCountryCode(999).setNationalNumber(2423651234L);
+  private static final PhoneNumber INTERNATIONAL_TOLL_FREE =
+      new PhoneNumber().setCountryCode(800).setNationalNumber(12345678L);
 
   public void testGetDescriptionForNumberWithNoDataFile() {
     // No data file containing mappings for US numbers is available in Chinese for the unittests. As
         geocoder.getDescriptionForNumber(AU_NUMBER, new Locale("en", "US")));
     assertEquals("", geocoder.getDescriptionForNumber(NUMBER_WITH_INVALID_COUNTRY_CODE,
                                                       new Locale("en", "US")));
+    assertEquals("", geocoder.getDescriptionForNumber(INTERNATIONAL_TOLL_FREE,
+                                                      new Locale("en", "US")));
   }
 
   public void testGetDescriptionForNumberWithMissingPrefix() {