summaryrefslogtreecommitdiffstats
path: root/java/libphonenumber/src/com/google/i18n
diff options
context:
space:
mode:
authordbeaumont@google.com <dbeaumont@google.com@ee073f10-1060-11df-b6a4-87a95322a99c>2012-07-12 13:14:13 +0000
committerdbeaumont@google.com <dbeaumont@google.com@ee073f10-1060-11df-b6a4-87a95322a99c>2012-07-12 13:14:13 +0000
commit126c688c23f92d93e5e9e49110ed32112b935be0 (patch)
tree363d36d2fd8b14c3d46e3a828c1544afdda50c46 /java/libphonenumber/src/com/google/i18n
parenta72cc05053361f363f4d7478defc997f7b2053ca (diff)
downloadandroid_external_libphonenumbergoogle-126c688c23f92d93e5e9e49110ed32112b935be0.tar.gz
android_external_libphonenumbergoogle-126c688c23f92d93e5e9e49110ed32112b935be0.tar.bz2
android_external_libphonenumbergoogle-126c688c23f92d93e5e9e49110ed32112b935be0.zip
JAVA: Metadata changes and bug fixes; libphonenumber v5.0
git-svn-id: http://libphonenumber.googlecode.com/svn/trunk@491 ee073f10-1060-11df-b6a4-87a95322a99c
Diffstat (limited to 'java/libphonenumber/src/com/google/i18n')
-rw-r--r--java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java14
-rw-r--r--java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java8
-rw-r--r--java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GAbin610 -> 329 bytes
-rw-r--r--java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_ILbin989 -> 1075 bytes
4 files changed, 21 insertions, 1 deletions
diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java
index da300ca..a7a5e18 100644
--- a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java
+++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java
@@ -433,7 +433,8 @@ final class PhoneNumberMatcher implements Iterator<PhoneNumberMatch> {
/**
* Small helper interface such that the number groups can be checked according to different
- * criteria.
+ * criteria, both for our default way of performing formatting and for any alternate formats we
+ * may want to check.
*/
interface NumberGroupingChecker {
/**
@@ -553,6 +554,17 @@ final class PhoneNumberMatcher implements Iterator<PhoneNumberMatch> {
if (checker.checkGroups(util, number, normalizedCandidate, formattedNumberGroups)) {
return true;
}
+ // If this didn't pass, see if there are any alternate formats, and try them instead.
+ PhoneMetadata alternateFormats =
+ MetadataManager.getAlternateFormatsForCountry(number.getCountryCode());
+ if (alternateFormats != null) {
+ for (NumberFormat alternateFormat : alternateFormats.numberFormats()) {
+ formattedNumberGroups = getNationalNumberGroups(util, number, alternateFormat);
+ if (checker.checkGroups(util, number, normalizedCandidate, formattedNumberGroups)) {
+ return true;
+ }
+ }
+ }
return false;
}
diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java
index d984bbe..8bcbc6e 100644
--- a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java
+++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java
@@ -265,9 +265,17 @@ public class PhoneNumberUtil {
// carrier codes, for example in Brazilian phone numbers. We also allow multiple "+" characters at
// the start.
// Corresponds to the following:
+ // [digits]{minLengthNsn}|
// plus_sign*(([punctuation]|[star])*[digits]){3,}([punctuation]|[star]|[digits]|[alpha])*
+ //
+ // The first reg-ex is to allow short numbers (two digits long) to be parsed if they are entered
+ // as "15" etc, but only if there is no punctuation in them. The second expression restricts the
+ // number of digits to three or more, but then allows them to be in international form, and to
+ // have alpha-characters and punctuation.
+ //
// Note VALID_PUNCTUATION starts with a -, so must be the first in the range.
private static final String VALID_PHONE_NUMBER =
+ DIGITS + "{" + MIN_LENGTH_FOR_NSN + "}" + "|" +
"[" + PLUS_CHARS + "]*+(?:[" + VALID_PUNCTUATION + STAR_SIGN + "]*" + DIGITS + "){3,}[" +
VALID_PUNCTUATION + STAR_SIGN + VALID_ALPHA + DIGITS + "]*";
diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GA b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GA
index fb204d0..1b49771 100644
--- a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GA
+++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GA
Binary files differ
diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IL b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IL
index 9419291..b01451a 100644
--- a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IL
+++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IL
Binary files differ