| OLD | NEW | 
|---|
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format | 
| 2 // Copyright 2008 Google Inc.  All rights reserved. | 2 // Copyright 2008 Google Inc.  All rights reserved. | 
| 3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ | 
| 4 // | 4 // | 
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without | 
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are | 
| 7 // met: | 7 // met: | 
| 8 // | 8 // | 
| 9 //     * Redistributions of source code must retain the above copyright | 9 //     * Redistributions of source code must retain the above copyright | 
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. | 
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 290       @Override | 290       @Override | 
| 291       public DynamicMessage parsePartialFrom( | 291       public DynamicMessage parsePartialFrom( | 
| 292           CodedInputStream input, ExtensionRegistryLite extensionRegistry) | 292           CodedInputStream input, ExtensionRegistryLite extensionRegistry) | 
| 293           throws InvalidProtocolBufferException { | 293           throws InvalidProtocolBufferException { | 
| 294         Builder builder = newBuilder(type); | 294         Builder builder = newBuilder(type); | 
| 295         try { | 295         try { | 
| 296           builder.mergeFrom(input, extensionRegistry); | 296           builder.mergeFrom(input, extensionRegistry); | 
| 297         } catch (InvalidProtocolBufferException e) { | 297         } catch (InvalidProtocolBufferException e) { | 
| 298           throw e.setUnfinishedMessage(builder.buildPartial()); | 298           throw e.setUnfinishedMessage(builder.buildPartial()); | 
| 299         } catch (IOException e) { | 299         } catch (IOException e) { | 
| 300           throw new InvalidProtocolBufferException(e.getMessage()) | 300           throw new InvalidProtocolBufferException(e) | 
| 301               .setUnfinishedMessage(builder.buildPartial()); | 301               .setUnfinishedMessage(builder.buildPartial()); | 
| 302         } | 302         } | 
| 303         return builder.buildPartial(); | 303         return builder.buildPartial(); | 
| 304       } | 304       } | 
| 305     }; | 305     }; | 
| 306   } | 306   } | 
| 307 | 307 | 
| 308   /** Verifies that the field is a field of this message. */ | 308   /** Verifies that the field is a field of this message. */ | 
| 309   private void verifyContainingType(FieldDescriptor field) { | 309   private void verifyContainingType(FieldDescriptor field) { | 
| 310     if (field.getContainingType() != type) { | 310     if (field.getContainingType() != type) { | 
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 519         ensureEnumValueDescriptor(field, value); | 519         ensureEnumValueDescriptor(field, value); | 
| 520       } | 520       } | 
| 521       OneofDescriptor oneofDescriptor = field.getContainingOneof(); | 521       OneofDescriptor oneofDescriptor = field.getContainingOneof(); | 
| 522       if (oneofDescriptor != null) { | 522       if (oneofDescriptor != null) { | 
| 523         int index = oneofDescriptor.getIndex(); | 523         int index = oneofDescriptor.getIndex(); | 
| 524         FieldDescriptor oldField = oneofCases[index]; | 524         FieldDescriptor oldField = oneofCases[index]; | 
| 525         if ((oldField != null) && (oldField != field)) { | 525         if ((oldField != null) && (oldField != field)) { | 
| 526           fields.clearField(oldField); | 526           fields.clearField(oldField); | 
| 527         } | 527         } | 
| 528         oneofCases[index] = field; | 528         oneofCases[index] = field; | 
|  | 529       } else if (field.getFile().getSyntax() == Descriptors.FileDescriptor.Synta
     x.PROTO3) { | 
|  | 530         if (!field.isRepeated() | 
|  | 531             && field.getJavaType() != FieldDescriptor.JavaType.MESSAGE | 
|  | 532             && value.equals(field.getDefaultValue())) { | 
|  | 533           // In proto3, setting a field to its default value is equivalent to cl
     earing the field. | 
|  | 534           fields.clearField(field); | 
|  | 535           return this; | 
|  | 536         } | 
| 529       } | 537       } | 
| 530       fields.setField(field, value); | 538       fields.setField(field, value); | 
| 531       return this; | 539       return this; | 
| 532     } | 540     } | 
| 533 | 541 | 
| 534     @Override | 542     @Override | 
| 535     public Builder clearField(FieldDescriptor field) { | 543     public Builder clearField(FieldDescriptor field) { | 
| 536       verifyContainingType(field); | 544       verifyContainingType(field); | 
| 537       ensureIsMutable(); | 545       ensureIsMutable(); | 
| 538       OneofDescriptor oneofDescriptor = field.getContainingOneof(); | 546       OneofDescriptor oneofDescriptor = field.getContainingOneof(); | 
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 667     } | 675     } | 
| 668 | 676 | 
| 669     @Override | 677     @Override | 
| 670     public com.google.protobuf.Message.Builder getRepeatedFieldBuilder(FieldDesc
     riptor field, | 678     public com.google.protobuf.Message.Builder getRepeatedFieldBuilder(FieldDesc
     riptor field, | 
| 671         int index) { | 679         int index) { | 
| 672       throw new UnsupportedOperationException( | 680       throw new UnsupportedOperationException( | 
| 673         "getRepeatedFieldBuilder() called on a dynamic message type."); | 681         "getRepeatedFieldBuilder() called on a dynamic message type."); | 
| 674     } | 682     } | 
| 675   } | 683   } | 
| 676 } | 684 } | 
| OLD | NEW | 
|---|