Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: third_party/protobuf/java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 * compiled before the new types were added. 50 * compiled before the new types were added.
51 * 51 *
52 * <p>Every {@link Message} contains an {@code UnknownFieldSet} (and every 52 * <p>Every {@link Message} contains an {@code UnknownFieldSet} (and every
53 * {@link Message.Builder} contains an {@link Builder}). 53 * {@link Message.Builder} contains an {@link Builder}).
54 * 54 *
55 * <p>Most users will never need to use this class. 55 * <p>Most users will never need to use this class.
56 * 56 *
57 * @author kenton@google.com Kenton Varda 57 * @author kenton@google.com Kenton Varda
58 */ 58 */
59 public final class UnknownFieldSet implements MessageLite { 59 public final class UnknownFieldSet implements MessageLite {
60
60 private UnknownFieldSet() {} 61 private UnknownFieldSet() {}
61 62
62 /** Create a new {@link Builder}. */ 63 /** Create a new {@link Builder}. */
63 public static Builder newBuilder() { 64 public static Builder newBuilder() {
64 return Builder.create(); 65 return Builder.create();
65 } 66 }
66 67
67 /** 68 /**
68 * Create a new {@link Builder} and initialize it to be a copy 69 * Create a new {@link Builder} and initialize it to be a copy
69 * of {@code copyFrom}. 70 * of {@code copyFrom}.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 */ 124 */
124 public Field getField(final int number) { 125 public Field getField(final int number) {
125 final Field result = fields.get(number); 126 final Field result = fields.get(number);
126 return (result == null) ? Field.getDefaultInstance() : result; 127 return (result == null) ? Field.getDefaultInstance() : result;
127 } 128 }
128 129
129 /** Serializes the set and writes it to {@code output}. */ 130 /** Serializes the set and writes it to {@code output}. */
130 @Override 131 @Override
131 public void writeTo(final CodedOutputStream output) throws IOException { 132 public void writeTo(final CodedOutputStream output) throws IOException {
132 for (final Map.Entry<Integer, Field> entry : fields.entrySet()) { 133 for (final Map.Entry<Integer, Field> entry : fields.entrySet()) {
133 entry.getValue().writeTo(entry.getKey(), output); 134 Field field = entry.getValue();
135 field.writeTo(entry.getKey(), output);
134 } 136 }
135 } 137 }
136 138
137 /** 139 /**
138 * Converts the set to a string in protocol buffer text format. This is 140 * Converts the set to a string in protocol buffer text format. This is
139 * just a trivial wrapper around 141 * just a trivial wrapper around
140 * {@link TextFormat#printToString(UnknownFieldSet)}. 142 * {@link TextFormat#printToString(UnknownFieldSet)}.
141 */ 143 */
142 @Override 144 @Override
143 public String toString() { 145 public String toString() {
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 @Override 1015 @Override
1014 public UnknownFieldSet parsePartialFrom( 1016 public UnknownFieldSet parsePartialFrom(
1015 CodedInputStream input, ExtensionRegistryLite extensionRegistry) 1017 CodedInputStream input, ExtensionRegistryLite extensionRegistry)
1016 throws InvalidProtocolBufferException { 1018 throws InvalidProtocolBufferException {
1017 Builder builder = newBuilder(); 1019 Builder builder = newBuilder();
1018 try { 1020 try {
1019 builder.mergeFrom(input); 1021 builder.mergeFrom(input);
1020 } catch (InvalidProtocolBufferException e) { 1022 } catch (InvalidProtocolBufferException e) {
1021 throw e.setUnfinishedMessage(builder.buildPartial()); 1023 throw e.setUnfinishedMessage(builder.buildPartial());
1022 } catch (IOException e) { 1024 } catch (IOException e) {
1023 throw new InvalidProtocolBufferException(e.getMessage()) 1025 throw new InvalidProtocolBufferException(e)
1024 .setUnfinishedMessage(builder.buildPartial()); 1026 .setUnfinishedMessage(builder.buildPartial());
1025 } 1027 }
1026 return builder.buildPartial(); 1028 return builder.buildPartial();
1027 } 1029 }
1028 } 1030 }
1029 1031
1030 private static final Parser PARSER = new Parser(); 1032 private static final Parser PARSER = new Parser();
1031 @Override 1033 @Override
1032 public final Parser getParserForType() { 1034 public final Parser getParserForType() {
1033 return PARSER; 1035 return PARSER;
1034 } 1036 }
1035 } 1037 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698