Class PhonePrefixMap

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable

    public class PhonePrefixMap
    extends java.lang.Object
    implements java.io.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:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String lookup​(com.google.i18n.phonenumbers.Phonenumber.PhoneNumber number)
      As per lookup(long), but receives the number as a PhoneNumber instead of a long.
      void readExternal​(java.io.ObjectInput objectInput)
      Supports Java Serialization.
      void readPhonePrefixMap​(java.util.SortedMap<java.lang.Integer,​java.lang.String> sortedPhonePrefixMap)
      Creates an PhonePrefixMap initialized with sortedPhonePrefixMap.
      java.lang.String toString()
      Dumps the mappings contained in the phone prefix map.
      void writeExternal​(java.io.ObjectOutput objectOutput)
      Supports Java Serialization.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • readPhonePrefixMap

        public void readPhonePrefixMap​(java.util.SortedMap<java.lang.Integer,​java.lang.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​(java.io.ObjectInput objectInput)
                          throws java.io.IOException
        Supports Java Serialization.
        Specified by:
        readExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
      • writeExternal

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

        public java.lang.String lookup​(com.google.i18n.phonenumbers.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 java.lang.String toString()
        Dumps the mappings contained in the phone prefix map.
        Overrides:
        toString in class java.lang.Object