Browse Source

Remove protobuf-javanano dependency (#1348)

We remove the dependency on protobuf (protobuf-javanano) from the Java library, resurrecting java/libphonenumber/src/com/google/i18n/phonenumbers/Phonemetadata.java which was present until libphonenumber-7.1.1.

Does not affect the C++ or JavaScript libraries.
pull/1349/head
Keghani Kouzoujian 9 years ago
committed by lararennie
parent
commit
96d90b1b1a
605 changed files with 31110 additions and 30536 deletions
  1. +9
    -1
      .travis.yml
  2. +832
    -769
      cpp/src/phonenumbers/alternate_format.cc
  3. +11749
    -11450
      cpp/src/phonenumbers/lite_metadata.cc
  4. +12511
    -12212
      cpp/src/phonenumbers/metadata.cc
  5. +3178
    -3142
      cpp/src/phonenumbers/short_metadata.cc
  6. +875
    -846
      cpp/src/phonenumbers/test_metadata.cc
  7. BIN
      java/carrier/src/com/google/i18n/phonenumbers/carrier/data/config
  8. BIN
      java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/config
  9. BIN
      java/lib/protobuf-javanano-3.0.0-alpha-7.jar
  10. +0
    -54
      java/lib/protobuf-javanano-readme.md
  11. +0
    -9
      java/libphonenumber/pom.xml
  12. +27
    -30
      java/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java
  13. +15
    -43
      java/libphonenumber/src/com/google/i18n/phonenumbers/MetadataManager.java
  14. +1
    -1
      java/libphonenumber/src/com/google/i18n/phonenumbers/MetadataSource.java
  15. +12
    -9
      java/libphonenumber/src/com/google/i18n/phonenumbers/MultiFileMetadataSourceImpl.java
  16. +8
    -8
      java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java
  17. +97
    -113
      java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java
  18. +1119
    -0
      java/libphonenumber/src/com/google/i18n/phonenumbers/Phonemetadata.java
  19. +28
    -28
      java/libphonenumber/src/com/google/i18n/phonenumbers/ShortNumberInfo.java
  20. +8
    -9
      java/libphonenumber/src/com/google/i18n/phonenumbers/SingleFileMetadataSourceImpl.java
  21. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_255
  22. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_27
  23. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_30
  24. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_31
  25. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_34
  26. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_350
  27. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_351
  28. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_352
  29. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_358
  30. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_359
  31. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_36
  32. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_372
  33. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_373
  34. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_380
  35. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_381
  36. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_385
  37. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_43
  38. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_44
  39. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_49
  40. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_505
  41. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_506
  42. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_54
  43. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_55
  44. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_58
  45. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_595
  46. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_61
  47. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_62
  48. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_63
  49. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_66
  50. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_675
  51. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_676
  52. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_679
  53. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_7
  54. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_81
  55. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_84
  56. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_855
  57. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_90
  58. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_91
  59. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_94
  60. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_95
  61. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_971
  62. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_972
  63. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_995
  64. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_800
  65. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_808
  66. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_870
  67. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_878
  68. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_881
  69. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_882
  70. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_883
  71. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_888
  72. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_979
  73. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AC
  74. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AD
  75. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AE
  76. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AF
  77. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AG
  78. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AI
  79. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AL
  80. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AM
  81. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AO
  82. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AR
  83. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AS
  84. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AT
  85. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AU
  86. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AW
  87. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AX
  88. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AZ
  89. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BA
  90. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BB
  91. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BD
  92. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BE
  93. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BF
  94. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BG
  95. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BH
  96. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BI
  97. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BJ
  98. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BL
  99. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BM
  100. BIN
      java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BN

+ 9
- 1
.travis.yml View File

@ -1,5 +1,13 @@
language: java language: java
install:
# Invoke the "travis" profile during Maven steps; see <profile> in pom.xml
# files. This is configured not to build the "cpp-build" module.
# The "mvn install" command will run by default during the "install" phase by
# Travis, without the profile flag. Here we customize the install phase to use
# the relevant profile. If we want to build "cpp-build" with Travis CI it's safe
# to remove this line entirely.
- mvn install -P travis -DskipTests=true -Dmaven.javadoc.skip=true -B -V
script: script:
- mvn test
- mvn -P travis test
- ant clean -f java/build.xml && ant jar -f java/build.xml - ant clean -f java/build.xml && ant jar -f java/build.xml
- ant junit -f java/build.xml - ant junit -f java/build.xml

+ 832
- 769
cpp/src/phonenumbers/alternate_format.cc
File diff suppressed because it is too large
View File


+ 11749
- 11450
cpp/src/phonenumbers/lite_metadata.cc
File diff suppressed because it is too large
View File


+ 12511
- 12212
cpp/src/phonenumbers/metadata.cc
File diff suppressed because it is too large
View File


+ 3178
- 3142
cpp/src/phonenumbers/short_metadata.cc
File diff suppressed because it is too large
View File


+ 875
- 846
cpp/src/phonenumbers/test_metadata.cc
File diff suppressed because it is too large
View File


BIN
java/carrier/src/com/google/i18n/phonenumbers/carrier/data/config View File


BIN
java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/config View File


BIN
java/lib/protobuf-javanano-3.0.0-alpha-7.jar View File


+ 0
- 54
java/lib/protobuf-javanano-readme.md View File

@ -1,54 +0,0 @@
# How to regenerate `Phonemetadata.java`
You need to re-generate
`java/libphonenumber/src/com/google/i18n/phonenumbers/nano/Phonemetadata.java` if you update
`resources/phonemetadata.proto` or the protobuf version.
Here are convenience instructions to update `Phonemetadata.java`.
Checklist:
- Are we still depending on Maven's 3.0.0-alpha-7 version of com.google.protobuf.nano
protobuf-javanano?
- Are you on a Linux x86_64 architecture? Check via the `arch` command in your terminal.
If you answered no to any question, refer instead to the full instructions, [How to update the
protobuf version](#how-to-update-the-protobuf-version).
```
mkdir /tmp/custom_protoc/ && \
cd /tmp/custom_protoc/ && \
wget https://github.com/google/protobuf/releases/download/v3.0.0-beta-4/protoc-3.0.0-beta-4-linux-x86_64.zip && \
unzip protoc-3.0.0-beta-4-linux-x86_64.zip
```
Then go to the root of your libphonenumber git repository and run:
```
/tmp/custom_protoc/bin/protoc --javanano_out=java/libphonenumber/src \
resources/phonemetadata.proto \
--proto_path=resources
```
# How to update the protobuf version
- Start by finding a protobuf library version released to Maven Central that has functionality you
need, e.g. nano. See http://mvnrepository.com/artifact/com.google.protobuf.
- Update the protobuf library dependency's `groupId`, `artifactId`, and `version` to match this
artifact in all the `pom.xml` files. You can find the files by searching for
`<groupId>com.google.protobuf` in the GitHub repository.
- Download the `.jar` from the Maven Repository,
e.g. from http://repo1.maven.org/maven2/com/google/protobuf/nano/protobuf-javanano/3.0.0-alpha-7/,
and copy to `java/lib/`, replacing the previous version's `.jar`.
- See https://github.com/google/protobuf/releases for the release containing the chosen version, and
download the `protoc` binary for your machine's architecture from the same release and use this to
re-generate `java/libphonenumber/src/com/google/i18n/phonenumbers/nano/Phonemetadata.java` and
check in any changes to this file. The command from the root directory is:
```
protoc --javanano_out=java/libphonenumber/src \
resources/phonemetadata.proto \
--proto_path=resources
```
- Update the convenience instructions, [How to regenerate `Phonemetadata.java`]
(#how-to-regenerate-phonemetadatajava).

+ 0
- 9
java/libphonenumber/pom.xml View File

@ -52,13 +52,4 @@
</plugins> </plugins>
</build> </build>
<dependencies>
<dependency>
<groupId>com.google.protobuf.nano</groupId>
<artifactId>protobuf-javanano</artifactId>
<!-- If updating the version, see instructions in java/lib/protobuf-javanano-readme.md. -->
<version>3.0.0-alpha-7</version>
</dependency>
</dependencies>
</project> </project>

+ 27
- 30
java/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java View File

@ -16,8 +16,8 @@
package com.google.i18n.phonenumbers; package com.google.i18n.phonenumbers;
import com.google.i18n.phonenumbers.nano.Phonemetadata.NumberFormat;
import com.google.i18n.phonenumbers.nano.Phonemetadata.PhoneMetadata;
import com.google.i18n.phonenumbers.Phonemetadata.NumberFormat;
import com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
@ -61,11 +61,8 @@ public class AsYouTypeFormatter {
// Character used when appropriate to separate a prefix, such as a long NDD or a country calling // Character used when appropriate to separate a prefix, such as a long NDD or a country calling
// code, from the national number. // code, from the national number.
private static final char SEPARATOR_BEFORE_NATIONAL_NUMBER = ' '; private static final char SEPARATOR_BEFORE_NATIONAL_NUMBER = ' ';
private static final PhoneMetadata EMPTY_METADATA;
static {
EMPTY_METADATA = new PhoneMetadata();
EMPTY_METADATA.internationalPrefix = "NA";
}
private static final PhoneMetadata EMPTY_METADATA =
new PhoneMetadata().setInternationalPrefix("NA");
private PhoneMetadata defaultMetadata; private PhoneMetadata defaultMetadata;
private PhoneMetadata currentMetadata; private PhoneMetadata currentMetadata;
@ -154,7 +151,7 @@ public class AsYouTypeFormatter {
Iterator<NumberFormat> it = possibleFormats.iterator(); Iterator<NumberFormat> it = possibleFormats.iterator();
while (it.hasNext()) { while (it.hasNext()) {
NumberFormat numberFormat = it.next(); NumberFormat numberFormat = it.next();
String pattern = numberFormat.pattern;
String pattern = numberFormat.getPattern();
if (currentFormattingPattern.equals(pattern)) { if (currentFormattingPattern.equals(pattern)) {
return false; return false;
} }
@ -162,7 +159,7 @@ public class AsYouTypeFormatter {
currentFormattingPattern = pattern; currentFormattingPattern = pattern;
shouldAddSpaceAfterNationalPrefix = shouldAddSpaceAfterNationalPrefix =
NATIONAL_PREFIX_SEPARATORS_PATTERN.matcher( NATIONAL_PREFIX_SEPARATORS_PATTERN.matcher(
numberFormat.nationalPrefixFormattingRule).find();
numberFormat.getNationalPrefixFormattingRule()).find();
// With a new formatting template, the matched position using the old template needs to be // With a new formatting template, the matched position using the old template needs to be
// reset. // reset.
lastMatchPosition = 0; lastMatchPosition = 0;
@ -176,17 +173,17 @@ public class AsYouTypeFormatter {
} }
private void getAvailableFormats(String leadingDigits) { private void getAvailableFormats(String leadingDigits) {
NumberFormat[] numberFormats =
(isCompleteNumber && currentMetadata.intlNumberFormat.length > 0)
? currentMetadata.intlNumberFormat
: currentMetadata.numberFormat;
boolean nationalPrefixIsUsedByCountry = (!currentMetadata.nationalPrefix.equals(""));
for (NumberFormat format : numberFormats) {
List<NumberFormat> formatList =
(isCompleteNumber && currentMetadata.intlNumberFormatSize() > 0)
? currentMetadata.intlNumberFormats()
: currentMetadata.numberFormats();
boolean nationalPrefixIsUsedByCountry = currentMetadata.hasNationalPrefix();
for (NumberFormat format : formatList) {
if (!nationalPrefixIsUsedByCountry || isCompleteNumber || if (!nationalPrefixIsUsedByCountry || isCompleteNumber ||
format.nationalPrefixOptionalWhenFormatting ||
format.isNationalPrefixOptionalWhenFormatting() ||
PhoneNumberUtil.formattingRuleHasFirstGroupOnly( PhoneNumberUtil.formattingRuleHasFirstGroupOnly(
format.nationalPrefixFormattingRule)) {
if (isFormatEligible(format.format)) {
format.getNationalPrefixFormattingRule())) {
if (isFormatEligible(format.getFormat())) {
possibleFormats.add(format); possibleFormats.add(format);
} }
} }
@ -203,14 +200,14 @@ public class AsYouTypeFormatter {
Iterator<NumberFormat> it = possibleFormats.iterator(); Iterator<NumberFormat> it = possibleFormats.iterator();
while (it.hasNext()) { while (it.hasNext()) {
NumberFormat format = it.next(); NumberFormat format = it.next();
if (format.leadingDigitsPattern.length == 0) {
if (format.leadingDigitsPatternSize() == 0) {
// Keep everything that isn't restricted by leading digits. // Keep everything that isn't restricted by leading digits.
continue; continue;
} }
int lastLeadingDigitsPattern = int lastLeadingDigitsPattern =
Math.min(indexOfLeadingDigitsPattern, format.leadingDigitsPattern.length - 1);
Math.min(indexOfLeadingDigitsPattern, format.leadingDigitsPatternSize() - 1);
Pattern leadingDigitsPattern = regexCache.getPatternForRegex( Pattern leadingDigitsPattern = regexCache.getPatternForRegex(
format.leadingDigitsPattern[lastLeadingDigitsPattern]);
format.getLeadingDigitsPattern(lastLeadingDigitsPattern));
Matcher m = leadingDigitsPattern.matcher(leadingDigits); Matcher m = leadingDigitsPattern.matcher(leadingDigits);
if (!m.lookingAt()) { if (!m.lookingAt()) {
it.remove(); it.remove();
@ -219,7 +216,7 @@ public class AsYouTypeFormatter {
} }
private boolean createFormattingTemplate(NumberFormat format) { private boolean createFormattingTemplate(NumberFormat format) {
String numberPattern = format.pattern;
String numberPattern = format.getPattern();
// The formatter doesn't format numbers when numberPattern contains "|", e.g. // The formatter doesn't format numbers when numberPattern contains "|", e.g.
// (20|3)\d{4}. In those cases we quickly return. // (20|3)\d{4}. In those cases we quickly return.
@ -233,7 +230,7 @@ public class AsYouTypeFormatter {
// Replace any standalone digit (not the one in d{}) with \d // Replace any standalone digit (not the one in d{}) with \d
numberPattern = STANDALONE_DIGIT_PATTERN.matcher(numberPattern).replaceAll("\\\\d"); numberPattern = STANDALONE_DIGIT_PATTERN.matcher(numberPattern).replaceAll("\\\\d");
formattingTemplate.setLength(0); formattingTemplate.setLength(0);
String tempTemplate = getFormattingTemplate(numberPattern, format.format);
String tempTemplate = getFormattingTemplate(numberPattern, format.getFormat());
if (tempTemplate.length() > 0) { if (tempTemplate.length() > 0) {
formattingTemplate.append(tempTemplate); formattingTemplate.append(tempTemplate);
return true; return true;
@ -431,12 +428,12 @@ public class AsYouTypeFormatter {
*/ */
String attemptToFormatAccruedDigits() { String attemptToFormatAccruedDigits() {
for (NumberFormat numberFormat : possibleFormats) { for (NumberFormat numberFormat : possibleFormats) {
Matcher m = regexCache.getPatternForRegex(numberFormat.pattern).matcher(nationalNumber);
Matcher m = regexCache.getPatternForRegex(numberFormat.getPattern()).matcher(nationalNumber);
if (m.matches()) { if (m.matches()) {
shouldAddSpaceAfterNationalPrefix = shouldAddSpaceAfterNationalPrefix =
NATIONAL_PREFIX_SEPARATORS_PATTERN.matcher( NATIONAL_PREFIX_SEPARATORS_PATTERN.matcher(
numberFormat.nationalPrefixFormattingRule).find();
String formattedNumber = m.replaceAll(numberFormat.format);
numberFormat.getNationalPrefixFormattingRule()).find();
String formattedNumber = m.replaceAll(numberFormat.getFormat());
return appendNationalNumber(formattedNumber); return appendNationalNumber(formattedNumber);
} }
} }
@ -529,7 +526,7 @@ public class AsYouTypeFormatter {
// that national significant numbers in NANPA always start with [2-9] after the national prefix. // that national significant numbers in NANPA always start with [2-9] after the national prefix.
// Numbers beginning with 1[01] can only be short/emergency numbers, which don't need the // Numbers beginning with 1[01] can only be short/emergency numbers, which don't need the
// national prefix. // national prefix.
return (currentMetadata.countryCode == 1) && (nationalNumber.charAt(0) == '1') &&
return (currentMetadata.getCountryCode() == 1) && (nationalNumber.charAt(0) == '1') &&
(nationalNumber.charAt(1) != '0') && (nationalNumber.charAt(1) != '1'); (nationalNumber.charAt(1) != '0') && (nationalNumber.charAt(1) != '1');
} }
@ -540,9 +537,9 @@ public class AsYouTypeFormatter {
startOfNationalNumber = 1; startOfNationalNumber = 1;
prefixBeforeNationalNumber.append('1').append(SEPARATOR_BEFORE_NATIONAL_NUMBER); prefixBeforeNationalNumber.append('1').append(SEPARATOR_BEFORE_NATIONAL_NUMBER);
isCompleteNumber = true; isCompleteNumber = true;
} else if (!currentMetadata.nationalPrefixForParsing.equals("")) {
} else if (currentMetadata.hasNationalPrefixForParsing()) {
Pattern nationalPrefixForParsing = Pattern nationalPrefixForParsing =
regexCache.getPatternForRegex(currentMetadata.nationalPrefixForParsing);
regexCache.getPatternForRegex(currentMetadata.getNationalPrefixForParsing());
Matcher m = nationalPrefixForParsing.matcher(nationalNumber); Matcher m = nationalPrefixForParsing.matcher(nationalNumber);
// Since some national prefix patterns are entirely optional, check that a national prefix // Since some national prefix patterns are entirely optional, check that a national prefix
// could actually be extracted. // could actually be extracted.
@ -570,7 +567,7 @@ public class AsYouTypeFormatter {
private boolean attemptToExtractIdd() { private boolean attemptToExtractIdd() {
Pattern internationalPrefix = Pattern internationalPrefix =
regexCache.getPatternForRegex("\\" + PhoneNumberUtil.PLUS_SIGN + "|" + regexCache.getPatternForRegex("\\" + PhoneNumberUtil.PLUS_SIGN + "|" +
currentMetadata.internationalPrefix);
currentMetadata.getInternationalPrefix());
Matcher iddMatcher = internationalPrefix.matcher(accruedInputWithoutFormatting); Matcher iddMatcher = internationalPrefix.matcher(accruedInputWithoutFormatting);
if (iddMatcher.lookingAt()) { if (iddMatcher.lookingAt()) {
isCompleteNumber = true; isCompleteNumber = true;


+ 15
- 43
java/libphonenumber/src/com/google/i18n/phonenumbers/MetadataManager.java View File

@ -16,16 +16,16 @@
package com.google.i18n.phonenumbers; package com.google.i18n.phonenumbers;
import com.google.i18n.phonenumbers.nano.Phonemetadata.PhoneMetadata;
import com.google.i18n.phonenumbers.nano.Phonemetadata.PhoneMetadataCollection;
import com.google.protobuf.nano.CodedInputByteBufferNano;
import com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata;
import com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadataCollection;
import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
@ -61,39 +61,13 @@ final class MetadataManager {
private MetadataManager() { private MetadataManager() {
} }
// The size of the byte buffer in bytes used to convert a stream containing metadata for a single
// region, to a nanoproto-compatible CodedInputByteBufferNano. This was determined by the size of
// the binary metadata files that contain each region's metadata.
static final int DEFAULT_BUFFER_SIZE = 16 * 1024;
// The size of the byte buffer in bytes used to convert a stream containing metadata for all
// regions, to a nanoproto-compatible CodedInputByteBufferNano. This was determined by the size of
// the binary metadata file that contains all regions' metadata.
static final int ALL_REGIONS_BUFFER_SIZE = 256 * 1024;
static CodedInputByteBufferNano convertStreamToByteBuffer(ObjectInputStream in, int bufferSize)
throws IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
int nRead;
byte[] data = new byte[bufferSize];
while ((nRead = in.read(data, 0, bufferSize)) != -1) {
outputStream.write(data, 0, nRead);
}
outputStream.flush();
return CodedInputByteBufferNano.newInstance(outputStream.toByteArray());
}
/** /**
* Loads and returns the metadata protocol buffer from the given stream and closes the stream.
* Loads and returns the metadata object from the given stream and closes the stream.
* *
* @param source the non-null stream from which metadata is to be read.
* @param bufferSize the size of the buffer in bytes used to convert the stream to a
nanoproto-compatible {@code CodedInputByteBufferNano}.
* @return the loaded metadata protocol buffer.
* @param source the non-null stream from which metadata is to be read
* @return the loaded metadata object
*/ */
static PhoneMetadataCollection loadMetadataAndCloseInput(InputStream source, int bufferSize) {
static PhoneMetadataCollection loadMetadataAndCloseInput(InputStream source) {
ObjectInputStream ois = null; ObjectInputStream ois = null;
try { try {
try { try {
@ -103,7 +77,7 @@ final class MetadataManager {
} }
PhoneMetadataCollection metadataCollection = new PhoneMetadataCollection(); PhoneMetadataCollection metadataCollection = new PhoneMetadataCollection();
try { try {
metadataCollection.mergeFrom(convertStreamToByteBuffer(ois, bufferSize));
metadataCollection.readExternal(ois);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("cannot load/parse metadata", e); throw new RuntimeException("cannot load/parse metadata", e);
} }
@ -130,10 +104,9 @@ final class MetadataManager {
// that they are present, by checking the map of available data first. // that they are present, by checking the map of available data first.
throw new IllegalStateException("missing metadata: " + fileName); throw new IllegalStateException("missing metadata: " + fileName);
} }
PhoneMetadataCollection alternateFormatData =
loadMetadataAndCloseInput(source, DEFAULT_BUFFER_SIZE);
for (PhoneMetadata metadata : alternateFormatData.metadata) {
callingCodeToAlternateFormatsMap.put(metadata.countryCode, metadata);
PhoneMetadataCollection alternateFormats = loadMetadataAndCloseInput(source);
for (PhoneMetadata metadata : alternateFormats.getMetadataList()) {
callingCodeToAlternateFormatsMap.put(metadata.getCountryCode(), metadata);
} }
} }
@ -157,10 +130,9 @@ final class MetadataManager {
// that they are present, by checking the map of available data first. // that they are present, by checking the map of available data first.
throw new IllegalStateException("missing metadata: " + fileName); throw new IllegalStateException("missing metadata: " + fileName);
} }
PhoneMetadataCollection shortNumberData =
loadMetadataAndCloseInput(source, DEFAULT_BUFFER_SIZE);
for (PhoneMetadata metadata : shortNumberData.metadata) {
regionCodeToShortNumberMetadataMap.put(regionCode, metadata);
PhoneMetadataCollection shortNumberMetadata = loadMetadataAndCloseInput(source);
for (PhoneMetadata metadata : shortNumberMetadata.getMetadataList()) {
regionCodeToShortNumberMetadataMap.put(regionCode, metadata);
} }
} }


+ 1
- 1
java/libphonenumber/src/com/google/i18n/phonenumbers/MetadataSource.java View File

@ -16,7 +16,7 @@
package com.google.i18n.phonenumbers; package com.google.i18n.phonenumbers;
import com.google.i18n.phonenumbers.nano.Phonemetadata.PhoneMetadata;
import com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata;
/** /**
* A source for phone metadata for all regions. * A source for phone metadata for all regions.


+ 12
- 9
java/libphonenumber/src/com/google/i18n/phonenumbers/MultiFileMetadataSourceImpl.java View File

@ -16,12 +16,16 @@
package com.google.i18n.phonenumbers; package com.google.i18n.phonenumbers;
import com.google.i18n.phonenumbers.nano.Phonemetadata.PhoneMetadata;
import com.google.i18n.phonenumbers.nano.Phonemetadata.PhoneMetadataCollection;
import com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata;
import com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadataCollection;
import java.io.InputStream; import java.io.InputStream;
import java.util.concurrent.ConcurrentHashMap;
import java.io.ObjectInputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -116,17 +120,16 @@ final class MultiFileMetadataSourceImpl implements MetadataSource {
// that they are present, by checking the map of available data first. // that they are present, by checking the map of available data first.
throw new IllegalStateException("missing metadata: " + fileName); throw new IllegalStateException("missing metadata: " + fileName);
} }
PhoneMetadataCollection metadataCollection =
MetadataManager.loadMetadataAndCloseInput(source, MetadataManager.DEFAULT_BUFFER_SIZE);
PhoneMetadata[] metadatas = metadataCollection.metadata;
if (metadatas.length == 0) {
PhoneMetadataCollection metadataCollection = MetadataManager.loadMetadataAndCloseInput(source);
List<PhoneMetadata> metadataList = metadataCollection.getMetadataList();
if (metadataList.isEmpty()) {
// Sanity check; this should not happen since we build with non-empty metadata. // Sanity check; this should not happen since we build with non-empty metadata.
throw new IllegalStateException("empty metadata: " + fileName); throw new IllegalStateException("empty metadata: " + fileName);
} }
if (metadatas.length > 1) {
if (metadataList.size() > 1) {
logger.log(Level.WARNING, "invalid metadata (too many entries): " + fileName); logger.log(Level.WARNING, "invalid metadata (too many entries): " + fileName);
} }
PhoneMetadata metadata = metadatas[0];
PhoneMetadata metadata = metadataList.get(0);
PhoneMetadata oldValue = map.putIfAbsent(key, metadata); PhoneMetadata oldValue = map.putIfAbsent(key, metadata);
return (oldValue != null) ? oldValue : metadata; return (oldValue != null) ? oldValue : metadata;
} }


+ 8
- 8
java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java View File

@ -19,10 +19,10 @@ package com.google.i18n.phonenumbers;
import com.google.i18n.phonenumbers.PhoneNumberUtil.Leniency; import com.google.i18n.phonenumbers.PhoneNumberUtil.Leniency;
import com.google.i18n.phonenumbers.PhoneNumberUtil.MatchType; import com.google.i18n.phonenumbers.PhoneNumberUtil.MatchType;
import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat; import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat;
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
import com.google.i18n.phonenumbers.Phonemetadata.NumberFormat;
import com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata;
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber.CountryCodeSource; import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber.CountryCodeSource;
import com.google.i18n.phonenumbers.nano.Phonemetadata.NumberFormat;
import com.google.i18n.phonenumbers.nano.Phonemetadata.PhoneMetadata;
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
import java.lang.Character.UnicodeBlock; import java.lang.Character.UnicodeBlock;
import java.util.Iterator; import java.util.Iterator;
@ -585,7 +585,7 @@ final class PhoneNumberMatcher implements Iterator<PhoneNumberMatch> {
PhoneMetadata alternateFormats = PhoneMetadata alternateFormats =
MetadataManager.getAlternateFormatsForCountry(number.getCountryCode()); MetadataManager.getAlternateFormatsForCountry(number.getCountryCode());
if (alternateFormats != null) { if (alternateFormats != null) {
for (NumberFormat alternateFormat : alternateFormats.numberFormat) {
for (NumberFormat alternateFormat : alternateFormats.numberFormats()) {
formattedNumberGroups = getNationalNumberGroups(util, number, alternateFormat); formattedNumberGroups = getNationalNumberGroups(util, number, alternateFormat);
if (checker.checkGroups(util, number, normalizedCandidate, formattedNumberGroups)) { if (checker.checkGroups(util, number, normalizedCandidate, formattedNumberGroups)) {
return true; return true;
@ -665,17 +665,17 @@ final class PhoneNumberMatcher implements Iterator<PhoneNumberMatch> {
// Check if a national prefix should be present when formatting this number. // Check if a national prefix should be present when formatting this number.
String nationalNumber = util.getNationalSignificantNumber(number); String nationalNumber = util.getNationalSignificantNumber(number);
NumberFormat formatRule = NumberFormat formatRule =
util.chooseFormattingPatternForNumber(metadata.numberFormat, nationalNumber);
util.chooseFormattingPatternForNumber(metadata.numberFormats(), nationalNumber);
// To do this, we check that a national prefix formatting rule was present and that it wasn't // To do this, we check that a national prefix formatting rule was present and that it wasn't
// just the first-group symbol ($1) with punctuation. // just the first-group symbol ($1) with punctuation.
if ((formatRule != null) && formatRule.nationalPrefixFormattingRule.length() > 0) {
if (formatRule.nationalPrefixOptionalWhenFormatting) {
if ((formatRule != null) && formatRule.getNationalPrefixFormattingRule().length() > 0) {
if (formatRule.isNationalPrefixOptionalWhenFormatting()) {
// The national-prefix is optional in these cases, so we don't need to check if it was // The national-prefix is optional in these cases, so we don't need to check if it was
// present. // present.
return true; return true;
} }
if (PhoneNumberUtil.formattingRuleHasFirstGroupOnly( if (PhoneNumberUtil.formattingRuleHasFirstGroupOnly(
formatRule.nationalPrefixFormattingRule)) {
formatRule.getNationalPrefixFormattingRule())) {
// National Prefix not needed for this number. // National Prefix not needed for this number.
return true; return true;
} }


+ 97
- 113
java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java View File

@ -16,11 +16,11 @@
package com.google.i18n.phonenumbers; package com.google.i18n.phonenumbers;
import com.google.i18n.phonenumbers.Phonemetadata.NumberFormat;
import com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata;
import com.google.i18n.phonenumbers.Phonemetadata.PhoneNumberDesc;
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber; import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber.CountryCodeSource; import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber.CountryCodeSource;
import com.google.i18n.phonenumbers.nano.Phonemetadata.NumberFormat;
import com.google.i18n.phonenumbers.nano.Phonemetadata.PhoneMetadata;
import com.google.i18n.phonenumbers.nano.Phonemetadata.PhoneNumberDesc;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
@ -612,24 +612,6 @@ public class PhoneNumberUtil {
nanpaRegions.addAll(countryCallingCodeToRegionCodeMap.get(NANPA_COUNTRY_CODE)); nanpaRegions.addAll(countryCallingCodeToRegionCodeMap.get(NANPA_COUNTRY_CODE));
} }
/**
* Returns a copy of the given NumberFormat object.
*/
static NumberFormat copyNumberFormat(NumberFormat other) {
NumberFormat copy = new NumberFormat();
copy.pattern = other.pattern;
copy.format = other.format;
int leadingDigitsPatternSize = other.leadingDigitsPattern.length;
copy.leadingDigitsPattern = new String[leadingDigitsPatternSize];
for (int i = 0; i < leadingDigitsPatternSize; i++) {
copy.leadingDigitsPattern[i] = other.leadingDigitsPattern[i];
}
copy.nationalPrefixFormattingRule = other.nationalPrefixFormattingRule;
copy.domesticCarrierCodeFormattingRule = other.domesticCarrierCodeFormattingRule;
copy.nationalPrefixOptionalWhenFormatting = other.nationalPrefixOptionalWhenFormatting;
return copy;
}
/** /**
* Attempts to extract a possible number from the string passed in. This currently strips all * Attempts to extract a possible number from the string passed in. This currently strips all
* leading characters that cannot be used to start a phone number. Characters that can be used to * leading characters that cannot be used to start a phone number. Characters that can be used to
@ -813,7 +795,7 @@ public class PhoneNumberUtil {
} }
// If a country doesn't use a national prefix, and this number doesn't have an Italian leading // If a country doesn't use a national prefix, and this number doesn't have an Italian leading
// zero, we assume it is a closed dialling plan with no area codes. // zero, we assume it is a closed dialling plan with no area codes.
if (metadata.nationalPrefix.equals("") && !number.isItalianLeadingZero()) {
if (!metadata.hasNationalPrefix() && !number.isItalianLeadingZero()) {
return 0; return 0;
} }
@ -1172,29 +1154,29 @@ public class PhoneNumberUtil {
StringBuilder formattedNumber = new StringBuilder(20); StringBuilder formattedNumber = new StringBuilder(20);
NumberFormat formattingPattern = NumberFormat formattingPattern =
chooseFormattingPatternForNumber(userDefinedFormats.toArray(
new NumberFormat[userDefinedFormats.size()]), nationalSignificantNumber);
chooseFormattingPatternForNumber(userDefinedFormats, nationalSignificantNumber);
if (formattingPattern == null) { if (formattingPattern == null) {
// If no pattern above is matched, we format the number as a whole. // If no pattern above is matched, we format the number as a whole.
formattedNumber.append(nationalSignificantNumber); formattedNumber.append(nationalSignificantNumber);
} else { } else {
NumberFormat numFormatCopy = new NumberFormat();
// Before we do a replacement of the national prefix pattern $NP with the national prefix, we // Before we do a replacement of the national prefix pattern $NP with the national prefix, we
// need to copy the rule so that subsequent replacements for different numbers have the // need to copy the rule so that subsequent replacements for different numbers have the
// appropriate national prefix. // appropriate national prefix.
NumberFormat numFormatCopy = copyNumberFormat(formattingPattern);
String nationalPrefixFormattingRule = formattingPattern.nationalPrefixFormattingRule;
numFormatCopy.mergeFrom(formattingPattern);
String nationalPrefixFormattingRule = formattingPattern.getNationalPrefixFormattingRule();
if (nationalPrefixFormattingRule.length() > 0) { if (nationalPrefixFormattingRule.length() > 0) {
String nationalPrefix = metadata.nationalPrefix;
String nationalPrefix = metadata.getNationalPrefix();
if (nationalPrefix.length() > 0) { if (nationalPrefix.length() > 0) {
// Replace $NP with national prefix and $FG with the first group ($1). // Replace $NP with national prefix and $FG with the first group ($1).
nationalPrefixFormattingRule = nationalPrefixFormattingRule =
NP_PATTERN.matcher(nationalPrefixFormattingRule).replaceFirst(nationalPrefix); NP_PATTERN.matcher(nationalPrefixFormattingRule).replaceFirst(nationalPrefix);
nationalPrefixFormattingRule = nationalPrefixFormattingRule =
FG_PATTERN.matcher(nationalPrefixFormattingRule).replaceFirst("\\$1"); FG_PATTERN.matcher(nationalPrefixFormattingRule).replaceFirst("\\$1");
numFormatCopy.nationalPrefixFormattingRule = nationalPrefixFormattingRule;
numFormatCopy.setNationalPrefixFormattingRule(nationalPrefixFormattingRule);
} else { } else {
// We don't want to have a rule for how to format the national prefix if there isn't one. // We don't want to have a rule for how to format the national prefix if there isn't one.
numFormatCopy.nationalPrefixFormattingRule = "";
numFormatCopy.clearNationalPrefixFormattingRule();
} }
} }
formattedNumber.append( formattedNumber.append(
@ -1410,16 +1392,16 @@ public class PhoneNumberUtil {
} }
// Metadata cannot be null because we checked 'isValidRegionCode()' above. // Metadata cannot be null because we checked 'isValidRegionCode()' above.
PhoneMetadata metadataForRegionCallingFrom = getMetadataForRegion(regionCallingFrom); PhoneMetadata metadataForRegionCallingFrom = getMetadataForRegion(regionCallingFrom);
String internationalPrefix = metadataForRegionCallingFrom.internationalPrefix;
String internationalPrefix = metadataForRegionCallingFrom.getInternationalPrefix();
// For regions that have multiple international prefixes, the international format of the // For regions that have multiple international prefixes, the international format of the
// number is returned, unless there is a preferred international prefix. // number is returned, unless there is a preferred international prefix.
String internationalPrefixForFormatting = ""; String internationalPrefixForFormatting = "";
if (UNIQUE_INTERNATIONAL_PREFIX.matcher(internationalPrefix).matches()) { if (UNIQUE_INTERNATIONAL_PREFIX.matcher(internationalPrefix).matches()) {
internationalPrefixForFormatting = internationalPrefix; internationalPrefixForFormatting = internationalPrefix;
} else if (!metadataForRegionCallingFrom.preferredInternationalPrefix.equals("")) {
} else if (metadataForRegionCallingFrom.hasPreferredInternationalPrefix()) {
internationalPrefixForFormatting = internationalPrefixForFormatting =
metadataForRegionCallingFrom.preferredInternationalPrefix;
metadataForRegionCallingFrom.getPreferredInternationalPrefix();
} }
String regionCode = getRegionCodeForCountryCode(countryCallingCode); String regionCode = getRegionCodeForCountryCode(countryCallingCode);
@ -1505,7 +1487,7 @@ public class PhoneNumberUtil {
PhoneMetadata metadata = getMetadataForRegion(regionCode); PhoneMetadata metadata = getMetadataForRegion(regionCode);
String nationalNumber = getNationalSignificantNumber(number); String nationalNumber = getNationalSignificantNumber(number);
NumberFormat formatRule = NumberFormat formatRule =
chooseFormattingPatternForNumber(metadata.numberFormat, nationalNumber);
chooseFormattingPatternForNumber(metadata.numberFormats(), nationalNumber);
// The format rule could still be null here if the national number was 0 and there was no // The format rule could still be null here if the national number was 0 and there was no
// raw input (this should not be possible for numbers generated by the phonenumber library // raw input (this should not be possible for numbers generated by the phonenumber library
// as they would also not have a country calling code and we would have exited earlier). // as they would also not have a country calling code and we would have exited earlier).
@ -1517,7 +1499,7 @@ public class PhoneNumberUtil {
// return the national format. // return the national format.
// TODO: Refactor the code below with the code in // TODO: Refactor the code below with the code in
// isNationalPrefixPresentIfRequired. // isNationalPrefixPresentIfRequired.
String candidateNationalPrefixRule = formatRule.nationalPrefixFormattingRule;
String candidateNationalPrefixRule = formatRule.getNationalPrefixFormattingRule();
// We assume that the first-group symbol will never be _before_ the national prefix. // We assume that the first-group symbol will never be _before_ the national prefix.
int indexOfFirstGroup = candidateNationalPrefixRule.indexOf("$1"); int indexOfFirstGroup = candidateNationalPrefixRule.indexOf("$1");
if (indexOfFirstGroup <= 0) { if (indexOfFirstGroup <= 0) {
@ -1533,8 +1515,9 @@ public class PhoneNumberUtil {
break; break;
} }
// Otherwise, we need to remove the national prefix from our output. // Otherwise, we need to remove the national prefix from our output.
NumberFormat numFormatCopy = copyNumberFormat(formatRule);
numFormatCopy.nationalPrefixFormattingRule = "";
NumberFormat numFormatCopy = new NumberFormat();
numFormatCopy.mergeFrom(formatRule);
numFormatCopy.clearNationalPrefixFormattingRule();
List<NumberFormat> numberFormats = new ArrayList<NumberFormat>(1); List<NumberFormat> numberFormats = new ArrayList<NumberFormat>(1);
numberFormats.add(numFormatCopy); numberFormats.add(numFormatCopy);
formattedNumber = formatByPattern(number, PhoneNumberFormat.NATIONAL, numberFormats); formattedNumber = formatByPattern(number, PhoneNumberFormat.NATIONAL, numberFormats);
@ -1591,7 +1574,7 @@ public class PhoneNumberUtil {
} }
String nationalNumber = getNationalSignificantNumber(number); String nationalNumber = getNationalSignificantNumber(number);
NumberFormat formatRule = NumberFormat formatRule =
chooseFormattingPatternForNumber(metadata.numberFormat, nationalNumber);
chooseFormattingPatternForNumber(metadata.numberFormats(), nationalNumber);
return formatRule != null; return formatRule != null;
} }
@ -1655,17 +1638,18 @@ public class PhoneNumberUtil {
} else if (metadataForRegionCallingFrom != null && } else if (metadataForRegionCallingFrom != null &&
countryCode == getCountryCodeForValidRegion(regionCallingFrom)) { countryCode == getCountryCodeForValidRegion(regionCallingFrom)) {
NumberFormat formattingPattern = NumberFormat formattingPattern =
chooseFormattingPatternForNumber(metadataForRegionCallingFrom.numberFormat,
chooseFormattingPatternForNumber(metadataForRegionCallingFrom.numberFormats(),
nationalNumber); nationalNumber);
if (formattingPattern == null) { if (formattingPattern == null) {
// If no pattern above is matched, we format the original input. // If no pattern above is matched, we format the original input.
return rawInput; return rawInput;
} }
NumberFormat newFormat = copyNumberFormat(formattingPattern);
NumberFormat newFormat = new NumberFormat();
newFormat.mergeFrom(formattingPattern);
// The first group is the first group of digits that the user wrote together. // The first group is the first group of digits that the user wrote together.
newFormat.pattern = "(\\d+)(.*)";
newFormat.setPattern("(\\d+)(.*)");
// Here we just concatenate them back together after the national prefix has been fixed. // Here we just concatenate them back together after the national prefix has been fixed.
newFormat.format = "$1$2";
newFormat.setFormat("$1$2");
// Now we format using this pattern instead of the default pattern, but with the national // Now we format using this pattern instead of the default pattern, but with the national
// prefix prefixed if necessary. // prefix prefixed if necessary.
// This will not work in the cases where the pattern (and not the leading digits) decide // This will not work in the cases where the pattern (and not the leading digits) decide
@ -1678,11 +1662,11 @@ public class PhoneNumberUtil {
// prefixes, the international format of the number is returned, unless there is a preferred // prefixes, the international format of the number is returned, unless there is a preferred
// international prefix. // international prefix.
if (metadataForRegionCallingFrom != null) { if (metadataForRegionCallingFrom != null) {
String internationalPrefix = metadataForRegionCallingFrom.internationalPrefix;
String internationalPrefix = metadataForRegionCallingFrom.getInternationalPrefix();
internationalPrefixForFormatting = internationalPrefixForFormatting =
UNIQUE_INTERNATIONAL_PREFIX.matcher(internationalPrefix).matches() UNIQUE_INTERNATIONAL_PREFIX.matcher(internationalPrefix).matches()
? internationalPrefix ? internationalPrefix
: metadataForRegionCallingFrom.preferredInternationalPrefix;
: metadataForRegionCallingFrom.getPreferredInternationalPrefix();
} }
StringBuilder formattedNumber = new StringBuilder(rawInput); StringBuilder formattedNumber = new StringBuilder(rawInput);
String regionCode = getRegionCodeForCountryCode(countryCode); String regionCode = getRegionCodeForCountryCode(countryCode);
@ -1764,27 +1748,27 @@ public class PhoneNumberUtil {
PhoneMetadata metadata, PhoneMetadata metadata,
PhoneNumberFormat numberFormat, PhoneNumberFormat numberFormat,
String carrierCode) { String carrierCode) {
NumberFormat[] intlNumberFormats = metadata.intlNumberFormat;
List<NumberFormat> intlNumberFormats = metadata.intlNumberFormats();
// When the intlNumberFormats exists, we use that to format national number for the // When the intlNumberFormats exists, we use that to format national number for the
// INTERNATIONAL format instead of using the numberDesc.numberFormats. // INTERNATIONAL format instead of using the numberDesc.numberFormats.
NumberFormat[] availableFormats =
(intlNumberFormats.length == 0 || numberFormat == PhoneNumberFormat.NATIONAL)
? metadata.numberFormat
: metadata.intlNumberFormat;
List<NumberFormat> availableFormats =
(intlNumberFormats.size() == 0 || numberFormat == PhoneNumberFormat.NATIONAL)
? metadata.numberFormats()
: metadata.intlNumberFormats();
NumberFormat formattingPattern = chooseFormattingPatternForNumber(availableFormats, number); NumberFormat formattingPattern = chooseFormattingPatternForNumber(availableFormats, number);
return (formattingPattern == null) return (formattingPattern == null)
? number ? number
: formatNsnUsingPattern(number, formattingPattern, numberFormat, carrierCode); : formatNsnUsingPattern(number, formattingPattern, numberFormat, carrierCode);
} }
NumberFormat chooseFormattingPatternForNumber(NumberFormat[] availableFormats,
NumberFormat chooseFormattingPatternForNumber(List<NumberFormat> availableFormats,
String nationalNumber) { String nationalNumber) {
for (NumberFormat numFormat : availableFormats) { for (NumberFormat numFormat : availableFormats) {
int size = numFormat.leadingDigitsPattern.length;
int size = numFormat.leadingDigitsPatternSize();
if (size == 0 || regexCache.getPatternForRegex( if (size == 0 || regexCache.getPatternForRegex(
// We always use the last leading_digits_pattern, as it is the most detailed. // We always use the last leading_digits_pattern, as it is the most detailed.
numFormat.leadingDigitsPattern[size - 1]).matcher(nationalNumber).lookingAt()) {
Matcher m = regexCache.getPatternForRegex(numFormat.pattern).matcher(nationalNumber);
numFormat.getLeadingDigitsPattern(size - 1)).matcher(nationalNumber).lookingAt()) {
Matcher m = regexCache.getPatternForRegex(numFormat.getPattern()).matcher(nationalNumber);
if (m.matches()) { if (m.matches()) {
return numFormat; return numFormat;
} }
@ -1806,15 +1790,15 @@ public class PhoneNumberUtil {
NumberFormat formattingPattern, NumberFormat formattingPattern,
PhoneNumberFormat numberFormat, PhoneNumberFormat numberFormat,
String carrierCode) { String carrierCode) {
String numberFormatRule = formattingPattern.format;
String numberFormatRule = formattingPattern.getFormat();
Matcher m = Matcher m =
regexCache.getPatternForRegex(formattingPattern.pattern).matcher(nationalNumber);
regexCache.getPatternForRegex(formattingPattern.getPattern()).matcher(nationalNumber);
String formattedNationalNumber = ""; String formattedNationalNumber = "";
if (numberFormat == PhoneNumberFormat.NATIONAL && if (numberFormat == PhoneNumberFormat.NATIONAL &&
carrierCode != null && carrierCode.length() > 0 && carrierCode != null && carrierCode.length() > 0 &&
formattingPattern.domesticCarrierCodeFormattingRule.length() > 0) {
formattingPattern.getDomesticCarrierCodeFormattingRule().length() > 0) {
// Replace the $CC in the formatting rule with the desired carrier code. // Replace the $CC in the formatting rule with the desired carrier code.
String carrierCodeFormattingRule = formattingPattern.domesticCarrierCodeFormattingRule;
String carrierCodeFormattingRule = formattingPattern.getDomesticCarrierCodeFormattingRule();
carrierCodeFormattingRule = carrierCodeFormattingRule =
CC_PATTERN.matcher(carrierCodeFormattingRule).replaceFirst(carrierCode); CC_PATTERN.matcher(carrierCodeFormattingRule).replaceFirst(carrierCode);
// Now replace the $FG in the formatting rule with the first group and the carrier code // Now replace the $FG in the formatting rule with the first group and the carrier code
@ -1824,7 +1808,7 @@ public class PhoneNumberUtil {
formattedNationalNumber = m.replaceAll(numberFormatRule); formattedNationalNumber = m.replaceAll(numberFormatRule);
} else { } else {
// Use the national prefix formatting rule instead. // Use the national prefix formatting rule instead.
String nationalPrefixFormattingRule = formattingPattern.nationalPrefixFormattingRule;
String nationalPrefixFormattingRule = formattingPattern.getNationalPrefixFormattingRule();
if (numberFormat == PhoneNumberFormat.NATIONAL && if (numberFormat == PhoneNumberFormat.NATIONAL &&
nationalPrefixFormattingRule != null && nationalPrefixFormattingRule != null &&
nationalPrefixFormattingRule.length() > 0) { nationalPrefixFormattingRule.length() > 0) {
@ -1881,11 +1865,11 @@ public class PhoneNumberUtil {
// invalid number. // invalid number.
PhoneNumberDesc desc = getNumberDescByType(getMetadataForRegion(regionCode), PhoneNumberDesc desc = getNumberDescByType(getMetadataForRegion(regionCode),
PhoneNumberType.FIXED_LINE); PhoneNumberType.FIXED_LINE);
if (desc.exampleNumber.equals("")) {
if (!desc.hasExampleNumber()) {
// This shouldn't happen; we have a test for this. // This shouldn't happen; we have a test for this.
return null; return null;
} }
String exampleNumber = desc.exampleNumber;
String exampleNumber = desc.getExampleNumber();
// Try and make the number invalid. We do this by changing the length. We try reducing the // Try and make the number invalid. We do this by changing the length. We try reducing the
// length of the number, since currently no region has a number that is the same length as // length of the number, since currently no region has a number that is the same length as
// MIN_LENGTH_FOR_NSN. This is probably quicker than making the number longer, which is another // MIN_LENGTH_FOR_NSN. This is probably quicker than making the number longer, which is another
@ -1933,8 +1917,8 @@ public class PhoneNumberUtil {
} }
PhoneNumberDesc desc = getNumberDescByType(getMetadataForRegion(regionCode), type); PhoneNumberDesc desc = getNumberDescByType(getMetadataForRegion(regionCode), type);
try { try {
if (!desc.exampleNumber.equals("")) {
return parse(desc.exampleNumber, regionCode);
if (desc.hasExampleNumber()) {
return parse(desc.getExampleNumber(), regionCode);
} }
} catch (NumberParseException e) { } catch (NumberParseException e) {
logger.log(Level.SEVERE, e.toString()); logger.log(Level.SEVERE, e.toString());
@ -1962,8 +1946,8 @@ public class PhoneNumberUtil {
PhoneNumberDesc desc = getNumberDescByType( PhoneNumberDesc desc = getNumberDescByType(
getMetadataForNonGeographicalRegion(countryCallingCode), type); getMetadataForNonGeographicalRegion(countryCallingCode), type);
try { try {
if (!desc.exampleNumber.equals("")) {
return parse("+" + countryCallingCode + desc.exampleNumber, UNKNOWN_REGION);
if (desc.hasExampleNumber()) {
return parse("+" + countryCallingCode + desc.getExampleNumber(), UNKNOWN_REGION);
} }
} catch (NumberParseException e) { } catch (NumberParseException e) {
logger.log(Level.SEVERE, e.toString()); logger.log(Level.SEVERE, e.toString());
@ -1984,10 +1968,10 @@ public class PhoneNumberUtil {
public PhoneNumber getExampleNumberForNonGeoEntity(int countryCallingCode) { public PhoneNumber getExampleNumberForNonGeoEntity(int countryCallingCode) {
PhoneMetadata metadata = getMetadataForNonGeographicalRegion(countryCallingCode); PhoneMetadata metadata = getMetadataForNonGeographicalRegion(countryCallingCode);
if (metadata != null) { if (metadata != null) {
PhoneNumberDesc desc = metadata.generalDesc;
PhoneNumberDesc desc = metadata.getGeneralDesc();
try { try {
if (!desc.exampleNumber.equals("")) {
return parse("+" + countryCallingCode + desc.exampleNumber, UNKNOWN_REGION);
if (desc.hasExampleNumber()) {
return parse("+" + countryCallingCode + desc.getExampleNumber(), UNKNOWN_REGION);
} }
} catch (NumberParseException e) { } catch (NumberParseException e) {
logger.log(Level.SEVERE, e.toString()); logger.log(Level.SEVERE, e.toString());
@ -2010,8 +1994,8 @@ public class PhoneNumberUtil {
if (numberFormat == PhoneNumberFormat.RFC3966) { if (numberFormat == PhoneNumberFormat.RFC3966) {
formattedNumber.append(RFC3966_EXTN_PREFIX).append(number.getExtension()); formattedNumber.append(RFC3966_EXTN_PREFIX).append(number.getExtension());
} else { } else {
if (!metadata.preferredExtnPrefix.equals("")) {
formattedNumber.append(metadata.preferredExtnPrefix).append(number.getExtension());
if (metadata.hasPreferredExtnPrefix()) {
formattedNumber.append(metadata.getPreferredExtnPrefix()).append(number.getExtension());
} else { } else {
formattedNumber.append(DEFAULT_EXTN_PREFIX).append(number.getExtension()); formattedNumber.append(DEFAULT_EXTN_PREFIX).append(number.getExtension());
} }
@ -2022,28 +2006,28 @@ public class PhoneNumberUtil {
PhoneNumberDesc getNumberDescByType(PhoneMetadata metadata, PhoneNumberType type) { PhoneNumberDesc getNumberDescByType(PhoneMetadata metadata, PhoneNumberType type) {
switch (type) { switch (type) {
case PREMIUM_RATE: case PREMIUM_RATE:
return metadata.premiumRate;
return metadata.getPremiumRate();
case TOLL_FREE: case TOLL_FREE:
return metadata.tollFree;
return metadata.getTollFree();
case MOBILE: case MOBILE:
return metadata.mobile;
return metadata.getMobile();
case FIXED_LINE: case FIXED_LINE:
case FIXED_LINE_OR_MOBILE: case FIXED_LINE_OR_MOBILE:
return metadata.fixedLine;
return metadata.getFixedLine();
case SHARED_COST: case SHARED_COST:
return metadata.sharedCost;
return metadata.getSharedCost();
case VOIP: case VOIP:
return metadata.voip;
return metadata.getVoip();
case PERSONAL_NUMBER: case PERSONAL_NUMBER:
return metadata.personalNumber;
return metadata.getPersonalNumber();
case PAGER: case PAGER:
return metadata.pager;
return metadata.getPager();
case UAN: case UAN:
return metadata.uan;
return metadata.getUan();
case VOICEMAIL: case VOICEMAIL:
return metadata.voicemail;
return metadata.getVoicemail();
default: default:
return metadata.generalDesc;
return metadata.getGeneralDesc();
} }
} }
@ -2064,48 +2048,48 @@ public class PhoneNumberUtil {
} }
private PhoneNumberType getNumberTypeHelper(String nationalNumber, PhoneMetadata metadata) { private PhoneNumberType getNumberTypeHelper(String nationalNumber, PhoneMetadata metadata) {
if (!isNumberMatchingDesc(nationalNumber, metadata.generalDesc)) {
if (!isNumberMatchingDesc(nationalNumber, metadata.getGeneralDesc())) {
return PhoneNumberType.UNKNOWN; return PhoneNumberType.UNKNOWN;
} }
if (isNumberMatchingDesc(nationalNumber, metadata.premiumRate)) {
if (isNumberMatchingDesc(nationalNumber, metadata.getPremiumRate())) {
return PhoneNumberType.PREMIUM_RATE; return PhoneNumberType.PREMIUM_RATE;
} }
if (isNumberMatchingDesc(nationalNumber, metadata.tollFree)) {
if (isNumberMatchingDesc(nationalNumber, metadata.getTollFree())) {
return PhoneNumberType.TOLL_FREE; return PhoneNumberType.TOLL_FREE;
} }
if (isNumberMatchingDesc(nationalNumber, metadata.sharedCost)) {
if (isNumberMatchingDesc(nationalNumber, metadata.getSharedCost())) {
return PhoneNumberType.SHARED_COST; return PhoneNumberType.SHARED_COST;
} }
if (isNumberMatchingDesc(nationalNumber, metadata.voip)) {
if (isNumberMatchingDesc(nationalNumber, metadata.getVoip())) {
return PhoneNumberType.VOIP; return PhoneNumberType.VOIP;
} }
if (isNumberMatchingDesc(nationalNumber, metadata.personalNumber)) {
if (isNumberMatchingDesc(nationalNumber, metadata.getPersonalNumber())) {
return PhoneNumberType.PERSONAL_NUMBER; return PhoneNumberType.PERSONAL_NUMBER;
} }
if (isNumberMatchingDesc(nationalNumber, metadata.pager)) {
if (isNumberMatchingDesc(nationalNumber, metadata.getPager())) {
return PhoneNumberType.PAGER; return PhoneNumberType.PAGER;
} }
if (isNumberMatchingDesc(nationalNumber, metadata.uan)) {
if (isNumberMatchingDesc(nationalNumber, metadata.getUan())) {
return PhoneNumberType.UAN; return PhoneNumberType.UAN;
} }
if (isNumberMatchingDesc(nationalNumber, metadata.voicemail)) {
if (isNumberMatchingDesc(nationalNumber, metadata.getVoicemail())) {
return PhoneNumberType.VOICEMAIL; return PhoneNumberType.VOICEMAIL;
} }
boolean isFixedLine = isNumberMatchingDesc(nationalNumber, metadata.fixedLine);
boolean isFixedLine = isNumberMatchingDesc(nationalNumber, metadata.getFixedLine());
if (isFixedLine) { if (isFixedLine) {
if (metadata.sameMobileAndFixedLinePattern) {
if (metadata.isSameMobileAndFixedLinePattern()) {
return PhoneNumberType.FIXED_LINE_OR_MOBILE; return PhoneNumberType.FIXED_LINE_OR_MOBILE;
} else if (isNumberMatchingDesc(nationalNumber, metadata.mobile)) {
} else if (isNumberMatchingDesc(nationalNumber, metadata.getMobile())) {
return PhoneNumberType.FIXED_LINE_OR_MOBILE; return PhoneNumberType.FIXED_LINE_OR_MOBILE;
} }
return PhoneNumberType.FIXED_LINE; return PhoneNumberType.FIXED_LINE;
} }
// Otherwise, test to see if the number is mobile. Only do this if certain that the patterns for // Otherwise, test to see if the number is mobile. Only do this if certain that the patterns for
// mobile and fixed line aren't the same. // mobile and fixed line aren't the same.
if (!metadata.sameMobileAndFixedLinePattern &&
isNumberMatchingDesc(nationalNumber, metadata.mobile)) {
if (!metadata.isSameMobileAndFixedLinePattern() &&
isNumberMatchingDesc(nationalNumber, metadata.getMobile())) {
return PhoneNumberType.MOBILE; return PhoneNumberType.MOBILE;
} }
return PhoneNumberType.UNKNOWN; return PhoneNumberType.UNKNOWN;
@ -2131,14 +2115,14 @@ public class PhoneNumberUtil {
boolean isNumberPossibleForDesc(String nationalNumber, PhoneNumberDesc numberDesc) { boolean isNumberPossibleForDesc(String nationalNumber, PhoneNumberDesc numberDesc) {
Matcher possibleNumberPatternMatcher = Matcher possibleNumberPatternMatcher =
regexCache.getPatternForRegex(numberDesc.possibleNumberPattern)
regexCache.getPatternForRegex(numberDesc.getPossibleNumberPattern())
.matcher(nationalNumber); .matcher(nationalNumber);
return possibleNumberPatternMatcher.matches(); return possibleNumberPatternMatcher.matches();
} }
boolean isNumberMatchingDesc(String nationalNumber, PhoneNumberDesc numberDesc) { boolean isNumberMatchingDesc(String nationalNumber, PhoneNumberDesc numberDesc) {
Matcher nationalNumberPatternMatcher = Matcher nationalNumberPatternMatcher =
regexCache.getPatternForRegex(numberDesc.nationalNumberPattern)
regexCache.getPatternForRegex(numberDesc.getNationalNumberPattern())
.matcher(nationalNumber); .matcher(nationalNumber);
return isNumberPossibleForDesc(nationalNumber, numberDesc) && return isNumberPossibleForDesc(nationalNumber, numberDesc) &&
nationalNumberPatternMatcher.matches(); nationalNumberPatternMatcher.matches();
@ -2217,8 +2201,8 @@ public class PhoneNumberUtil {
// If leadingDigits is present, use this. Otherwise, do full validation. // If leadingDigits is present, use this. Otherwise, do full validation.
// Metadata cannot be null because the region codes come from the country calling code map. // Metadata cannot be null because the region codes come from the country calling code map.
PhoneMetadata metadata = getMetadataForRegion(regionCode); PhoneMetadata metadata = getMetadataForRegion(regionCode);
if (!metadata.leadingDigits.equals("")) {
if (regexCache.getPatternForRegex(metadata.leadingDigits)
if (metadata.hasLeadingDigits()) {
if (regexCache.getPatternForRegex(metadata.getLeadingDigits())
.matcher(nationalNumber).lookingAt()) { .matcher(nationalNumber).lookingAt()) {
return regionCode; return regionCode;
} }
@ -2284,7 +2268,7 @@ public class PhoneNumberUtil {
if (metadata == null) { if (metadata == null) {
throw new IllegalArgumentException("Invalid region code: " + regionCode); throw new IllegalArgumentException("Invalid region code: " + regionCode);
} }
return metadata.countryCode;
return metadata.getCountryCode();
} }
/** /**
@ -2310,7 +2294,7 @@ public class PhoneNumberUtil {
+ ") provided."); + ") provided.");
return null; return null;
} }
String nationalPrefix = metadata.nationalPrefix;
String nationalPrefix = metadata.getNationalPrefix();
// If no national prefix was found, we return null. // If no national prefix was found, we return null.
if (nationalPrefix.length() == 0) { if (nationalPrefix.length() == 0) {
return null; return null;
@ -2344,7 +2328,7 @@ public class PhoneNumberUtil {
if (mainMetadataForCallingCode == null) { if (mainMetadataForCallingCode == null) {
return false; return false;
} }
return mainMetadataForCallingCode.leadingZeroPossible;
return mainMetadataForCallingCode.isLeadingZeroPossible();
} }
/** /**
@ -2401,7 +2385,7 @@ public class PhoneNumberUtil {
*/ */
private boolean isShorterThanPossibleNormalNumber(PhoneMetadata regionMetadata, String number) { private boolean isShorterThanPossibleNormalNumber(PhoneMetadata regionMetadata, String number) {
Pattern possibleNumberPattern = regexCache.getPatternForRegex( Pattern possibleNumberPattern = regexCache.getPatternForRegex(
regionMetadata.generalDesc.possibleNumberPattern);
regionMetadata.getGeneralDesc().getPossibleNumberPattern());
return testNumberLengthAgainstPattern(possibleNumberPattern, number) == return testNumberLengthAgainstPattern(possibleNumberPattern, number) ==
ValidationResult.TOO_SHORT; ValidationResult.TOO_SHORT;
} }
@ -2441,7 +2425,7 @@ public class PhoneNumberUtil {
// Metadata cannot be null because the country calling code is valid. // Metadata cannot be null because the country calling code is valid.
PhoneMetadata metadata = getMetadataForRegionOrCallingCode(countryCode, regionCode); PhoneMetadata metadata = getMetadataForRegionOrCallingCode(countryCode, regionCode);
Pattern possibleNumberPattern = Pattern possibleNumberPattern =
regexCache.getPatternForRegex(metadata.generalDesc.possibleNumberPattern);
regexCache.getPatternForRegex(metadata.getGeneralDesc().getPossibleNumberPattern());
return testNumberLengthAgainstPattern(possibleNumberPattern, nationalNumber); return testNumberLengthAgainstPattern(possibleNumberPattern, nationalNumber);
} }
@ -2573,7 +2557,7 @@ public class PhoneNumberUtil {
// Set the default prefix to be something that will never match. // Set the default prefix to be something that will never match.
String possibleCountryIddPrefix = "NonMatch"; String possibleCountryIddPrefix = "NonMatch";
if (defaultRegionMetadata != null) { if (defaultRegionMetadata != null) {
possibleCountryIddPrefix = defaultRegionMetadata.internationalPrefix;
possibleCountryIddPrefix = defaultRegionMetadata.getInternationalPrefix();
} }
CountryCodeSource countryCodeSource = CountryCodeSource countryCodeSource =
@ -2601,19 +2585,19 @@ public class PhoneNumberUtil {
// Check to see if the number starts with the country calling code for the default region. If // Check to see if the number starts with the country calling code for the default region. If
// so, we remove the country calling code, and do some checks on the validity of the number // so, we remove the country calling code, and do some checks on the validity of the number
// before and after. // before and after.
int defaultCountryCode = defaultRegionMetadata.countryCode;
int defaultCountryCode = defaultRegionMetadata.getCountryCode();
String defaultCountryCodeString = String.valueOf(defaultCountryCode); String defaultCountryCodeString = String.valueOf(defaultCountryCode);
String normalizedNumber = fullNumber.toString(); String normalizedNumber = fullNumber.toString();
if (normalizedNumber.startsWith(defaultCountryCodeString)) { if (normalizedNumber.startsWith(defaultCountryCodeString)) {
StringBuilder potentialNationalNumber = StringBuilder potentialNationalNumber =
new StringBuilder(normalizedNumber.substring(defaultCountryCodeString.length())); new StringBuilder(normalizedNumber.substring(defaultCountryCodeString.length()));
PhoneNumberDesc generalDesc = defaultRegionMetadata.generalDesc;
PhoneNumberDesc generalDesc = defaultRegionMetadata.getGeneralDesc();
Pattern validNumberPattern = Pattern validNumberPattern =
regexCache.getPatternForRegex(generalDesc.nationalNumberPattern);
regexCache.getPatternForRegex(generalDesc.getNationalNumberPattern());
maybeStripNationalPrefixAndCarrierCode( maybeStripNationalPrefixAndCarrierCode(
potentialNationalNumber, defaultRegionMetadata, null /* Don't need the carrier code */); potentialNationalNumber, defaultRegionMetadata, null /* Don't need the carrier code */);
Pattern possibleNumberPattern = Pattern possibleNumberPattern =
regexCache.getPatternForRegex(generalDesc.possibleNumberPattern);
regexCache.getPatternForRegex(generalDesc.getPossibleNumberPattern());
// If the number was not valid before but is valid now, or if it was too long before, we // If the number was not valid before but is valid now, or if it was too long before, we
// consider the number with the country calling code stripped to be a better result and // consider the number with the country calling code stripped to be a better result and
// keep that instead. // keep that instead.
@ -2706,7 +2690,7 @@ public class PhoneNumberUtil {
boolean maybeStripNationalPrefixAndCarrierCode( boolean maybeStripNationalPrefixAndCarrierCode(
StringBuilder number, PhoneMetadata metadata, StringBuilder carrierCode) { StringBuilder number, PhoneMetadata metadata, StringBuilder carrierCode) {
int numberLength = number.length(); int numberLength = number.length();
String possibleNationalPrefix = metadata.nationalPrefixForParsing;
String possibleNationalPrefix = metadata.getNationalPrefixForParsing();
if (numberLength == 0 || possibleNationalPrefix.length() == 0) { if (numberLength == 0 || possibleNationalPrefix.length() == 0) {
// Early return for numbers of zero length. // Early return for numbers of zero length.
return false; return false;
@ -2715,14 +2699,14 @@ public class PhoneNumberUtil {
Matcher prefixMatcher = regexCache.getPatternForRegex(possibleNationalPrefix).matcher(number); Matcher prefixMatcher = regexCache.getPatternForRegex(possibleNationalPrefix).matcher(number);
if (prefixMatcher.lookingAt()) { if (prefixMatcher.lookingAt()) {
Pattern nationalNumberRule = Pattern nationalNumberRule =
regexCache.getPatternForRegex(metadata.generalDesc.nationalNumberPattern);
regexCache.getPatternForRegex(metadata.getGeneralDesc().getNationalNumberPattern());
// Check if the original number is viable. // Check if the original number is viable.
boolean isViableOriginalNumber = nationalNumberRule.matcher(number).matches(); boolean isViableOriginalNumber = nationalNumberRule.matcher(number).matches();
// prefixMatcher.group(numOfGroups) == null implies nothing was captured by the capturing // prefixMatcher.group(numOfGroups) == null implies nothing was captured by the capturing
// groups in possibleNationalPrefix; therefore, no transformation is necessary, and we just // groups in possibleNationalPrefix; therefore, no transformation is necessary, and we just
// remove the national prefix. // remove the national prefix.
int numOfGroups = prefixMatcher.groupCount(); int numOfGroups = prefixMatcher.groupCount();
String transformRule = metadata.nationalPrefixTransformRule;
String transformRule = metadata.getNationalPrefixTransformRule();
if (transformRule == null || transformRule.length() == 0 || if (transformRule == null || transformRule.length() == 0 ||
prefixMatcher.group(numOfGroups) == null) { prefixMatcher.group(numOfGroups) == null) {
// If the original number was viable, and the resultant number is not, we return. // If the original number was viable, and the resultant number is not, we return.
@ -3017,7 +3001,7 @@ public class PhoneNumberUtil {
normalize(nationalNumber); normalize(nationalNumber);
normalizedNationalNumber.append(nationalNumber); normalizedNationalNumber.append(nationalNumber);
if (defaultRegion != null) { if (defaultRegion != null) {
countryCode = regionMetadata.countryCode;
countryCode = regionMetadata.getCountryCode();
phoneNumber.setCountryCode(countryCode); phoneNumber.setCountryCode(countryCode);
} else if (keepRawInput) { } else if (keepRawInput) {
phoneNumber.clearCountryCodeSource(); phoneNumber.clearCountryCodeSource();
@ -3291,7 +3275,7 @@ public class PhoneNumberUtil {
return true; return true;
} }
String nationalSignificantNumber = getNationalSignificantNumber(number); String nationalSignificantNumber = getNationalSignificantNumber(number);
return !isNumberMatchingDesc(nationalSignificantNumber, metadata.noInternationalDialling);
return !isNumberMatchingDesc(nationalSignificantNumber, metadata.getNoInternationalDialling());
} }
/** /**
@ -3307,6 +3291,6 @@ public class PhoneNumberUtil {
logger.log(Level.WARNING, "Invalid or unknown region code provided: " + regionCode); logger.log(Level.WARNING, "Invalid or unknown region code provided: " + regionCode);
return false; return false;
} }
return metadata.mobileNumberPortableRegion;
return metadata.isMobileNumberPortableRegion();
} }
} }

+ 1119
- 0
java/libphonenumber/src/com/google/i18n/phonenumbers/Phonemetadata.java
File diff suppressed because it is too large
View File


+ 28
- 28
java/libphonenumber/src/com/google/i18n/phonenumbers/ShortNumberInfo.java View File

@ -16,11 +16,11 @@
package com.google.i18n.phonenumbers; package com.google.i18n.phonenumbers;
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
import com.google.i18n.phonenumbers.internal.MatcherApi; import com.google.i18n.phonenumbers.internal.MatcherApi;
import com.google.i18n.phonenumbers.internal.RegexBasedMatcher; import com.google.i18n.phonenumbers.internal.RegexBasedMatcher;
import com.google.i18n.phonenumbers.nano.Phonemetadata.PhoneMetadata;
import com.google.i18n.phonenumbers.nano.Phonemetadata.PhoneNumberDesc;
import com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata;
import com.google.i18n.phonenumbers.Phonemetadata.PhoneNumberDesc;
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -130,7 +130,7 @@ public class ShortNumberInfo {
if (phoneMetadata == null) { if (phoneMetadata == null) {
return false; return false;
} }
return matcherApi.matchesPossibleNumber(shortNumber, phoneMetadata.generalDesc);
return matcherApi.matchesPossibleNumber(shortNumber, phoneMetadata.getGeneralDesc());
} }
/** /**
@ -151,7 +151,7 @@ public class ShortNumberInfo {
return false; return false;
} }
return matcherApi.matchesPossibleNumber(getNationalSignificantNumber(number), return matcherApi.matchesPossibleNumber(getNationalSignificantNumber(number),
phoneMetadata.generalDesc);
phoneMetadata.getGeneralDesc());
} }
/** /**
@ -171,7 +171,7 @@ public class ShortNumberInfo {
if (phoneMetadata == null) { if (phoneMetadata == null) {
continue; continue;
} }
if (matcherApi.matchesPossibleNumber(shortNumber, phoneMetadata.generalDesc)) {
if (matcherApi.matchesPossibleNumber(shortNumber, phoneMetadata.getGeneralDesc())) {
return true; return true;
} }
} }
@ -199,11 +199,11 @@ public class ShortNumberInfo {
if (phoneMetadata == null) { if (phoneMetadata == null) {
return false; return false;
} }
PhoneNumberDesc generalDesc = phoneMetadata.generalDesc;
PhoneNumberDesc generalDesc = phoneMetadata.getGeneralDesc();
if (!matchesPossibleNumberAndNationalNumber(shortNumber, generalDesc)) { if (!matchesPossibleNumberAndNationalNumber(shortNumber, generalDesc)) {
return false; return false;
} }
PhoneNumberDesc shortNumberDesc = phoneMetadata.shortCode;
PhoneNumberDesc shortNumberDesc = phoneMetadata.getShortCode();
return matchesPossibleNumberAndNationalNumber(shortNumber, shortNumberDesc); return matchesPossibleNumberAndNationalNumber(shortNumber, shortNumberDesc);
} }
@ -226,11 +226,11 @@ public class ShortNumberInfo {
return false; return false;
} }
String shortNumber = getNationalSignificantNumber(number); String shortNumber = getNationalSignificantNumber(number);
PhoneNumberDesc generalDesc = phoneMetadata.generalDesc;
PhoneNumberDesc generalDesc = phoneMetadata.getGeneralDesc();
if (!matchesPossibleNumberAndNationalNumber(shortNumber, generalDesc)) { if (!matchesPossibleNumberAndNationalNumber(shortNumber, generalDesc)) {
return false; return false;
} }
PhoneNumberDesc shortNumberDesc = phoneMetadata.shortCode;
PhoneNumberDesc shortNumberDesc = phoneMetadata.getShortCode();
return matchesPossibleNumberAndNationalNumber(shortNumber, shortNumberDesc); return matchesPossibleNumberAndNationalNumber(shortNumber, shortNumberDesc);
} }
@ -292,13 +292,13 @@ public class ShortNumberInfo {
// The cost categories are tested in order of decreasing expense, since if for some reason the // The cost categories are tested in order of decreasing expense, since if for some reason the
// patterns overlap the most expensive matching cost category should be returned. // patterns overlap the most expensive matching cost category should be returned.
if (matchesPossibleNumberAndNationalNumber(shortNumber, phoneMetadata.premiumRate)) {
if (matchesPossibleNumberAndNationalNumber(shortNumber, phoneMetadata.getPremiumRate())) {
return ShortNumberCost.PREMIUM_RATE; return ShortNumberCost.PREMIUM_RATE;
} }
if (matchesPossibleNumberAndNationalNumber(shortNumber, phoneMetadata.standardRate)) {
if (matchesPossibleNumberAndNationalNumber(shortNumber, phoneMetadata.getStandardRate())) {
return ShortNumberCost.STANDARD_RATE; return ShortNumberCost.STANDARD_RATE;
} }
if (matchesPossibleNumberAndNationalNumber(shortNumber, phoneMetadata.tollFree)) {
if (matchesPossibleNumberAndNationalNumber(shortNumber, phoneMetadata.getTollFree())) {
return ShortNumberCost.TOLL_FREE; return ShortNumberCost.TOLL_FREE;
} }
if (isEmergencyNumber(shortNumber, regionDialingFrom)) { if (isEmergencyNumber(shortNumber, regionDialingFrom)) {
@ -346,13 +346,13 @@ public class ShortNumberInfo {
// The cost categories are tested in order of decreasing expense, since if for some reason the // The cost categories are tested in order of decreasing expense, since if for some reason the
// patterns overlap the most expensive matching cost category should be returned. // patterns overlap the most expensive matching cost category should be returned.
if (matchesPossibleNumberAndNationalNumber(shortNumber, phoneMetadata.premiumRate)) {
if (matchesPossibleNumberAndNationalNumber(shortNumber, phoneMetadata.getPremiumRate())) {
return ShortNumberCost.PREMIUM_RATE; return ShortNumberCost.PREMIUM_RATE;
} }
if (matchesPossibleNumberAndNationalNumber(shortNumber, phoneMetadata.standardRate)) {
if (matchesPossibleNumberAndNationalNumber(shortNumber, phoneMetadata.getStandardRate())) {
return ShortNumberCost.STANDARD_RATE; return ShortNumberCost.STANDARD_RATE;
} }
if (matchesPossibleNumberAndNationalNumber(shortNumber, phoneMetadata.tollFree)) {
if (matchesPossibleNumberAndNationalNumber(shortNumber, phoneMetadata.getTollFree())) {
return ShortNumberCost.TOLL_FREE; return ShortNumberCost.TOLL_FREE;
} }
if (isEmergencyNumber(shortNumber, regionDialingFrom)) { if (isEmergencyNumber(shortNumber, regionDialingFrom)) {
@ -429,7 +429,7 @@ public class ShortNumberInfo {
for (String regionCode : regionCodes) { for (String regionCode : regionCodes) {
PhoneMetadata phoneMetadata = MetadataManager.getShortNumberMetadataForRegion(regionCode); PhoneMetadata phoneMetadata = MetadataManager.getShortNumberMetadataForRegion(regionCode);
if (phoneMetadata != null if (phoneMetadata != null
&& matchesPossibleNumberAndNationalNumber(nationalNumber, phoneMetadata.shortCode)) {
&& matchesPossibleNumberAndNationalNumber(nationalNumber, phoneMetadata.getShortCode())) {
// The number is valid for this region. // The number is valid for this region.
return regionCode; return regionCode;
} }
@ -457,9 +457,9 @@ public class ShortNumberInfo {
if (phoneMetadata == null) { if (phoneMetadata == null) {
return ""; return "";
} }
PhoneNumberDesc desc = phoneMetadata.shortCode;
if (!desc.exampleNumber.equals("")) {
return desc.exampleNumber;
PhoneNumberDesc desc = phoneMetadata.getShortCode();
if (desc.hasExampleNumber()) {
return desc.getExampleNumber();
} }
return ""; return "";
} }
@ -481,20 +481,20 @@ public class ShortNumberInfo {
PhoneNumberDesc desc = null; PhoneNumberDesc desc = null;
switch (cost) { switch (cost) {
case TOLL_FREE: case TOLL_FREE:
desc = phoneMetadata.tollFree;
desc = phoneMetadata.getTollFree();
break; break;
case STANDARD_RATE: case STANDARD_RATE:
desc = phoneMetadata.standardRate;
desc = phoneMetadata.getStandardRate();
break; break;
case PREMIUM_RATE: case PREMIUM_RATE:
desc = phoneMetadata.premiumRate;
desc = phoneMetadata.getPremiumRate();
break; break;
default: default:
// UNKNOWN_COST numbers are computed by the process of elimination from the other cost // UNKNOWN_COST numbers are computed by the process of elimination from the other cost
// categories. // categories.
} }
if (desc != null && !desc.exampleNumber.equals("")) {
return desc.exampleNumber;
if (desc != null && desc.hasExampleNumber()) {
return desc.getExampleNumber();
} }
return ""; return "";
} }
@ -543,12 +543,12 @@ public class ShortNumberInfo {
return false; return false;
} }
PhoneMetadata metadata = MetadataManager.getShortNumberMetadataForRegion(regionCode); PhoneMetadata metadata = MetadataManager.getShortNumberMetadataForRegion(regionCode);
if (metadata == null || metadata.emergency == null) {
if (metadata == null || !metadata.hasEmergency()) {
return false; return false;
} }
String normalizedNumber = PhoneNumberUtil.normalizeDigitsOnly(number); String normalizedNumber = PhoneNumberUtil.normalizeDigitsOnly(number);
PhoneNumberDesc emergencyDesc = metadata.emergency;
PhoneNumberDesc emergencyDesc = metadata.getEmergency();
boolean allowPrefixMatchForRegion = boolean allowPrefixMatchForRegion =
allowPrefixMatch && !REGIONS_WHERE_EMERGENCY_NUMBERS_MUST_BE_EXACT.contains(regionCode); allowPrefixMatch && !REGIONS_WHERE_EMERGENCY_NUMBERS_MUST_BE_EXACT.contains(regionCode);
return matcherApi.matchesNationalNumber(normalizedNumber, emergencyDesc, return matcherApi.matchesNationalNumber(normalizedNumber, emergencyDesc,
@ -572,7 +572,7 @@ public class ShortNumberInfo {
PhoneMetadata phoneMetadata = MetadataManager.getShortNumberMetadataForRegion(regionCode); PhoneMetadata phoneMetadata = MetadataManager.getShortNumberMetadataForRegion(regionCode);
return (phoneMetadata != null) return (phoneMetadata != null)
&& (matchesPossibleNumberAndNationalNumber(nationalNumber, && (matchesPossibleNumberAndNationalNumber(nationalNumber,
phoneMetadata.carrierSpecific));
phoneMetadata.getCarrierSpecific()));
} }
/** /**


+ 8
- 9
java/libphonenumber/src/com/google/i18n/phonenumbers/SingleFileMetadataSourceImpl.java View File

@ -16,8 +16,8 @@
package com.google.i18n.phonenumbers; package com.google.i18n.phonenumbers;
import com.google.i18n.phonenumbers.nano.Phonemetadata.PhoneMetadata;
import com.google.i18n.phonenumbers.nano.Phonemetadata.PhoneMetadataCollection;
import com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata;
import com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadataCollection;
import java.io.InputStream; import java.io.InputStream;
import java.util.Collections; import java.util.Collections;
@ -101,16 +101,15 @@ final class SingleFileMetadataSourceImpl implements MetadataSource {
// loading depending on what data is available in the jar. // loading depending on what data is available in the jar.
throw new IllegalStateException("missing metadata: " + fileName); throw new IllegalStateException("missing metadata: " + fileName);
} }
PhoneMetadataCollection metadataCollection =
MetadataManager.loadMetadataAndCloseInput(source, MetadataManager.ALL_REGIONS_BUFFER_SIZE);
PhoneMetadata[] metadatas = metadataCollection.metadata;
if (metadatas.length == 0) {
PhoneMetadataCollection metadataCollection = MetadataManager.loadMetadataAndCloseInput(source);
List<PhoneMetadata> metadataList = metadataCollection.getMetadataList();
if (metadataList.isEmpty()) {
// This should not happen since clients shouldn't be using this implementation! // This should not happen since clients shouldn't be using this implementation!
throw new IllegalStateException("empty metadata: " + fileName); throw new IllegalStateException("empty metadata: " + fileName);
} }
for (PhoneMetadata metadata : metadatas) {
String regionCode = metadata.id;
int countryCallingCode = metadata.countryCode;
for (PhoneMetadata metadata : metadataList) {
String regionCode = metadata.getId();
int countryCallingCode = metadata.getCountryCode();
boolean isNonGeoRegion = PhoneNumberUtil.REGION_CODE_FOR_NON_GEO_ENTITY.equals(regionCode); boolean isNonGeoRegion = PhoneNumberUtil.REGION_CODE_FOR_NON_GEO_ENTITY.equals(regionCode);
if (isNonGeoRegion) { if (isNonGeoRegion) {
countryCodeToNonGeographicalMetadataMap.put(countryCallingCode, metadata); countryCodeToNonGeographicalMetadataMap.put(countryCallingCode, metadata);


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_255 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_27 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_30 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_31 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_34 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_350 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_351 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_352 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_358 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_359 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_36 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_372 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_373 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_380 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_381 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_385 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_43 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_44 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_49 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_505 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_506 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_54 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_55 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_58 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_595 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_61 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_62 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_63 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_66 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_675 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_676 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_679 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_7 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_81 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_84 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_855 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_90 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_91 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_94 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_95 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_971 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_972 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberAlternateFormatsProto_995 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_800 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_808 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_870 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_878 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_881 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_882 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_883 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_888 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_979 View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AC View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AD View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AE View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AF View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AG View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AI View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AL View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AM View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AO View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AR View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AS View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AT View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AU View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AW View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AX View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AZ View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BA View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BB View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BD View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BE View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BF View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BG View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BH View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BI View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BJ View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BL View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BM View File


BIN
java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BN View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save