Class PhoneNumberOfflineGeocoder
- Author:
- Shaopeng Jia
-
Method Summary
Modifier and TypeMethodDescriptiongetDescriptionForNumber
(Phonenumber.PhoneNumber number, Locale languageCode) As pergetDescriptionForValidNumber(PhoneNumber, Locale)
but explicitly checks the validity of the number passed in.getDescriptionForNumber
(Phonenumber.PhoneNumber number, Locale languageCode, String userRegion) As pergetDescriptionForValidNumber(PhoneNumber, Locale, String)
but explicitly checks the validity of the number passed in.getDescriptionForValidNumber
(Phonenumber.PhoneNumber number, Locale languageCode) Returns a text description for the given phone number, in the language provided.getDescriptionForValidNumber
(Phonenumber.PhoneNumber number, Locale languageCode, String userRegion) As pergetDescriptionForValidNumber(PhoneNumber, Locale)
but also considers the region of the user.static PhoneNumberOfflineGeocoder
Gets aPhoneNumberOfflineGeocoder
instance to carry out international phone number geocoding.
-
Method Details
-
getInstance
Gets aPhoneNumberOfflineGeocoder
instance to carry out international phone number geocoding.The
PhoneNumberOfflineGeocoder
is implemented as a singleton. Therefore, calling this method multiple times will only result in one instance being created.- Returns:
- a
PhoneNumberOfflineGeocoder
instance
-
getDescriptionForValidNumber
Returns a text description for the given phone number, in the language provided. The description might consist of the name of the country where the phone number is from, or the name of the geographical area the phone number is from if more detailed information is available.This method assumes the validity of the number passed in has already been checked, and that the number is suitable for geocoding. We consider fixed-line and mobile numbers possible candidates for geocoding.
- Parameters:
number
- a valid phone number for which we want to get a text descriptionlanguageCode
- the language code for which the description should be written- Returns:
- a text description for the given language code for the given phone number, or an empty string if the number could come from multiple countries, or the country code is in fact invalid
-
getDescriptionForValidNumber
public String getDescriptionForValidNumber(Phonenumber.PhoneNumber number, Locale languageCode, String userRegion) As pergetDescriptionForValidNumber(PhoneNumber, Locale)
but also considers the region of the user. If the phone number is from the same region as the user, only a lower-level description will be returned, if one exists. Otherwise, the phone number's region will be returned, with optionally some more detailed information.For example, for a user from the region "US" (United States), we would show "Mountain View, CA" for a particular number, omitting the United States from the description. For a user from the United Kingdom (region "GB"), for the same number we may show "Mountain View, CA, United States" or even just "United States".
This method assumes the validity of the number passed in has already been checked.
- Parameters:
number
- the phone number for which we want to get a text descriptionlanguageCode
- the language code for which the description should be writtenuserRegion
- the region code for a given user. This region will be omitted from the description if the phone number comes from this region. It should be a two-letter upper-case CLDR region code.- Returns:
- a text description for the given language code for the given phone number, or an empty string if the number could come from multiple countries, or the country code is in fact invalid
-
getDescriptionForNumber
As pergetDescriptionForValidNumber(PhoneNumber, Locale)
but explicitly checks the validity of the number passed in.- Parameters:
number
- the phone number for which we want to get a text descriptionlanguageCode
- the language code for which the description should be written- Returns:
- a text description for the given language code for the given phone number, or empty string if the number passed in is invalid or could belong to multiple countries
-
getDescriptionForNumber
public String getDescriptionForNumber(Phonenumber.PhoneNumber number, Locale languageCode, String userRegion) As pergetDescriptionForValidNumber(PhoneNumber, Locale, String)
but explicitly checks the validity of the number passed in.- Parameters:
number
- the phone number for which we want to get a text descriptionlanguageCode
- the language code for which the description should be writtenuserRegion
- the region code for a given user. This region will be omitted from the description if the phone number comes from this region. It should be a two-letter upper-case CLDR region code.- Returns:
- a text description for the given language code for the given phone number, or empty string if the number passed in is invalid or could belong to multiple countries
-