Class PhonePrefixMap
java.lang.Object
com.google.i18n.phonenumbers.prefixmapper.PhonePrefixMap
- All Implemented Interfaces:
Externalizable,Serializable
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlookup(Phonenumber.PhoneNumber number) As perlookup(long), but receives the number as a PhoneNumber instead of a long.voidreadExternal(ObjectInput objectInput) Supports Java Serialization.voidreadPhonePrefixMap(SortedMap<Integer, String> sortedPhonePrefixMap) Creates anPhonePrefixMapinitialized withsortedPhonePrefixMap.toString()Dumps the mappings contained in the phone prefix map.voidwriteExternal(ObjectOutput objectOutput) Supports Java Serialization.
-
Constructor Details
-
PhonePrefixMap
public PhonePrefixMap()Creates an emptyPhonePrefixMap. The default constructor is necessary for implementingExternalizable. The empty map could later be populated byreadPhonePrefixMap(java.util.SortedMap)orreadExternal(java.io.ObjectInput).
-
-
Method Details
-
readPhonePrefixMap
Creates anPhonePrefixMapinitialized withsortedPhonePrefixMap. 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
Supports Java Serialization.- Specified by:
readExternalin interfaceExternalizable- Throws:
IOException
-
writeExternal
Supports Java Serialization.- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
lookup
As perlookup(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
Dumps the mappings contained in the phone prefix map.
-