com.google.i18n.phonenumbers.geocoding
Class PhoneNumberOfflineGeocoder

java.lang.Object
  extended by com.google.i18n.phonenumbers.geocoding.PhoneNumberOfflineGeocoder

public class PhoneNumberOfflineGeocoder
extends Object

An offline geocoder which provides geographical information related to a phone number.

Author:
Shaopeng Jia

Method Summary
 String getDescriptionForNumber(Phonenumber.PhoneNumber number, Locale languageCode)
          As per #getDescriptionForValidNumber(PhoneNumber, Locale) but explicitly checks the validity of the number passed in.
 String getDescriptionForNumber(Phonenumber.PhoneNumber number, Locale languageCode, String userRegion)
          As per #getDescriptionForValidNumber(PhoneNumber, Locale, String) but explicitly checks the validity of the number passed in.
 String getDescriptionForValidNumber(Phonenumber.PhoneNumber number, Locale languageCode)
          Returns a text description for the given phone number, in the language provided.
 String getDescriptionForValidNumber(Phonenumber.PhoneNumber number, Locale languageCode, String userRegion)
          As per #getDescriptionForValidNumber(PhoneNumber, Locale) but also considers the region of the user.
static PhoneNumberOfflineGeocoder getInstance()
          Gets a PhoneNumberOfflineGeocoder instance to carry out international phone number geocoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static PhoneNumberOfflineGeocoder getInstance()
Gets a PhoneNumberOfflineGeocoder 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

public String getDescriptionForValidNumber(Phonenumber.PhoneNumber number,
                                           Locale languageCode)
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 description
languageCode - the language code for which the description should be written
Returns:
a text description for the given language code for the given phone number

getDescriptionForValidNumber

public String getDescriptionForValidNumber(Phonenumber.PhoneNumber number,
                                           Locale languageCode,
                                           String userRegion)
As per #getDescriptionForValidNumber(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 description
languageCode - the language code for which the description should be written
userRegion - the region code for a given user. This region will be omitted from the description if the phone number comes from this region. It is a two-letter uppercase ISO country code as defined by ISO 3166-1.
Returns:
a text description for the given language code for the given phone number, or empty string if the number passed in is invalid

getDescriptionForNumber

public String getDescriptionForNumber(Phonenumber.PhoneNumber number,
                                      Locale languageCode)
As per #getDescriptionForValidNumber(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 description
languageCode - 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

getDescriptionForNumber

public String getDescriptionForNumber(Phonenumber.PhoneNumber number,
                                      Locale languageCode,
                                      String userRegion)
As per #getDescriptionForValidNumber(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 description
languageCode - the language code for which the description should be written
userRegion - the region code for a given user. This region will be omitted from the description if the phone number comes from this region. It is a two-letter uppercase ISO country code as defined by ISO 3166-1.
Returns:
a text description for the given language code for the given phone number, or empty string if the number passed in is invalid


Copyright © 2012 Google. All Rights Reserved.