Class PhonePrefixMap

java.lang.Object
com.google.i18n.phonenumbers.prefixmapper.PhonePrefixMap
All Implemented Interfaces:
Externalizable, Serializable

public class PhonePrefixMap extends Object implements Externalizable
A utility that maps phone number prefixes to a description string, which may be, for example, the geographical area the prefix covers.
Author:
Shaopeng Jia
See Also:
  • Constructor Details

  • Method Details

    • readPhonePrefixMap

      public void readPhonePrefixMap(SortedMap<Integer,String> sortedPhonePrefixMap)
      Creates an PhonePrefixMap initialized with sortedPhonePrefixMap. Note that the underlying implementation of this method is expensive thus should not be called by time-critical applications.
      Parameters:
      sortedPhonePrefixMap - a map from phone number prefixes to descriptions of those prefixes sorted in ascending order of the phone number prefixes as integers.
    • readExternal

      public void readExternal(ObjectInput objectInput) throws IOException
      Supports Java Serialization.
      Specified by:
      readExternal in interface Externalizable
      Throws:
      IOException
    • writeExternal

      public void writeExternal(ObjectOutput objectOutput) throws IOException
      Supports Java Serialization.
      Specified by:
      writeExternal in interface Externalizable
      Throws:
      IOException
    • lookup

      public String lookup(Phonenumber.PhoneNumber number)
      As per lookup(long), but receives the number as a PhoneNumber instead of a long.
      Parameters:
      number - the phone number to look up
      Returns:
      the description corresponding to the prefix that best matches this phone number
    • toString

      public String toString()
      Dumps the mappings contained in the phone prefix map.
      Overrides:
      toString in class Object