summaryrefslogtreecommitdiff
path: root/java/src/com/android/i18n/phonenumbers/geocoding/AreaCodeMap.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/i18n/phonenumbers/geocoding/AreaCodeMap.java')
-rw-r--r--java/src/com/android/i18n/phonenumbers/geocoding/AreaCodeMap.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/java/src/com/android/i18n/phonenumbers/geocoding/AreaCodeMap.java b/java/src/com/android/i18n/phonenumbers/geocoding/AreaCodeMap.java
index cab8818b..c22bde5c 100644
--- a/java/src/com/android/i18n/phonenumbers/geocoding/AreaCodeMap.java
+++ b/java/src/com/android/i18n/phonenumbers/geocoding/AreaCodeMap.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Google Inc.
+ * Copyright (C) 2011 The Libphonenumber Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -129,12 +129,15 @@ public class AreaCodeMap implements Externalizable {
* Supports Java Serialization.
*/
public void writeExternal(ObjectOutput objectOutput) throws IOException {
- objectOutput.writeBoolean(areaCodeMapStorage.isFlyweight());
+ objectOutput.writeBoolean(areaCodeMapStorage instanceof FlyweightMapStorage);
areaCodeMapStorage.writeExternal(objectOutput);
}
/**
- * Returns the description of the geographical area the {@code number} corresponds to.
+ * Returns the description of the geographical area the {@code number} corresponds to. This method
+ * distinguishes the case of an invalid prefix and a prefix for which the name is not available in
+ * the current language. If the description is not available in the current language an empty
+ * string is returned. If no description was found for the provided number, null is returned.
*
* @param number the phone number to look up
* @return the description of the geographical area
@@ -142,7 +145,7 @@ public class AreaCodeMap implements Externalizable {
String lookup(PhoneNumber number) {
int numOfEntries = areaCodeMapStorage.getNumOfEntries();
if (numOfEntries == 0) {
- return "";
+ return null;
}
long phonePrefix =
Long.parseLong(number.getCountryCode() + phoneUtil.getNationalSignificantNumber(number));
@@ -156,7 +159,7 @@ public class AreaCodeMap implements Externalizable {
}
currentIndex = binarySearch(0, currentIndex, phonePrefix);
if (currentIndex < 0) {
- return "";
+ return null;
}
int currentPrefix = areaCodeMapStorage.getPrefix(currentIndex);
if (phonePrefix == currentPrefix) {
@@ -164,7 +167,7 @@ public class AreaCodeMap implements Externalizable {
}
currentSetOfLengths = currentSetOfLengths.headSet(possibleLength);
}
- return "";
+ return null;
}
/**