Commits

jia....@ee073f10-1060-11df-b6a4-87a95322a99c  committed 8729a64

switch the library to use protobuf lite instead of the full version.

  • Participants
  • Parent commits 9a67ec5
  • Branches default

Comments (0)

Files changed (8)

File java/lib/protobuf-java-2.3.0-lite.jar

Binary file added.

File java/lib/protobuf-java-2.3.0.jar

Binary file removed.

File java/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java

 import com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadataCollection;
 import com.google.i18n.phonenumbers.Phonemetadata.PhoneNumberDesc;
 import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
+import com.google.protobuf.MessageLite;
 
 import java.io.InputStream;
 import java.io.IOException;
+import java.io.OutputStream;
+import java.io.ByteArrayOutputStream;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
   }
 
   /**
+   * As no equals method is implemented for MessageLite, we implement our own equals method here
+   * to compare the serialized data.
+   */ 
+  @VisibleForTesting
+  static Boolean areSameMessages(MessageLite message1, MessageLite message2) {
+    if (message1 == null && message2 == null) {
+      return true;
+    }
+    if (message1 == null || message2 == null) {
+      return false;
+    }
+    OutputStream output1 = new ByteArrayOutputStream();
+    OutputStream output2 = new ByteArrayOutputStream();
+    try {
+      message1.writeTo(output1);
+      message2.writeTo(output2);
+    } catch (IOException e) {
+      LOGGER.log(Level.WARNING, e.toString());
+    }
+
+    return output1.toString().equals(output2.toString());
+  }
+
+
+  /**
    * Parses a string and returns it in proto buffer format. This method is the same as the public
    * parse() method, with the exception that it  allows the default country to be null, for use by
    * isNumberMatch().
     int secondNumberCountryCode = number2.getCountryCode();
     // Both had country code specified.
     if (firstNumberCountryCode != 0 && secondNumberCountryCode != 0) {
-      if (number1.equals(number2)) {
+      if (areSameMessages(number1, number2)) {
         return MatchType.EXACT_MATCH;
       } else if (firstNumberCountryCode == secondNumberCountryCode) {
         // A SHORT_NSN_MATCH occurs if there is a difference because of the presence or absence of
     PhoneNumber newNumber =
         PhoneNumber.newBuilder(number1).setCountryCode(secondNumberCountryCode).build();
     // If all else was the same, then this is an NSN_MATCH.
-    if (newNumber.equals(number2)) {
+    if (areSameMessages(newNumber, number2)) {
       return MatchType.NSN_MATCH;
     }
     String firstNumberNationalNumber = String.valueOf(newNumber.getNationalNumber());

File java/src/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java

 import com.google.i18n.phonenumbers.Phonemetadata.NumberFormat;
 import com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata;
 import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
+import com.google.protobuf.MessageLite;
 import junit.framework.TestCase;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
     super.tearDown();
   }
 
-  public void testGetInstanceLoadUSMetadata() {
+  private Boolean assertEquals(MessageLite message1, MessageLite message2) {
+    return PhoneNumberUtil.areSameMessages(message1, message2);
+  }
+
+  public void testGetInstanceLoadUSMetadata() throws IOException {
     PhoneMetadata metadata = phoneUtil.getPhoneMetadata("US");
     assertEquals("US", metadata.getId());
     assertEquals(1, metadata.getCountryCode());
     assertEquals("$1 $2 $3 $4", metadata.getIntlNumberFormat(3).getFormat());
   }
 
-  public void testGetExampleNumber() {
+  public void testGetExampleNumber() throws IOException {
     PhoneNumber deNumber =
         PhoneNumber.newBuilder().setCountryCode(49).setNationalNumber(30123456).build();
     assertEquals(deNumber, phoneUtil.getExampleNumber("DE"));
   public void testIsNumberMatchMatches() throws Exception {
     // Test simple matches where formatting is different, or leading zeroes, or country code has
     // been specified.
+    PhoneNumber num1 = phoneUtil.parse("+64 3 331 6005", "NZ");
+    PhoneNumber num2 = phoneUtil.parse("+64 03 331 6005", "NZ");
+    assertEquals(PhoneNumberUtil.MatchType.EXACT_MATCH,
+                 phoneUtil.isNumberMatch(num1, num2));
     assertEquals(PhoneNumberUtil.MatchType.EXACT_MATCH,
                  phoneUtil.isNumberMatch("+64 3 331 6005", "+64 03 331 6005"));
     assertEquals(PhoneNumberUtil.MatchType.EXACT_MATCH,

File java/src/com/google/i18n/phonenumbers/Phonemetadata.java

 public final class Phonemetadata {
   private Phonemetadata() {}
   public static void registerAllExtensions(
-      com.google.protobuf.ExtensionRegistry registry) {
+      com.google.protobuf.ExtensionRegistryLite registry) {
   }
   public static final class NumberFormat extends
-      com.google.protobuf.GeneratedMessage {
+      com.google.protobuf.GeneratedMessageLite {
     // Use NumberFormat.newBuilder() to construct.
     private NumberFormat() {
       initFields();
       return defaultInstance;
     }
     
-    public static final com.google.protobuf.Descriptors.Descriptor
-        getDescriptor() {
-      return com.google.i18n.phonenumbers.Phonemetadata.internal_static_i18n_phonenumbers_NumberFormat_descriptor;
-    }
-    
-    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
-        internalGetFieldAccessorTable() {
-      return com.google.i18n.phonenumbers.Phonemetadata.internal_static_i18n_phonenumbers_NumberFormat_fieldAccessorTable;
-    }
-    
     // required string pattern = 1;
     public static final int PATTERN_FIELD_NUMBER = 1;
     private boolean hasPattern;
       if (hasNationalPrefixFormattingRule()) {
         output.writeString(4, getNationalPrefixFormattingRule());
       }
-      getUnknownFields().writeTo(output);
     }
     
     private int memoizedSerializedSize = -1;
         size += com.google.protobuf.CodedOutputStream
           .computeStringSize(4, getNationalPrefixFormattingRule());
       }
-      size += getUnknownFields().getSerializedSize();
       memoizedSerializedSize = size;
       return size;
     }
     public Builder toBuilder() { return newBuilder(this); }
     
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessage.Builder<Builder> {
+        com.google.protobuf.GeneratedMessageLite.Builder<
+          com.google.i18n.phonenumbers.Phonemetadata.NumberFormat, Builder> {
       private com.google.i18n.phonenumbers.Phonemetadata.NumberFormat result;
       
       // Construct using com.google.i18n.phonenumbers.Phonemetadata.NumberFormat.newBuilder()
         return create().mergeFrom(result);
       }
       
-      public com.google.protobuf.Descriptors.Descriptor
-          getDescriptorForType() {
-        return com.google.i18n.phonenumbers.Phonemetadata.NumberFormat.getDescriptor();
-      }
-      
       public com.google.i18n.phonenumbers.Phonemetadata.NumberFormat getDefaultInstanceForType() {
         return com.google.i18n.phonenumbers.Phonemetadata.NumberFormat.getDefaultInstance();
       }
         return returnMe;
       }
       
-      public Builder mergeFrom(com.google.protobuf.Message other) {
-        if (other instanceof com.google.i18n.phonenumbers.Phonemetadata.NumberFormat) {
-          return mergeFrom((com.google.i18n.phonenumbers.Phonemetadata.NumberFormat)other);
-        } else {
-          super.mergeFrom(other);
-          return this;
-        }
-      }
-      
       public Builder mergeFrom(com.google.i18n.phonenumbers.Phonemetadata.NumberFormat other) {
         if (other == com.google.i18n.phonenumbers.Phonemetadata.NumberFormat.getDefaultInstance()) return this;
         if (other.hasPattern()) {
         if (other.hasNationalPrefixFormattingRule()) {
           setNationalPrefixFormattingRule(other.getNationalPrefixFormattingRule());
         }
-        this.mergeUnknownFields(other.getUnknownFields());
         return this;
       }
       
           com.google.protobuf.CodedInputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        com.google.protobuf.UnknownFieldSet.Builder unknownFields =
-          com.google.protobuf.UnknownFieldSet.newBuilder(
-            this.getUnknownFields());
         while (true) {
           int tag = input.readTag();
           switch (tag) {
             case 0:
-              this.setUnknownFields(unknownFields.build());
               return this;
             default: {
-              if (!parseUnknownField(input, unknownFields,
-                                     extensionRegistry, tag)) {
-                this.setUnknownFields(unknownFields.build());
+              if (!parseUnknownField(input, extensionRegistry, tag)) {
                 return this;
               }
               break;
   }
   
   public static final class PhoneNumberDesc extends
-      com.google.protobuf.GeneratedMessage {
+      com.google.protobuf.GeneratedMessageLite {
     // Use PhoneNumberDesc.newBuilder() to construct.
     private PhoneNumberDesc() {
       initFields();
       return defaultInstance;
     }
     
-    public static final com.google.protobuf.Descriptors.Descriptor
-        getDescriptor() {
-      return com.google.i18n.phonenumbers.Phonemetadata.internal_static_i18n_phonenumbers_PhoneNumberDesc_descriptor;
-    }
-    
-    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
-        internalGetFieldAccessorTable() {
-      return com.google.i18n.phonenumbers.Phonemetadata.internal_static_i18n_phonenumbers_PhoneNumberDesc_fieldAccessorTable;
-    }
-    
     // optional string national_number_pattern = 2;
     public static final int NATIONAL_NUMBER_PATTERN_FIELD_NUMBER = 2;
     private boolean hasNationalNumberPattern;
       if (hasExampleNumber()) {
         output.writeString(6, getExampleNumber());
       }
-      getUnknownFields().writeTo(output);
     }
     
     private int memoizedSerializedSize = -1;
         size += com.google.protobuf.CodedOutputStream
           .computeStringSize(6, getExampleNumber());
       }
-      size += getUnknownFields().getSerializedSize();
       memoizedSerializedSize = size;
       return size;
     }
     public Builder toBuilder() { return newBuilder(this); }
     
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessage.Builder<Builder> {
+        com.google.protobuf.GeneratedMessageLite.Builder<
+          com.google.i18n.phonenumbers.Phonemetadata.PhoneNumberDesc, Builder> {
       private com.google.i18n.phonenumbers.Phonemetadata.PhoneNumberDesc result;
       
       // Construct using com.google.i18n.phonenumbers.Phonemetadata.PhoneNumberDesc.newBuilder()
         return create().mergeFrom(result);
       }
       
-      public com.google.protobuf.Descriptors.Descriptor
-          getDescriptorForType() {
-        return com.google.i18n.phonenumbers.Phonemetadata.PhoneNumberDesc.getDescriptor();
-      }
-      
       public com.google.i18n.phonenumbers.Phonemetadata.PhoneNumberDesc getDefaultInstanceForType() {
         return com.google.i18n.phonenumbers.Phonemetadata.PhoneNumberDesc.getDefaultInstance();
       }
         return returnMe;
       }
       
-      public Builder mergeFrom(com.google.protobuf.Message other) {
-        if (other instanceof com.google.i18n.phonenumbers.Phonemetadata.PhoneNumberDesc) {
-          return mergeFrom((com.google.i18n.phonenumbers.Phonemetadata.PhoneNumberDesc)other);
-        } else {
-          super.mergeFrom(other);
-          return this;
-        }
-      }
-      
       public Builder mergeFrom(com.google.i18n.phonenumbers.Phonemetadata.PhoneNumberDesc other) {
         if (other == com.google.i18n.phonenumbers.Phonemetadata.PhoneNumberDesc.getDefaultInstance()) return this;
         if (other.hasNationalNumberPattern()) {
         if (other.hasExampleNumber()) {
           setExampleNumber(other.getExampleNumber());
         }
-        this.mergeUnknownFields(other.getUnknownFields());
         return this;
       }
       
           com.google.protobuf.CodedInputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        com.google.protobuf.UnknownFieldSet.Builder unknownFields =
-          com.google.protobuf.UnknownFieldSet.newBuilder(
-            this.getUnknownFields());
         while (true) {
           int tag = input.readTag();
           switch (tag) {
             case 0:
-              this.setUnknownFields(unknownFields.build());
               return this;
             default: {
-              if (!parseUnknownField(input, unknownFields,
-                                     extensionRegistry, tag)) {
-                this.setUnknownFields(unknownFields.build());
+              if (!parseUnknownField(input, extensionRegistry, tag)) {
                 return this;
               }
               break;
   }
   
   public static final class PhoneMetadata extends
-      com.google.protobuf.GeneratedMessage {
+      com.google.protobuf.GeneratedMessageLite {
     // Use PhoneMetadata.newBuilder() to construct.
     private PhoneMetadata() {
       initFields();
       return defaultInstance;
     }
     
-    public static final com.google.protobuf.Descriptors.Descriptor
-        getDescriptor() {
-      return com.google.i18n.phonenumbers.Phonemetadata.internal_static_i18n_phonenumbers_PhoneMetadata_descriptor;
-    }
-    
-    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
-        internalGetFieldAccessorTable() {
-      return com.google.i18n.phonenumbers.Phonemetadata.internal_static_i18n_phonenumbers_PhoneMetadata_fieldAccessorTable;
-    }
-    
     // required .i18n.phonenumbers.PhoneNumberDesc general_desc = 1;
     public static final int GENERAL_DESC_FIELD_NUMBER = 1;
     private boolean hasGeneralDesc;
       if (hasNationalPrefixFormattingRule()) {
         output.writeString(21, getNationalPrefixFormattingRule());
       }
-      getUnknownFields().writeTo(output);
     }
     
     private int memoizedSerializedSize = -1;
         size += com.google.protobuf.CodedOutputStream
           .computeStringSize(21, getNationalPrefixFormattingRule());
       }
-      size += getUnknownFields().getSerializedSize();
       memoizedSerializedSize = size;
       return size;
     }
     public Builder toBuilder() { return newBuilder(this); }
     
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessage.Builder<Builder> {
+        com.google.protobuf.GeneratedMessageLite.Builder<
+          com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata, Builder> {
       private com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata result;
       
       // Construct using com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata.newBuilder()
         return create().mergeFrom(result);
       }
       
-      public com.google.protobuf.Descriptors.Descriptor
-          getDescriptorForType() {
-        return com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata.getDescriptor();
-      }
-      
       public com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata getDefaultInstanceForType() {
         return com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata.getDefaultInstance();
       }
         return returnMe;
       }
       
-      public Builder mergeFrom(com.google.protobuf.Message other) {
-        if (other instanceof com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata) {
-          return mergeFrom((com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata)other);
-        } else {
-          super.mergeFrom(other);
-          return this;
-        }
-      }
-      
       public Builder mergeFrom(com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata other) {
         if (other == com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata.getDefaultInstance()) return this;
         if (other.hasGeneralDesc()) {
         if (other.hasNationalPrefixFormattingRule()) {
           setNationalPrefixFormattingRule(other.getNationalPrefixFormattingRule());
         }
-        this.mergeUnknownFields(other.getUnknownFields());
         return this;
       }
       
           com.google.protobuf.CodedInputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        com.google.protobuf.UnknownFieldSet.Builder unknownFields =
-          com.google.protobuf.UnknownFieldSet.newBuilder(
-            this.getUnknownFields());
         while (true) {
           int tag = input.readTag();
           switch (tag) {
             case 0:
-              this.setUnknownFields(unknownFields.build());
               return this;
             default: {
-              if (!parseUnknownField(input, unknownFields,
-                                     extensionRegistry, tag)) {
-                this.setUnknownFields(unknownFields.build());
+              if (!parseUnknownField(input, extensionRegistry, tag)) {
                 return this;
               }
               break;
   }
   
   public static final class PhoneMetadataCollection extends
-      com.google.protobuf.GeneratedMessage {
+      com.google.protobuf.GeneratedMessageLite {
     // Use PhoneMetadataCollection.newBuilder() to construct.
     private PhoneMetadataCollection() {
       initFields();
       return defaultInstance;
     }
     
-    public static final com.google.protobuf.Descriptors.Descriptor
-        getDescriptor() {
-      return com.google.i18n.phonenumbers.Phonemetadata.internal_static_i18n_phonenumbers_PhoneMetadataCollection_descriptor;
-    }
-    
-    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
-        internalGetFieldAccessorTable() {
-      return com.google.i18n.phonenumbers.Phonemetadata.internal_static_i18n_phonenumbers_PhoneMetadataCollection_fieldAccessorTable;
-    }
-    
     // repeated .i18n.phonenumbers.PhoneMetadata metadata = 1;
     public static final int METADATA_FIELD_NUMBER = 1;
     private java.util.List<com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata> metadata_ =
       for (com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata element : getMetadataList()) {
         output.writeMessage(1, element);
       }
-      getUnknownFields().writeTo(output);
     }
     
     private int memoizedSerializedSize = -1;
         size += com.google.protobuf.CodedOutputStream
           .computeMessageSize(1, element);
       }
-      size += getUnknownFields().getSerializedSize();
       memoizedSerializedSize = size;
       return size;
     }
     public Builder toBuilder() { return newBuilder(this); }
     
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessage.Builder<Builder> {
+        com.google.protobuf.GeneratedMessageLite.Builder<
+          com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadataCollection, Builder> {
       private com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadataCollection result;
       
       // Construct using com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadataCollection.newBuilder()
         return create().mergeFrom(result);
       }
       
-      public com.google.protobuf.Descriptors.Descriptor
-          getDescriptorForType() {
-        return com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadataCollection.getDescriptor();
-      }
-      
       public com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadataCollection getDefaultInstanceForType() {
         return com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadataCollection.getDefaultInstance();
       }
         return returnMe;
       }
       
-      public Builder mergeFrom(com.google.protobuf.Message other) {
-        if (other instanceof com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadataCollection) {
-          return mergeFrom((com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadataCollection)other);
-        } else {
-          super.mergeFrom(other);
-          return this;
-        }
-      }
-      
       public Builder mergeFrom(com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadataCollection other) {
         if (other == com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadataCollection.getDefaultInstance()) return this;
         if (!other.metadata_.isEmpty()) {
           }
           result.metadata_.addAll(other.metadata_);
         }
-        this.mergeUnknownFields(other.getUnknownFields());
         return this;
       }
       
           com.google.protobuf.CodedInputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        com.google.protobuf.UnknownFieldSet.Builder unknownFields =
-          com.google.protobuf.UnknownFieldSet.newBuilder(
-            this.getUnknownFields());
         while (true) {
           int tag = input.readTag();
           switch (tag) {
             case 0:
-              this.setUnknownFields(unknownFields.build());
               return this;
             default: {
-              if (!parseUnknownField(input, unknownFields,
-                                     extensionRegistry, tag)) {
-                this.setUnknownFields(unknownFields.build());
+              if (!parseUnknownField(input, extensionRegistry, tag)) {
                 return this;
               }
               break;
     // @@protoc_insertion_point(class_scope:i18n.phonenumbers.PhoneMetadataCollection)
   }
   
-  private static com.google.protobuf.Descriptors.Descriptor
-    internal_static_i18n_phonenumbers_NumberFormat_descriptor;
-  private static
-    com.google.protobuf.GeneratedMessage.FieldAccessorTable
-      internal_static_i18n_phonenumbers_NumberFormat_fieldAccessorTable;
-  private static com.google.protobuf.Descriptors.Descriptor
-    internal_static_i18n_phonenumbers_PhoneNumberDesc_descriptor;
-  private static
-    com.google.protobuf.GeneratedMessage.FieldAccessorTable
-      internal_static_i18n_phonenumbers_PhoneNumberDesc_fieldAccessorTable;
-  private static com.google.protobuf.Descriptors.Descriptor
-    internal_static_i18n_phonenumbers_PhoneMetadata_descriptor;
-  private static
-    com.google.protobuf.GeneratedMessage.FieldAccessorTable
-      internal_static_i18n_phonenumbers_PhoneMetadata_fieldAccessorTable;
-  private static com.google.protobuf.Descriptors.Descriptor
-    internal_static_i18n_phonenumbers_PhoneMetadataCollection_descriptor;
-  private static
-    com.google.protobuf.GeneratedMessage.FieldAccessorTable
-      internal_static_i18n_phonenumbers_PhoneMetadataCollection_fieldAccessorTable;
   
-  public static com.google.protobuf.Descriptors.FileDescriptor
-      getDescriptor() {
-    return descriptor;
-  }
-  private static com.google.protobuf.Descriptors.FileDescriptor
-      descriptor;
   static {
-    java.lang.String[] descriptorData = {
-      "\n\023phonemetadata.proto\022\021i18n.phonenumbers" +
-      "\"p\n\014NumberFormat\022\017\n\007pattern\030\001 \002(\t\022\016\n\006for" +
-      "mat\030\002 \002(\t\022\026\n\016leading_digits\030\003 \001(\t\022\'\n\037nat" +
-      "ional_prefix_formatting_rule\030\004 \001(\t\"k\n\017Ph" +
-      "oneNumberDesc\022\037\n\027national_number_pattern" +
-      "\030\002 \001(\t\022\037\n\027possible_number_pattern\030\003 \001(\t\022" +
-      "\026\n\016example_number\030\006 \001(\t\"\214\007\n\rPhoneMetadat" +
-      "a\0228\n\014general_desc\030\001 \002(\0132\".i18n.phonenumb" +
-      "ers.PhoneNumberDesc\0226\n\nfixed_line\030\002 \002(\0132" +
-      "\".i18n.phonenumbers.PhoneNumberDesc\0222\n\006m",
-      "obile\030\003 \002(\0132\".i18n.phonenumbers.PhoneNum" +
-      "berDesc\0225\n\ttoll_free\030\004 \002(\0132\".i18n.phonen" +
-      "umbers.PhoneNumberDesc\0228\n\014premium_rate\030\005" +
-      " \002(\0132\".i18n.phonenumbers.PhoneNumberDesc" +
-      "\0227\n\013shared_cost\030\006 \002(\0132\".i18n.phonenumber" +
-      "s.PhoneNumberDesc\022;\n\017personal_number\030\007 \002" +
-      "(\0132\".i18n.phonenumbers.PhoneNumberDesc\0220" +
-      "\n\004voip\030\010 \002(\0132\".i18n.phonenumbers.PhoneNu" +
-      "mberDesc\022\n\n\002id\030\t \002(\t\022\024\n\014country_code\030\n \002" +
-      "(\005\022\034\n\024international_prefix\030\013 \002(\t\022&\n\036pref",
-      "erred_international_prefix\030\021 \001(\t\022\027\n\017nati" +
-      "onal_prefix\030\014 \001(\t\022\035\n\025preferred_extn_pref" +
-      "ix\030\r \001(\t\022#\n\033national_prefix_for_parsing\030" +
-      "\017 \001(\t\022&\n\036national_prefix_transform_rule\030" +
-      "\020 \001(\t\0221\n\"same_mobile_and_fixed_line_patt" +
-      "ern\030\022 \001(\010:\005false\0226\n\rnumber_format\030\023 \003(\0132" +
-      "\037.i18n.phonenumbers.NumberFormat\022;\n\022intl" +
-      "_number_format\030\024 \003(\0132\037.i18n.phonenumbers" +
-      ".NumberFormat\022\'\n\037national_prefix_formatt" +
-      "ing_rule\030\025 \001(\t\"M\n\027PhoneMetadataCollectio",
-      "n\0222\n\010metadata\030\001 \003(\0132 .i18n.phonenumbers." +
-      "PhoneMetadataB\036\n\034com.google.i18n.phonenu" +
-      "mbers"
-    };
-    com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
-      new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
-        public com.google.protobuf.ExtensionRegistry assignDescriptors(
-            com.google.protobuf.Descriptors.FileDescriptor root) {
-          descriptor = root;
-          internal_static_i18n_phonenumbers_NumberFormat_descriptor =
-            getDescriptor().getMessageTypes().get(0);
-          internal_static_i18n_phonenumbers_NumberFormat_fieldAccessorTable = new
-            com.google.protobuf.GeneratedMessage.FieldAccessorTable(
-              internal_static_i18n_phonenumbers_NumberFormat_descriptor,
-              new java.lang.String[] { "Pattern", "Format", "LeadingDigits", "NationalPrefixFormattingRule", },
-              com.google.i18n.phonenumbers.Phonemetadata.NumberFormat.class,
-              com.google.i18n.phonenumbers.Phonemetadata.NumberFormat.Builder.class);
-          internal_static_i18n_phonenumbers_PhoneNumberDesc_descriptor =
-            getDescriptor().getMessageTypes().get(1);
-          internal_static_i18n_phonenumbers_PhoneNumberDesc_fieldAccessorTable = new
-            com.google.protobuf.GeneratedMessage.FieldAccessorTable(
-              internal_static_i18n_phonenumbers_PhoneNumberDesc_descriptor,
-              new java.lang.String[] { "NationalNumberPattern", "PossibleNumberPattern", "ExampleNumber", },
-              com.google.i18n.phonenumbers.Phonemetadata.PhoneNumberDesc.class,
-              com.google.i18n.phonenumbers.Phonemetadata.PhoneNumberDesc.Builder.class);
-          internal_static_i18n_phonenumbers_PhoneMetadata_descriptor =
-            getDescriptor().getMessageTypes().get(2);
-          internal_static_i18n_phonenumbers_PhoneMetadata_fieldAccessorTable = new
-            com.google.protobuf.GeneratedMessage.FieldAccessorTable(
-              internal_static_i18n_phonenumbers_PhoneMetadata_descriptor,
-              new java.lang.String[] { "GeneralDesc", "FixedLine", "Mobile", "TollFree", "PremiumRate", "SharedCost", "PersonalNumber", "Voip", "Id", "CountryCode", "InternationalPrefix", "PreferredInternationalPrefix", "NationalPrefix", "PreferredExtnPrefix", "NationalPrefixForParsing", "NationalPrefixTransformRule", "SameMobileAndFixedLinePattern", "NumberFormat", "IntlNumberFormat", "NationalPrefixFormattingRule", },
-              com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata.class,
-              com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata.Builder.class);
-          internal_static_i18n_phonenumbers_PhoneMetadataCollection_descriptor =
-            getDescriptor().getMessageTypes().get(3);
-          internal_static_i18n_phonenumbers_PhoneMetadataCollection_fieldAccessorTable = new
-            com.google.protobuf.GeneratedMessage.FieldAccessorTable(
-              internal_static_i18n_phonenumbers_PhoneMetadataCollection_descriptor,
-              new java.lang.String[] { "Metadata", },
-              com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadataCollection.class,
-              com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadataCollection.Builder.class);
-          return null;
-        }
-      };
-    com.google.protobuf.Descriptors.FileDescriptor
-      .internalBuildGeneratedFileFrom(descriptorData,
-        new com.google.protobuf.Descriptors.FileDescriptor[] {
-        }, assigner);
   }
   
   public static void internalForceInit() {}

File java/src/com/google/i18n/phonenumbers/Phonenumber.java

 public final class Phonenumber {
   private Phonenumber() {}
   public static void registerAllExtensions(
-      com.google.protobuf.ExtensionRegistry registry) {
+      com.google.protobuf.ExtensionRegistryLite registry) {
   }
   public static final class PhoneNumber extends
-      com.google.protobuf.GeneratedMessage {
+      com.google.protobuf.GeneratedMessageLite {
     // Use PhoneNumber.newBuilder() to construct.
     private PhoneNumber() {
       initFields();
       return defaultInstance;
     }
     
-    public static final com.google.protobuf.Descriptors.Descriptor
-        getDescriptor() {
-      return com.google.i18n.phonenumbers.Phonenumber.internal_static_i18n_phonenumbers_PhoneNumber_descriptor;
-    }
-    
-    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
-        internalGetFieldAccessorTable() {
-      return com.google.i18n.phonenumbers.Phonenumber.internal_static_i18n_phonenumbers_PhoneNumber_fieldAccessorTable;
-    }
-    
     // required int32 country_code = 1;
     public static final int COUNTRY_CODE_FIELD_NUMBER = 1;
     private boolean hasCountryCode;
       if (hasItalianLeadingZero()) {
         output.writeBool(4, getItalianLeadingZero());
       }
-      getUnknownFields().writeTo(output);
     }
     
     private int memoizedSerializedSize = -1;
         size += com.google.protobuf.CodedOutputStream
           .computeBoolSize(4, getItalianLeadingZero());
       }
-      size += getUnknownFields().getSerializedSize();
       memoizedSerializedSize = size;
       return size;
     }
     public Builder toBuilder() { return newBuilder(this); }
     
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessage.Builder<Builder> {
+        com.google.protobuf.GeneratedMessageLite.Builder<
+          com.google.i18n.phonenumbers.Phonenumber.PhoneNumber, Builder> {
       private com.google.i18n.phonenumbers.Phonenumber.PhoneNumber result;
       
       // Construct using com.google.i18n.phonenumbers.Phonenumber.PhoneNumber.newBuilder()
         return create().mergeFrom(result);
       }
       
-      public com.google.protobuf.Descriptors.Descriptor
-          getDescriptorForType() {
-        return com.google.i18n.phonenumbers.Phonenumber.PhoneNumber.getDescriptor();
-      }
-      
       public com.google.i18n.phonenumbers.Phonenumber.PhoneNumber getDefaultInstanceForType() {
         return com.google.i18n.phonenumbers.Phonenumber.PhoneNumber.getDefaultInstance();
       }
         return returnMe;
       }
       
-      public Builder mergeFrom(com.google.protobuf.Message other) {
-        if (other instanceof com.google.i18n.phonenumbers.Phonenumber.PhoneNumber) {
-          return mergeFrom((com.google.i18n.phonenumbers.Phonenumber.PhoneNumber)other);
-        } else {
-          super.mergeFrom(other);
-          return this;
-        }
-      }
-      
       public Builder mergeFrom(com.google.i18n.phonenumbers.Phonenumber.PhoneNumber other) {
         if (other == com.google.i18n.phonenumbers.Phonenumber.PhoneNumber.getDefaultInstance()) return this;
         if (other.hasCountryCode()) {
         if (other.hasItalianLeadingZero()) {
           setItalianLeadingZero(other.getItalianLeadingZero());
         }
-        this.mergeUnknownFields(other.getUnknownFields());
         return this;
       }
       
           com.google.protobuf.CodedInputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        com.google.protobuf.UnknownFieldSet.Builder unknownFields =
-          com.google.protobuf.UnknownFieldSet.newBuilder(
-            this.getUnknownFields());
         while (true) {
           int tag = input.readTag();
           switch (tag) {
             case 0:
-              this.setUnknownFields(unknownFields.build());
               return this;
             default: {
-              if (!parseUnknownField(input, unknownFields,
-                                     extensionRegistry, tag)) {
-                this.setUnknownFields(unknownFields.build());
+              if (!parseUnknownField(input, extensionRegistry, tag)) {
                 return this;
               }
               break;
     // @@protoc_insertion_point(class_scope:i18n.phonenumbers.PhoneNumber)
   }
   
-  private static com.google.protobuf.Descriptors.Descriptor
-    internal_static_i18n_phonenumbers_PhoneNumber_descriptor;
-  private static
-    com.google.protobuf.GeneratedMessage.FieldAccessorTable
-      internal_static_i18n_phonenumbers_PhoneNumber_fieldAccessorTable;
   
-  public static com.google.protobuf.Descriptors.FileDescriptor
-      getDescriptor() {
-    return descriptor;
-  }
-  private static com.google.protobuf.Descriptors.FileDescriptor
-      descriptor;
   static {
-    java.lang.String[] descriptorData = {
-      "\n\021phonenumber.proto\022\021i18n.phonenumbers\"m" +
-      "\n\013PhoneNumber\022\024\n\014country_code\030\001 \002(\005\022\027\n\017n" +
-      "ational_number\030\002 \002(\004\022\021\n\textension\030\003 \001(\t\022" +
-      "\034\n\024italian_leading_zero\030\004 \001(\010B\036\n\034com.goo" +
-      "gle.i18n.phonenumbers"
-    };
-    com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
-      new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
-        public com.google.protobuf.ExtensionRegistry assignDescriptors(
-            com.google.protobuf.Descriptors.FileDescriptor root) {
-          descriptor = root;
-          internal_static_i18n_phonenumbers_PhoneNumber_descriptor =
-            getDescriptor().getMessageTypes().get(0);
-          internal_static_i18n_phonenumbers_PhoneNumber_fieldAccessorTable = new
-            com.google.protobuf.GeneratedMessage.FieldAccessorTable(
-              internal_static_i18n_phonenumbers_PhoneNumber_descriptor,
-              new java.lang.String[] { "CountryCode", "NationalNumber", "Extension", "ItalianLeadingZero", },
-              com.google.i18n.phonenumbers.Phonenumber.PhoneNumber.class,
-              com.google.i18n.phonenumbers.Phonenumber.PhoneNumber.Builder.class);
-          return null;
-        }
-      };
-    com.google.protobuf.Descriptors.FileDescriptor
-      .internalBuildGeneratedFileFrom(descriptorData,
-        new com.google.protobuf.Descriptors.FileDescriptor[] {
-        }, assigner);
   }
   
   public static void internalForceInit() {}

File java/src/com/google/i18n/phonenumbers/phonemetadata.proto

 syntax = "proto2";
 
 option java_package = "com.google.i18n.phonenumbers";
+option optimize_for = LITE_RUNTIME;
 package i18n.phonenumbers;
 
 message NumberFormat {

File java/src/com/google/i18n/phonenumbers/phonenumber.proto

 syntax = "proto2";
 
 option java_package = "com.google.i18n.phonenumbers";
+option optimize_for = LITE_RUNTIME;
 package i18n.phonenumbers;
 
 message PhoneNumber {