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
-
Method Summary
Modifier and TypeMethodDescriptionlookup
(Phonenumber.PhoneNumber number) As perlookup(long)
, but receives the number as a PhoneNumber instead of a long.void
readExternal
(ObjectInput objectInput) Supports Java Serialization.void
readPhonePrefixMap
(SortedMap<Integer, String> sortedPhonePrefixMap) Creates anPhonePrefixMap
initialized withsortedPhonePrefixMap
.toString()
Dumps the mappings contained in the phone prefix map.void
writeExternal
(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 anPhonePrefixMap
initialized 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:
readExternal
in interfaceExternalizable
- Throws:
IOException
-
writeExternal
Supports Java Serialization.- Specified by:
writeExternal
in 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.
-