GeneratedMessageLite.java
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 package com.google.protobuf;
32 
41 import java.io.IOException;
42 import java.io.InputStream;
43 import java.io.ObjectStreamException;
44 import java.io.Serializable;
45 import java.lang.reflect.InvocationTargetException;
46 import java.lang.reflect.Method;
47 import java.nio.ByteBuffer;
48 import java.util.ArrayList;
49 import java.util.Collections;
50 import java.util.Iterator;
51 import java.util.List;
52 import java.util.Map;
53 import java.util.concurrent.ConcurrentHashMap;
54 
60 public abstract class GeneratedMessageLite<
61  MessageType extends GeneratedMessageLite<MessageType, BuilderType>,
62  BuilderType extends GeneratedMessageLite.Builder<MessageType, BuilderType>>
63  extends AbstractMessageLite<MessageType, BuilderType> {
64 
67 
69  protected int memoizedSerializedSize = -1;
70 
71  @Override
72  @SuppressWarnings("unchecked") // Guaranteed by runtime.
73  public final Parser<MessageType> getParserForType() {
74  return (Parser<MessageType>) dynamicMethod(MethodToInvoke.GET_PARSER);
75  }
76 
77  @Override
78  @SuppressWarnings("unchecked") // Guaranteed by runtime.
79  public final MessageType getDefaultInstanceForType() {
80  return (MessageType) dynamicMethod(MethodToInvoke.GET_DEFAULT_INSTANCE);
81  }
82 
83  @Override
84  @SuppressWarnings("unchecked") // Guaranteed by runtime.
85  public final BuilderType newBuilderForType() {
86  return (BuilderType) dynamicMethod(MethodToInvoke.NEW_BUILDER);
87  }
88 
101  @Override
102  public String toString() {
103  return MessageLiteToString.toString(this, super.toString());
104  }
105 
106  @SuppressWarnings("unchecked") // Guaranteed by runtime
107  @Override
108  public int hashCode() {
109  if (memoizedHashCode != 0) {
110  return memoizedHashCode;
111  }
112  memoizedHashCode = Protobuf.getInstance().schemaFor(this).hashCode(this);
113  return memoizedHashCode;
114  }
115 
116  @SuppressWarnings("unchecked") // Guaranteed by isInstance + runtime
117  @Override
118  public boolean equals(Object other) {
119  if (this == other) {
120  return true;
121  }
122 
123  if (!getDefaultInstanceForType().getClass().isInstance(other)) {
124  return false;
125  }
126 
127  return Protobuf.getInstance().schemaFor(this).equals(this, (MessageType) other);
128  }
129 
130  // The general strategy for unknown fields is to use an UnknownFieldSetLite that is treated as
131  // mutable during the parsing constructor and immutable after. This allows us to avoid
132  // any unnecessary intermediary allocations while reducing the generated code size.
133 
135  private final void ensureUnknownFieldsInitialized() {
137  unknownFields = UnknownFieldSetLite.newInstance();
138  }
139  }
140 
146  protected boolean parseUnknownField(int tag, CodedInputStream input) throws IOException {
147  // This will avoid the allocation of unknown fields when a group tag is encountered.
149  return false;
150  }
151 
153  return unknownFields.mergeFieldFrom(tag, input);
154  }
155 
157  protected void mergeVarintField(int tag, int value) {
159  unknownFields.mergeVarintField(tag, value);
160  }
161 
163  protected void mergeLengthDelimitedField(int fieldNumber, ByteString value) {
165  unknownFields.mergeLengthDelimitedField(fieldNumber, value);
166  }
167 
169  protected void makeImmutable() {
170  Protobuf.getInstance().schemaFor(this).makeImmutable(this);
171  }
172 
173  protected final <
175  BuilderType extends GeneratedMessageLite.Builder<MessageType, BuilderType>>
176  BuilderType createBuilder() {
177  return (BuilderType) dynamicMethod(MethodToInvoke.NEW_BUILDER);
178  }
179 
180  protected final <
182  BuilderType extends GeneratedMessageLite.Builder<MessageType, BuilderType>>
183  BuilderType createBuilder(MessageType prototype) {
184  return ((BuilderType) createBuilder()).mergeFrom(prototype);
185  }
186 
187  @Override
188  public final boolean isInitialized() {
189  return isInitialized((MessageType) this, Boolean.TRUE);
190  }
191 
192  @Override
193  @SuppressWarnings("unchecked")
194  public final BuilderType toBuilder() {
195  BuilderType builder = (BuilderType) dynamicMethod(MethodToInvoke.NEW_BUILDER);
196  builder.mergeFrom((MessageType) this);
197  return builder;
198  }
199 
206  public static enum MethodToInvoke {
207  // Rely on/modify instance state
210 
211  // Rely on static state
217  }
218 
242  protected abstract Object dynamicMethod(MethodToInvoke method, Object arg0, Object arg1);
243 
245  protected Object dynamicMethod(MethodToInvoke method, Object arg0) {
246  return dynamicMethod(method, arg0, null);
247  }
248 
250  protected Object dynamicMethod(MethodToInvoke method) {
251  return dynamicMethod(method, null, null);
252  }
253 
254  @Override
255  int getMemoizedSerializedSize() {
256  return memoizedSerializedSize;
257  }
258 
259  @Override
260  void setMemoizedSerializedSize(int size) {
262  }
263 
264  public void writeTo(CodedOutputStream output) throws IOException {
265  Protobuf.getInstance()
266  .schemaFor(this)
267  .writeTo(this, CodedOutputStreamWriter.forCodedOutput(output));
268  }
269 
270  public int getSerializedSize() {
271  if (memoizedSerializedSize == -1) {
272  memoizedSerializedSize = Protobuf.getInstance().schemaFor(this).getSerializedSize(this);
273  }
274  return memoizedSerializedSize;
275  }
276 
278  Object buildMessageInfo() throws Exception {
279  return dynamicMethod(MethodToInvoke.BUILD_MESSAGE_INFO);
280  }
281 
282  private static Map<Object, GeneratedMessageLite<?, ?>> defaultInstanceMap =
283  new ConcurrentHashMap<Object, GeneratedMessageLite<?, ?>>();
284 
285  @SuppressWarnings("unchecked")
286  static <T extends GeneratedMessageLite<?, ?>> T getDefaultInstance(Class<T> clazz) {
287  T result = (T) defaultInstanceMap.get(clazz);
288  if (result == null) {
289  // Foo.class does not initialize the class so we need to force the initialization in order to
290  // get the default instance registered.
291  try {
292  Class.forName(clazz.getName(), true, clazz.getClassLoader());
293  } catch (ClassNotFoundException e) {
294  throw new IllegalStateException("Class initialization cannot fail.", e);
295  }
296  result = (T) defaultInstanceMap.get(clazz);
297  }
298  if (result == null) {
299  // On some Samsung devices, this still doesn't return a valid value for some reason. We add a
300  // reflective fallback to keep the device running. See b/114675342.
301  result = (T) UnsafeUtil.allocateInstance(clazz).getDefaultInstanceForType();
302  // A sanity check to ensure that <clinit> was actually invoked.
303  if (result == null) {
304  throw new IllegalStateException();
305  }
306  defaultInstanceMap.put(clazz, result);
307  }
308  return result;
309  }
310 
311  protected static <T extends GeneratedMessageLite<?, ?>> void registerDefaultInstance(
312  Class<T> clazz, T defaultInstance) {
313  defaultInstanceMap.put(clazz, defaultInstance);
314  }
315 
316  protected static Object newMessageInfo(
317  MessageLite defaultInstance, String info, Object[] objects) {
318  return new RawMessageInfo(defaultInstance, info, objects);
319  }
320 
327  this.unknownFields = UnknownFieldSetLite.mutableCopyOf(this.unknownFields, unknownFields);
328  }
329 
330  @SuppressWarnings("unchecked")
331  public abstract static class Builder<
332  MessageType extends GeneratedMessageLite<MessageType, BuilderType>,
333  BuilderType extends Builder<MessageType, BuilderType>>
334  extends AbstractMessageLite.Builder<MessageType, BuilderType> {
335 
336  private final MessageType defaultInstance;
337  protected MessageType instance;
338  protected boolean isBuilt;
339 
340  protected Builder(MessageType defaultInstance) {
341  this.defaultInstance = defaultInstance;
342  this.instance =
343  (MessageType) defaultInstance.dynamicMethod(MethodToInvoke.NEW_MUTABLE_INSTANCE);
344  isBuilt = false;
345  }
346 
351  protected void copyOnWrite() {
352  if (isBuilt) {
353  MessageType newInstance =
354  (MessageType) instance.dynamicMethod(MethodToInvoke.NEW_MUTABLE_INSTANCE);
355  mergeFromInstance(newInstance, instance);
356  instance = newInstance;
357  isBuilt = false;
358  }
359  }
360 
361  @Override
362  public final boolean isInitialized() {
363  return GeneratedMessageLite.isInitialized(instance, /* shouldMemoize= */ false);
364  }
365 
366  @Override
367  public final BuilderType clear() {
368  // No need to copy on write since we're dropping the instance anyways.
369  instance = (MessageType) instance.dynamicMethod(MethodToInvoke.NEW_MUTABLE_INSTANCE);
370  return (BuilderType) this;
371  }
372 
373  @Override
374  public BuilderType clone() {
375  BuilderType builder = (BuilderType) getDefaultInstanceForType().newBuilderForType();
376  builder.mergeFrom(buildPartial());
377  return builder;
378  }
379 
380  @Override
381  public MessageType buildPartial() {
382  if (isBuilt) {
383  return instance;
384  }
385 
386  instance.makeImmutable();
387 
388  isBuilt = true;
389  return instance;
390  }
391 
392  @Override
393  public final MessageType build() {
394  MessageType result = buildPartial();
395  if (!result.isInitialized()) {
396  throw newUninitializedMessageException(result);
397  }
398  return result;
399  }
400 
401  @Override
402  protected BuilderType internalMergeFrom(MessageType message) {
403  return mergeFrom(message);
404  }
405 
407  public BuilderType mergeFrom(MessageType message) {
408  copyOnWrite();
409  mergeFromInstance(instance, message);
410  return (BuilderType) this;
411  }
412 
413  private void mergeFromInstance(MessageType dest, MessageType src) {
414  Protobuf.getInstance().schemaFor(dest).mergeFrom(dest, src);
415  }
416 
417  @Override
418  public MessageType getDefaultInstanceForType() {
419  return defaultInstance;
420  }
421 
422  @Override
423  public BuilderType mergeFrom(
424  byte[] input, int offset, int length, ExtensionRegistryLite extensionRegistry)
426  copyOnWrite();
427  try {
428  Protobuf.getInstance().schemaFor(instance).mergeFrom(
429  instance, input, offset, offset + length,
430  new ArrayDecoders.Registers(extensionRegistry));
431  } catch (InvalidProtocolBufferException e) {
432  throw e;
433  } catch (IndexOutOfBoundsException e) {
434  throw InvalidProtocolBufferException.truncatedMessage();
435  } catch (IOException e) {
436  throw new RuntimeException("Reading from byte array should not throw IOException.", e);
437  }
438  return (BuilderType) this;
439  }
440 
441  @Override
442  public BuilderType mergeFrom(
443  byte[] input, int offset, int length)
446  }
447 
448  @Override
449  public BuilderType mergeFrom(
451  com.google.protobuf.ExtensionRegistryLite extensionRegistry)
452  throws IOException {
453  copyOnWrite();
454  try {
455  // TODO(yilunchong): Try to make input with type CodedInpuStream.ArrayDecoder use
456  // fast path.
457  Protobuf.getInstance().schemaFor(instance).mergeFrom(
458  instance, CodedInputStreamReader.forCodedInput(input), extensionRegistry);
459  } catch (RuntimeException e) {
460  if (e.getCause() instanceof IOException) {
461  throw (IOException) e.getCause();
462  }
463  throw e;
464  }
465  return (BuilderType) this;
466  }
467  }
468 
469 
470  // =================================================================
471  // Extensions-related stuff
472 
474  public interface ExtendableMessageOrBuilder<
475  MessageType extends ExtendableMessage<MessageType, BuilderType>,
476  BuilderType extends ExtendableBuilder<MessageType, BuilderType>>
477  extends MessageLiteOrBuilder {
478 
481 
483  <Type> int getExtensionCount(ExtensionLite<MessageType, List<Type>> extension);
484 
487 
489  <Type> Type getExtension(ExtensionLite<MessageType, List<Type>> extension, int index);
490  }
491 
493  public abstract static class ExtendableMessage<
494  MessageType extends ExtendableMessage<MessageType, BuilderType>,
495  BuilderType extends ExtendableBuilder<MessageType, BuilderType>>
496  extends GeneratedMessageLite<MessageType, BuilderType>
497  implements ExtendableMessageOrBuilder<MessageType, BuilderType> {
498 
500  protected FieldSet<ExtensionDescriptor> extensions = FieldSet.emptySet();
501 
502  @SuppressWarnings("unchecked")
503  protected final void mergeExtensionFields(final MessageType other) {
504  if (extensions.isImmutable()) {
505  extensions = extensions.clone();
506  }
507  extensions.mergeFrom(((ExtendableMessage) other).extensions);
508  }
509 
517  protected <MessageType extends MessageLite> boolean parseUnknownField(
518  MessageType defaultInstance,
520  ExtensionRegistryLite extensionRegistry,
521  int tag)
522  throws IOException {
523  int fieldNumber = WireFormat.getTagFieldNumber(tag);
524 
525  // TODO(dweis): How much bytecode would be saved by not requiring the generated code to
526  // provide the default instance?
528  extensionRegistry.findLiteExtensionByNumber(defaultInstance, fieldNumber);
529 
530  return parseExtension(input, extensionRegistry, extension, tag, fieldNumber);
531  }
532 
533  private boolean parseExtension(
535  ExtensionRegistryLite extensionRegistry,
537  int tag,
538  int fieldNumber)
539  throws IOException {
540  int wireType = WireFormat.getTagWireType(tag);
541  boolean unknown = false;
542  boolean packed = false;
543  if (extension == null) {
544  unknown = true; // Unknown field.
545  } else if (wireType
546  == FieldSet.getWireFormatForFieldType(
547  extension.descriptor.getLiteType(), /* isPacked= */ false)) {
548  packed = false; // Normal, unpacked value.
549  } else if (extension.descriptor.isRepeated
550  && extension.descriptor.type.isPackable()
551  && wireType
552  == FieldSet.getWireFormatForFieldType(
553  extension.descriptor.getLiteType(), /* isPacked= */ true)) {
554  packed = true; // Packed value.
555  } else {
556  unknown = true; // Wrong wire type.
557  }
558 
559  if (unknown) { // Unknown field or wrong wire type. Skip.
560  return parseUnknownField(tag, input);
561  }
562 
563  ensureExtensionsAreMutable();
564 
565  if (packed) {
566  int length = input.readRawVarint32();
567  int limit = input.pushLimit(length);
568  if (extension.descriptor.getLiteType() == WireFormat.FieldType.ENUM) {
569  while (input.getBytesUntilLimit() > 0) {
570  int rawValue = input.readEnum();
571  Object value = extension.descriptor.getEnumType().findValueByNumber(rawValue);
572  if (value == null) {
573  // If the number isn't recognized as a valid value for this
574  // enum, drop it (don't even add it to unknownFields).
575  return true;
576  }
577  extensions.addRepeatedField(
578  extension.descriptor, extension.singularToFieldSetType(value));
579  }
580  } else {
581  while (input.getBytesUntilLimit() > 0) {
582  Object value =
583  FieldSet.readPrimitiveField(
584  input, extension.descriptor.getLiteType(), /*checkUtf8=*/ false);
585  extensions.addRepeatedField(extension.descriptor, value);
586  }
587  }
588  input.popLimit(limit);
589  } else {
590  Object value;
591  switch (extension.descriptor.getLiteJavaType()) {
592  case MESSAGE:
593  {
594  MessageLite.Builder subBuilder = null;
595  if (!extension.descriptor.isRepeated()) {
596  MessageLite existingValue = (MessageLite) extensions.getField(extension.descriptor);
597  if (existingValue != null) {
598  subBuilder = existingValue.toBuilder();
599  }
600  }
601  if (subBuilder == null) {
602  subBuilder = extension.getMessageDefaultInstance().newBuilderForType();
603  }
604  if (extension.descriptor.getLiteType() == WireFormat.FieldType.GROUP) {
605  input.readGroup(extension.getNumber(), subBuilder, extensionRegistry);
606  } else {
607  input.readMessage(subBuilder, extensionRegistry);
608  }
609  value = subBuilder.build();
610  break;
611  }
612  case ENUM:
613  int rawValue = input.readEnum();
614  value = extension.descriptor.getEnumType().findValueByNumber(rawValue);
615  // If the number isn't recognized as a valid value for this enum,
616  // write it to unknown fields object.
617  if (value == null) {
618  mergeVarintField(fieldNumber, rawValue);
619  return true;
620  }
621  break;
622  default:
623  value =
624  FieldSet.readPrimitiveField(
625  input, extension.descriptor.getLiteType(), /*checkUtf8=*/ false);
626  break;
627  }
628 
629  if (extension.descriptor.isRepeated()) {
630  extensions.addRepeatedField(
631  extension.descriptor, extension.singularToFieldSetType(value));
632  } else {
633  extensions.setField(extension.descriptor, extension.singularToFieldSetType(value));
634  }
635  }
636  return true;
637  }
638 
646  protected <MessageType extends MessageLite> boolean parseUnknownFieldAsMessageSet(
647  MessageType defaultInstance,
649  ExtensionRegistryLite extensionRegistry,
650  int tag)
651  throws IOException {
652 
653  if (tag == WireFormat.MESSAGE_SET_ITEM_TAG) {
654  mergeMessageSetExtensionFromCodedStream(defaultInstance, input, extensionRegistry);
655  return true;
656  }
657 
658  // TODO(dweis): Do we really want to support non message set wire format in message sets?
659  // Full runtime does... So we do for now.
660  int wireType = WireFormat.getTagWireType(tag);
661  if (wireType == WireFormat.WIRETYPE_LENGTH_DELIMITED) {
662  return parseUnknownField(defaultInstance, input, extensionRegistry, tag);
663  } else {
664  // TODO(dweis): Should we throw on invalid input? Full runtime does not...
665  return input.skipField(tag);
666  }
667  }
668 
676  private <MessageType extends MessageLite> void mergeMessageSetExtensionFromCodedStream(
677  MessageType defaultInstance,
678  CodedInputStream input,
679  ExtensionRegistryLite extensionRegistry)
680  throws IOException {
681  // The wire format for MessageSet is:
682  // message MessageSet {
683  // repeated group Item = 1 {
684  // required int32 typeId = 2;
685  // required bytes message = 3;
686  // }
687  // }
688  // "typeId" is the extension's field number. The extension can only be
689  // a message type, where "message" contains the encoded bytes of that
690  // message.
691  //
692  // In practice, we will probably never see a MessageSet item in which
693  // the message appears before the type ID, or where either field does not
694  // appear exactly once. However, in theory such cases are valid, so we
695  // should be prepared to accept them.
696 
697  int typeId = 0;
698  ByteString rawBytes = null; // If we encounter "message" before "typeId"
699  GeneratedExtension<?, ?> extension = null;
700 
701  // Read bytes from input, if we get it's type first then parse it eagerly,
702  // otherwise we store the raw bytes in a local variable.
703  while (true) {
704  final int tag = input.readTag();
705  if (tag == 0) {
706  break;
707  }
708 
709  if (tag == WireFormat.MESSAGE_SET_TYPE_ID_TAG) {
710  typeId = input.readUInt32();
711  if (typeId != 0) {
712  extension = extensionRegistry.findLiteExtensionByNumber(defaultInstance, typeId);
713  }
714 
715  } else if (tag == WireFormat.MESSAGE_SET_MESSAGE_TAG) {
716  if (typeId != 0) {
717  if (extension != null) {
718  // We already know the type, so we can parse directly from the
719  // input with no copying. Hooray!
720  eagerlyMergeMessageSetExtension(input, extension, extensionRegistry, typeId);
721  rawBytes = null;
722  continue;
723  }
724  }
725  // We haven't seen a type ID yet or we want parse message lazily.
726  rawBytes = input.readBytes();
727 
728  } else { // Unknown tag. Skip it.
729  if (!input.skipField(tag)) {
730  break; // End of group
731  }
732  }
733  }
734  input.checkLastTagWas(WireFormat.MESSAGE_SET_ITEM_END_TAG);
735 
736  // Process the raw bytes.
737  if (rawBytes != null && typeId != 0) { // Zero is not a valid type ID.
738  if (extension != null) { // We known the type
739  mergeMessageSetExtensionFromBytes(rawBytes, extensionRegistry, extension);
740  } else { // We don't know how to parse this. Ignore it.
741  if (rawBytes != null) {
742  mergeLengthDelimitedField(typeId, rawBytes);
743  }
744  }
745  }
746  }
747 
751  ExtensionRegistryLite extensionRegistry,
752  int typeId)
753  throws IOException {
754  int fieldNumber = typeId;
755  int tag = WireFormat.makeTag(typeId, WireFormat.WIRETYPE_LENGTH_DELIMITED);
756  parseExtension(input, extensionRegistry, extension, tag, fieldNumber);
757  }
758 
760  ByteString rawBytes,
761  ExtensionRegistryLite extensionRegistry,
763  throws IOException {
764  MessageLite.Builder subBuilder = null;
765  MessageLite existingValue = (MessageLite) extensions.getField(extension.descriptor);
766  if (existingValue != null) {
767  subBuilder = existingValue.toBuilder();
768  }
769  if (subBuilder == null) {
770  subBuilder = extension.getMessageDefaultInstance().newBuilderForType();
771  }
772  subBuilder.mergeFrom(rawBytes, extensionRegistry);
773  MessageLite value = subBuilder.build();
774 
775  ensureExtensionsAreMutable()
776  .setField(extension.descriptor, extension.singularToFieldSetType(value));
777  }
778 
779  FieldSet<ExtensionDescriptor> ensureExtensionsAreMutable() {
780  if (extensions.isImmutable()) {
781  extensions = extensions.clone();
782  }
783  return extensions;
784  }
785 
787  if (extension.getContainingTypeDefaultInstance() != getDefaultInstanceForType()) {
788  // This can only happen if someone uses unchecked operations.
789  throw new IllegalArgumentException(
790  "This extension is for a different message type. Please make "
791  + "sure that you are not suppressing any generics type warnings.");
792  }
793  }
794 
796  @Override
797  public final <Type> boolean hasExtension(final ExtensionLite<MessageType, Type> extension) {
798  GeneratedExtension<MessageType, Type> extensionLite = checkIsLite(extension);
799 
800  verifyExtensionContainingType(extensionLite);
801  return extensions.hasField(extensionLite.descriptor);
802  }
803 
805  @Override
806  public final <Type> int getExtensionCount(
807  final ExtensionLite<MessageType, List<Type>> extension) {
808  GeneratedExtension<MessageType, List<Type>> extensionLite = checkIsLite(extension);
809 
810  verifyExtensionContainingType(extensionLite);
811  return extensions.getRepeatedFieldCount(extensionLite.descriptor);
812  }
813 
815  @Override
816  @SuppressWarnings("unchecked")
817  public final <Type> Type getExtension(final ExtensionLite<MessageType, Type> extension) {
818  GeneratedExtension<MessageType, Type> extensionLite = checkIsLite(extension);
819 
820  verifyExtensionContainingType(extensionLite);
821  final Object value = extensions.getField(extensionLite.descriptor);
822  if (value == null) {
823  return extensionLite.defaultValue;
824  } else {
825  return (Type) extensionLite.fromFieldSetType(value);
826  }
827  }
828 
830  @Override
831  @SuppressWarnings("unchecked")
832  public final <Type> Type getExtension(
833  final ExtensionLite<MessageType, List<Type>> extension, final int index) {
834  GeneratedExtension<MessageType, List<Type>> extensionLite = checkIsLite(extension);
835 
836  verifyExtensionContainingType(extensionLite);
837  return (Type)
838  extensionLite.singularFromFieldSetType(
839  extensions.getRepeatedField(extensionLite.descriptor, index));
840  }
841 
843  protected boolean extensionsAreInitialized() {
844  return extensions.isInitialized();
845  }
846 
852  protected class ExtensionWriter {
853  // Imagine how much simpler this code would be if Java iterators had
854  // a way to get the next element without advancing the iterator.
855 
856  private final Iterator<Map.Entry<ExtensionDescriptor, Object>> iter = extensions.iterator();
857  private Map.Entry<ExtensionDescriptor, Object> next;
858  private final boolean messageSetWireFormat;
859 
861  if (iter.hasNext()) {
862  next = iter.next();
863  }
864  this.messageSetWireFormat = messageSetWireFormat;
865  }
866 
867  public void writeUntil(final int end, final CodedOutputStream output) throws IOException {
868  while (next != null && next.getKey().getNumber() < end) {
869  ExtensionDescriptor extension = next.getKey();
871  && extension.getLiteJavaType() == WireFormat.JavaType.MESSAGE
872  && !extension.isRepeated()) {
873  output.writeMessageSetExtension(extension.getNumber(), (MessageLite) next.getValue());
874  } else {
875  FieldSet.writeField(extension, next.getValue(), output);
876  }
877  if (iter.hasNext()) {
878  next = iter.next();
879  } else {
880  next = null;
881  }
882  }
883  }
884  }
885 
887  return new ExtensionWriter(false);
888  }
889 
891  return new ExtensionWriter(true);
892  }
893 
895  protected int extensionsSerializedSize() {
896  return extensions.getSerializedSize();
897  }
898 
900  return extensions.getMessageSetSerializedSize();
901  }
902  }
903 
905  @SuppressWarnings("unchecked")
906  public abstract static class ExtendableBuilder<
907  MessageType extends ExtendableMessage<MessageType, BuilderType>,
908  BuilderType extends ExtendableBuilder<MessageType, BuilderType>>
909  extends Builder<MessageType, BuilderType>
910  implements ExtendableMessageOrBuilder<MessageType, BuilderType> {
911  protected ExtendableBuilder(MessageType defaultInstance) {
912  super(defaultInstance);
913  }
914 
915  // For immutable message conversion.
916  void internalSetExtensionSet(FieldSet<ExtensionDescriptor> extensions) {
917  copyOnWrite();
918  instance.extensions = extensions;
919  }
920 
921  @Override
922  protected void copyOnWrite() {
923  if (!isBuilt) {
924  return;
925  }
926 
927  super.copyOnWrite();
928  instance.extensions = instance.extensions.clone();
929  }
930 
931  private FieldSet<ExtensionDescriptor> ensureExtensionsAreMutable() {
932  FieldSet<ExtensionDescriptor> extensions = instance.extensions;
933  if (extensions.isImmutable()) {
934  extensions = extensions.clone();
935  instance.extensions = extensions;
936  }
937  return extensions;
938  }
939 
940  @Override
941  public final MessageType buildPartial() {
942  if (isBuilt) {
943  return instance;
944  }
945 
946  instance.extensions.makeImmutable();
947  return super.buildPartial();
948  }
949 
951  if (extension.getContainingTypeDefaultInstance() != getDefaultInstanceForType()) {
952  // This can only happen if someone uses unchecked operations.
953  throw new IllegalArgumentException(
954  "This extension is for a different message type. Please make "
955  + "sure that you are not suppressing any generics type warnings.");
956  }
957  }
958 
960  @Override
961  public final <Type> boolean hasExtension(final ExtensionLite<MessageType, Type> extension) {
962  return instance.hasExtension(extension);
963  }
964 
966  @Override
967  public final <Type> int getExtensionCount(
968  final ExtensionLite<MessageType, List<Type>> extension) {
969  return instance.getExtensionCount(extension);
970  }
971 
973  @Override
974  @SuppressWarnings("unchecked")
975  public final <Type> Type getExtension(final ExtensionLite<MessageType, Type> extension) {
976  return instance.getExtension(extension);
977  }
978 
980  @Override
981  @SuppressWarnings("unchecked")
982  public final <Type> Type getExtension(
983  final ExtensionLite<MessageType, List<Type>> extension, final int index) {
984  return instance.getExtension(extension, index);
985  }
986 
988  public final <Type> BuilderType setExtension(
990  GeneratedExtension<MessageType, Type> extensionLite = checkIsLite(extension);
991 
992  verifyExtensionContainingType(extensionLite);
993  copyOnWrite();
994  ensureExtensionsAreMutable()
995  .setField(extensionLite.descriptor, extensionLite.toFieldSetType(value));
996  return (BuilderType) this;
997  }
998 
1000  public final <Type> BuilderType setExtension(
1001  final ExtensionLite<MessageType, List<Type>> extension, final int index, final Type value) {
1002  GeneratedExtension<MessageType, List<Type>> extensionLite = checkIsLite(extension);
1003 
1004  verifyExtensionContainingType(extensionLite);
1005  copyOnWrite();
1006  ensureExtensionsAreMutable()
1007  .setRepeatedField(
1008  extensionLite.descriptor, index, extensionLite.singularToFieldSetType(value));
1009  return (BuilderType) this;
1010  }
1011 
1013  public final <Type> BuilderType addExtension(
1014  final ExtensionLite<MessageType, List<Type>> extension, final Type value) {
1015  GeneratedExtension<MessageType, List<Type>> extensionLite = checkIsLite(extension);
1016 
1017  verifyExtensionContainingType(extensionLite);
1018  copyOnWrite();
1019  ensureExtensionsAreMutable()
1020  .addRepeatedField(extensionLite.descriptor, extensionLite.singularToFieldSetType(value));
1021  return (BuilderType) this;
1022  }
1023 
1025  public final <Type> BuilderType clearExtension(final ExtensionLite<MessageType, ?> extension) {
1026  GeneratedExtension<MessageType, ?> extensionLite = checkIsLite(extension);
1027 
1028  verifyExtensionContainingType(extensionLite);
1029  copyOnWrite();
1030  ensureExtensionsAreMutable().clearField(extensionLite.descriptor);
1031  return (BuilderType) this;
1032  }
1033  }
1034 
1035  // -----------------------------------------------------------------
1036 
1038  public static <ContainingType extends MessageLite, Type>
1040  final ContainingType containingTypeDefaultInstance,
1041  final Type defaultValue,
1042  final MessageLite messageDefaultInstance,
1043  final Internal.EnumLiteMap<?> enumTypeMap,
1044  final int number,
1045  final WireFormat.FieldType type,
1046  final Class singularType) {
1048  containingTypeDefaultInstance,
1049  defaultValue,
1050  messageDefaultInstance,
1051  new ExtensionDescriptor(
1052  enumTypeMap, number, type, /* isRepeated= */ false, /* isPacked= */ false),
1053  singularType);
1054  }
1055 
1057  public static <ContainingType extends MessageLite, Type>
1059  final ContainingType containingTypeDefaultInstance,
1060  final MessageLite messageDefaultInstance,
1061  final Internal.EnumLiteMap<?> enumTypeMap,
1062  final int number,
1063  final WireFormat.FieldType type,
1064  final boolean isPacked,
1065  final Class singularType) {
1066  @SuppressWarnings("unchecked") // Subclasses ensure Type is a List
1067  Type emptyList = (Type) Collections.emptyList();
1069  containingTypeDefaultInstance,
1070  emptyList,
1071  messageDefaultInstance,
1072  new ExtensionDescriptor(enumTypeMap, number, type, /* isRepeated= */ true, isPacked),
1073  singularType);
1074  }
1075 
1076  static final class ExtensionDescriptor
1077  implements FieldSet.FieldDescriptorLite<ExtensionDescriptor> {
1078  ExtensionDescriptor(
1079  final Internal.EnumLiteMap<?> enumTypeMap,
1080  final int number,
1081  final WireFormat.FieldType type,
1082  final boolean isRepeated,
1083  final boolean isPacked) {
1084  this.enumTypeMap = enumTypeMap;
1085  this.number = number;
1086  this.type = type;
1087  this.isRepeated = isRepeated;
1088  this.isPacked = isPacked;
1089  }
1090 
1091  final Internal.EnumLiteMap<?> enumTypeMap;
1092  final int number;
1093  final WireFormat.FieldType type;
1094  final boolean isRepeated;
1095  final boolean isPacked;
1096 
1097  @Override
1098  public int getNumber() {
1099  return number;
1100  }
1101 
1102  @Override
1103  public WireFormat.FieldType getLiteType() {
1104  return type;
1105  }
1106 
1107  @Override
1108  public WireFormat.JavaType getLiteJavaType() {
1109  return type.getJavaType();
1110  }
1111 
1112  @Override
1113  public boolean isRepeated() {
1114  return isRepeated;
1115  }
1116 
1117  @Override
1118  public boolean isPacked() {
1119  return isPacked;
1120  }
1121 
1122  @Override
1123  public Internal.EnumLiteMap<?> getEnumType() {
1124  return enumTypeMap;
1125  }
1126 
1127  @Override
1128  @SuppressWarnings("unchecked")
1129  public MessageLite.Builder internalMergeFrom(MessageLite.Builder to, MessageLite from) {
1130  return ((Builder) to).mergeFrom((GeneratedMessageLite) from);
1131  }
1132 
1133 
1134  @Override
1135  public int compareTo(ExtensionDescriptor other) {
1136  return number - other.number;
1137  }
1138  }
1139 
1140  // =================================================================
1141 
1143  @SuppressWarnings("unchecked")
1144  static Method getMethodOrDie(Class clazz, String name, Class... params) {
1145  try {
1146  return clazz.getMethod(name, params);
1147  } catch (NoSuchMethodException e) {
1148  throw new RuntimeException(
1149  "Generated message class \"" + clazz.getName() + "\" missing method \"" + name + "\".",
1150  e);
1151  }
1152  }
1153 
1155  static Object invokeOrDie(Method method, Object object, Object... params) {
1156  try {
1157  return method.invoke(object, params);
1158  } catch (IllegalAccessException e) {
1159  throw new RuntimeException(
1160  "Couldn't use Java reflection to implement protocol message reflection.", e);
1161  } catch (InvocationTargetException e) {
1162  final Throwable cause = e.getCause();
1163  if (cause instanceof RuntimeException) {
1164  throw (RuntimeException) cause;
1165  } else if (cause instanceof Error) {
1166  throw (Error) cause;
1167  } else {
1168  throw new RuntimeException(
1169  "Unexpected exception thrown by generated accessor method.", cause);
1170  }
1171  }
1172  }
1173 
1174 
1181  public static class GeneratedExtension<ContainingType extends MessageLite, Type>
1182  extends ExtensionLite<ContainingType, Type> {
1183 
1192  final ContainingType containingTypeDefaultInstance,
1193  final Type defaultValue,
1194  final MessageLite messageDefaultInstance,
1195  final ExtensionDescriptor descriptor,
1196  final Class singularType) {
1197  // Defensive checks to verify the correct initialization order of
1198  // GeneratedExtensions and their related GeneratedMessages.
1199  if (containingTypeDefaultInstance == null) {
1200  throw new IllegalArgumentException("Null containingTypeDefaultInstance");
1201  }
1202  if (descriptor.getLiteType() == WireFormat.FieldType.MESSAGE
1203  && messageDefaultInstance == null) {
1204  throw new IllegalArgumentException("Null messageDefaultInstance");
1205  }
1206  this.containingTypeDefaultInstance = containingTypeDefaultInstance;
1207  this.defaultValue = defaultValue;
1208  this.messageDefaultInstance = messageDefaultInstance;
1209  this.descriptor = descriptor;
1210  }
1211 
1212  final ContainingType containingTypeDefaultInstance;
1213  final Type defaultValue;
1214  final MessageLite messageDefaultInstance;
1215  final ExtensionDescriptor descriptor;
1216 
1218  public ContainingType getContainingTypeDefaultInstance() {
1219  return containingTypeDefaultInstance;
1220  }
1221 
1223  @Override
1224  public int getNumber() {
1225  return descriptor.getNumber();
1226  }
1227 
1232  @Override
1234  return messageDefaultInstance;
1235  }
1236 
1237  @SuppressWarnings("unchecked")
1238  Object fromFieldSetType(final Object value) {
1239  if (descriptor.isRepeated()) {
1240  if (descriptor.getLiteJavaType() == WireFormat.JavaType.ENUM) {
1241  final List result = new ArrayList();
1242  for (final Object element : (List) value) {
1243  result.add(singularFromFieldSetType(element));
1244  }
1245  return result;
1246  } else {
1247  return value;
1248  }
1249  } else {
1250  return singularFromFieldSetType(value);
1251  }
1252  }
1253 
1254  Object singularFromFieldSetType(final Object value) {
1255  if (descriptor.getLiteJavaType() == WireFormat.JavaType.ENUM) {
1256  return descriptor.enumTypeMap.findValueByNumber((Integer) value);
1257  } else {
1258  return value;
1259  }
1260  }
1261 
1262  @SuppressWarnings("unchecked")
1263  Object toFieldSetType(final Object value) {
1264  if (descriptor.isRepeated()) {
1265  if (descriptor.getLiteJavaType() == WireFormat.JavaType.ENUM) {
1266  final List result = new ArrayList();
1267  for (final Object element : (List) value) {
1268  result.add(singularToFieldSetType(element));
1269  }
1270  return result;
1271  } else {
1272  return value;
1273  }
1274  } else {
1275  return singularToFieldSetType(value);
1276  }
1277  }
1278 
1279  Object singularToFieldSetType(final Object value) {
1280  if (descriptor.getLiteJavaType() == WireFormat.JavaType.ENUM) {
1281  return ((Internal.EnumLite) value).getNumber();
1282  } else {
1283  return value;
1284  }
1285  }
1286 
1287  @Override
1289  return descriptor.getLiteType();
1290  }
1291 
1292  @Override
1293  public boolean isRepeated() {
1294  return descriptor.isRepeated;
1295  }
1296 
1297  @Override
1299  return defaultValue;
1300  }
1301  }
1302 
1307  protected static final class SerializedForm implements Serializable {
1308 
1310  return new SerializedForm(message);
1311  }
1312 
1313  private static final long serialVersionUID = 0L;
1314 
1315  // since v3.6.1
1316  private final Class<?> messageClass;
1317  // only included for backwards compatibility before messageClass was added
1318  private final String messageClassName;
1319  private final byte[] asBytes;
1320 
1326  SerializedForm(MessageLite regularForm) {
1327  messageClass = regularForm.getClass();
1328  messageClassName = messageClass.getName();
1329  asBytes = regularForm.toByteArray();
1330  }
1331 
1338  @SuppressWarnings("unchecked")
1339  protected Object readResolve() throws ObjectStreamException {
1340  try {
1341  Class<?> messageClass = resolveMessageClass();
1342  java.lang.reflect.Field defaultInstanceField =
1343  messageClass.getDeclaredField("DEFAULT_INSTANCE");
1344  defaultInstanceField.setAccessible(true);
1345  MessageLite defaultInstance = (MessageLite) defaultInstanceField.get(null);
1346  return defaultInstance.newBuilderForType().mergeFrom(asBytes).buildPartial();
1347  } catch (ClassNotFoundException e) {
1348  throw new RuntimeException("Unable to find proto buffer class: " + messageClassName, e);
1349  } catch (NoSuchFieldException e) {
1350  return readResolveFallback();
1351  } catch (SecurityException e) {
1352  throw new RuntimeException("Unable to call DEFAULT_INSTANCE in " + messageClassName, e);
1353  } catch (IllegalAccessException e) {
1354  throw new RuntimeException("Unable to call parsePartialFrom", e);
1355  } catch (InvalidProtocolBufferException e) {
1356  throw new RuntimeException("Unable to understand proto buffer", e);
1357  }
1358  }
1359 
1363  @Deprecated
1364  private Object readResolveFallback() throws ObjectStreamException {
1365  try {
1366  Class<?> messageClass = resolveMessageClass();
1367  java.lang.reflect.Field defaultInstanceField =
1368  messageClass.getDeclaredField("defaultInstance");
1369  defaultInstanceField.setAccessible(true);
1370  MessageLite defaultInstance = (MessageLite) defaultInstanceField.get(null);
1371  return defaultInstance.newBuilderForType()
1372  .mergeFrom(asBytes)
1373  .buildPartial();
1374  } catch (ClassNotFoundException e) {
1375  throw new RuntimeException("Unable to find proto buffer class: " + messageClassName, e);
1376  } catch (NoSuchFieldException e) {
1377  throw new RuntimeException("Unable to find defaultInstance in " + messageClassName, e);
1378  } catch (SecurityException e) {
1379  throw new RuntimeException("Unable to call defaultInstance in " + messageClassName, e);
1380  } catch (IllegalAccessException e) {
1381  throw new RuntimeException("Unable to call parsePartialFrom", e);
1382  } catch (InvalidProtocolBufferException e) {
1383  throw new RuntimeException("Unable to understand proto buffer", e);
1384  }
1385  }
1386 
1387  private Class<?> resolveMessageClass() throws ClassNotFoundException {
1388  return messageClass != null ? messageClass : Class.forName(messageClassName);
1389  }
1390  }
1391 
1393  private static <
1394  MessageType extends ExtendableMessage<MessageType, BuilderType>,
1395  BuilderType extends ExtendableBuilder<MessageType, BuilderType>,
1396  T>
1398  if (!extension.isLite()) {
1399  throw new IllegalArgumentException("Expected a lite extension.");
1400  }
1401 
1403  }
1404 
1410  protected static final <T extends GeneratedMessageLite<T, ?>> boolean isInitialized(
1411  T message, boolean shouldMemoize) {
1412  byte memoizedIsInitialized =
1413  (Byte) message.dynamicMethod(MethodToInvoke.GET_MEMOIZED_IS_INITIALIZED);
1414  if (memoizedIsInitialized == 1) {
1415  return true;
1416  }
1417  if (memoizedIsInitialized == 0) {
1418  return false;
1419  }
1420  boolean isInitialized = Protobuf.getInstance().schemaFor(message).isInitialized(message);
1421  if (shouldMemoize) {
1422  message.dynamicMethod(
1423  MethodToInvoke.SET_MEMOIZED_IS_INITIALIZED, isInitialized ? message : null);
1424  }
1425  return isInitialized;
1426  }
1427 
1428  protected static IntList emptyIntList() {
1429  return IntArrayList.emptyList();
1430  }
1431 
1432  protected static IntList mutableCopy(IntList list) {
1433  int size = list.size();
1434  return list.mutableCopyWithCapacity(
1435  size == 0 ? AbstractProtobufList.DEFAULT_CAPACITY : size * 2);
1436  }
1437 
1438  protected static LongList emptyLongList() {
1439  return LongArrayList.emptyList();
1440  }
1441 
1442  protected static LongList mutableCopy(LongList list) {
1443  int size = list.size();
1444  return list.mutableCopyWithCapacity(
1445  size == 0 ? AbstractProtobufList.DEFAULT_CAPACITY : size * 2);
1446  }
1447 
1448  protected static FloatList emptyFloatList() {
1449  return FloatArrayList.emptyList();
1450  }
1451 
1452  protected static FloatList mutableCopy(FloatList list) {
1453  int size = list.size();
1454  return list.mutableCopyWithCapacity(
1455  size == 0 ? AbstractProtobufList.DEFAULT_CAPACITY : size * 2);
1456  }
1457 
1458  protected static DoubleList emptyDoubleList() {
1459  return DoubleArrayList.emptyList();
1460  }
1461 
1462  protected static DoubleList mutableCopy(DoubleList list) {
1463  int size = list.size();
1464  return list.mutableCopyWithCapacity(
1465  size == 0 ? AbstractProtobufList.DEFAULT_CAPACITY : size * 2);
1466  }
1467 
1468  protected static BooleanList emptyBooleanList() {
1469  return BooleanArrayList.emptyList();
1470  }
1471 
1472  protected static BooleanList mutableCopy(BooleanList list) {
1473  int size = list.size();
1474  return list.mutableCopyWithCapacity(
1475  size == 0 ? AbstractProtobufList.DEFAULT_CAPACITY : size * 2);
1476  }
1477 
1478  protected static <E> ProtobufList<E> emptyProtobufList() {
1479  return ProtobufArrayList.emptyList();
1480  }
1481 
1482  protected static <E> ProtobufList<E> mutableCopy(ProtobufList<E> list) {
1483  int size = list.size();
1484  return list.mutableCopyWithCapacity(
1485  size == 0 ? AbstractProtobufList.DEFAULT_CAPACITY : size * 2);
1486  }
1487 
1493  protected static class DefaultInstanceBasedParser<T extends GeneratedMessageLite<T, ?>>
1494  extends AbstractParser<T> {
1495 
1496  private final T defaultInstance;
1497 
1499  this.defaultInstance = defaultInstance;
1500  }
1501 
1502  @Override
1505  return GeneratedMessageLite.parsePartialFrom(defaultInstance, input, extensionRegistry);
1506  }
1507 
1508  @Override
1510  byte[] input, int offset, int length, ExtensionRegistryLite extensionRegistry)
1512  return GeneratedMessageLite.parsePartialFrom(
1513  defaultInstance, input, offset, length, extensionRegistry);
1514  }
1515  }
1516 
1521  // TODO(dweis): Should this verify that the last tag was 0?
1522  static <T extends GeneratedMessageLite<T, ?>> T parsePartialFrom(
1523  T instance, CodedInputStream input, ExtensionRegistryLite extensionRegistry)
1525  @SuppressWarnings("unchecked") // Guaranteed by protoc
1526  T result = (T) instance.dynamicMethod(MethodToInvoke.NEW_MUTABLE_INSTANCE);
1527  try {
1528  // TODO(yilunchong): Try to make input with type CodedInpuStream.ArrayDecoder use
1529  // fast path.
1530  Schema<T> schema = Protobuf.getInstance().schemaFor(result);
1531  schema.mergeFrom(result, CodedInputStreamReader.forCodedInput(input), extensionRegistry);
1532  schema.makeImmutable(result);
1533  } catch (IOException e) {
1534  if (e.getCause() instanceof InvalidProtocolBufferException) {
1535  throw (InvalidProtocolBufferException) e.getCause();
1536  }
1537  throw new InvalidProtocolBufferException(e.getMessage()).setUnfinishedMessage(result);
1538  } catch (RuntimeException e) {
1539  if (e.getCause() instanceof InvalidProtocolBufferException) {
1540  throw (InvalidProtocolBufferException) e.getCause();
1541  }
1542  throw e;
1543  }
1544  return result;
1545  }
1546 
1548  static <T extends GeneratedMessageLite<T, ?>> T parsePartialFrom(
1549  T instance, byte[] input, int offset, int length, ExtensionRegistryLite extensionRegistry)
1550  throws InvalidProtocolBufferException {
1551  @SuppressWarnings("unchecked") // Guaranteed by protoc
1552  T result = (T) instance.dynamicMethod(MethodToInvoke.NEW_MUTABLE_INSTANCE);
1553  try {
1554  Schema<T> schema = Protobuf.getInstance().schemaFor(result);
1555  schema.mergeFrom(
1556  result, input, offset, offset + length, new ArrayDecoders.Registers(extensionRegistry));
1557  schema.makeImmutable(result);
1558  if (result.memoizedHashCode != 0) {
1559  throw new RuntimeException();
1560  }
1561  } catch (IOException e) {
1562  if (e.getCause() instanceof InvalidProtocolBufferException) {
1563  throw (InvalidProtocolBufferException) e.getCause();
1564  }
1565  throw new InvalidProtocolBufferException(e.getMessage()).setUnfinishedMessage(result);
1566  } catch (IndexOutOfBoundsException e) {
1567  throw InvalidProtocolBufferException.truncatedMessage().setUnfinishedMessage(result);
1568  }
1569  return result;
1570  }
1571 
1572  protected static <T extends GeneratedMessageLite<T, ?>> T parsePartialFrom(
1573  T defaultInstance, CodedInputStream input) throws InvalidProtocolBufferException {
1574  return parsePartialFrom(defaultInstance, input, ExtensionRegistryLite.getEmptyRegistry());
1575  }
1576 
1583  private static <T extends GeneratedMessageLite<T, ?>> T checkMessageInitialized(T message)
1585  if (message != null && !message.isInitialized()) {
1586  throw message
1587  .newUninitializedMessageException()
1588  .asInvalidProtocolBufferException()
1590  }
1591  return message;
1592  }
1593 
1594  // Validates last tag.
1595  protected static <T extends GeneratedMessageLite<T, ?>> T parseFrom(
1596  T defaultInstance, ByteBuffer data, ExtensionRegistryLite extensionRegistry)
1598  return checkMessageInitialized(
1599  parseFrom(defaultInstance, CodedInputStream.newInstance(data), extensionRegistry));
1600  }
1601 
1602  // Validates last tag.
1603  protected static <T extends GeneratedMessageLite<T, ?>> T parseFrom(
1604  T defaultInstance, ByteBuffer data) throws InvalidProtocolBufferException {
1605  return parseFrom(defaultInstance, data, ExtensionRegistryLite.getEmptyRegistry());
1606  }
1607 
1608  // Validates last tag.
1609  protected static <T extends GeneratedMessageLite<T, ?>> T parseFrom(
1610  T defaultInstance, ByteString data) throws InvalidProtocolBufferException {
1611  return checkMessageInitialized(
1612  parseFrom(defaultInstance, data, ExtensionRegistryLite.getEmptyRegistry()));
1613  }
1614 
1615  // Validates last tag.
1616  protected static <T extends GeneratedMessageLite<T, ?>> T parseFrom(
1617  T defaultInstance, ByteString data, ExtensionRegistryLite extensionRegistry)
1619  return checkMessageInitialized(parsePartialFrom(defaultInstance, data, extensionRegistry));
1620  }
1621 
1622  // This is a special case since we want to verify that the last tag is 0. We assume we exhaust the
1623  // ByteString.
1624  private static <T extends GeneratedMessageLite<T, ?>> T parsePartialFrom(
1625  T defaultInstance, ByteString data, ExtensionRegistryLite extensionRegistry)
1627  T message;
1628  try {
1629  CodedInputStream input = data.newCodedInput();
1630  message = parsePartialFrom(defaultInstance, input, extensionRegistry);
1631  try {
1632  input.checkLastTagWas(0);
1633  } catch (InvalidProtocolBufferException e) {
1634  throw e.setUnfinishedMessage(message);
1635  }
1636  return message;
1637  } catch (InvalidProtocolBufferException e) {
1638  throw e;
1639  }
1640  }
1641 
1642  // This is a special case since we want to verify that the last tag is 0. We assume we exhaust the
1643  // ByteString.
1644  private static <T extends GeneratedMessageLite<T, ?>> T parsePartialFrom(
1645  T defaultInstance, byte[] data, ExtensionRegistryLite extensionRegistry)
1647  return checkMessageInitialized(
1648  parsePartialFrom(defaultInstance, data, 0, data.length, extensionRegistry));
1649  }
1650 
1651  // Validates last tag.
1652  protected static <T extends GeneratedMessageLite<T, ?>> T parseFrom(
1653  T defaultInstance, byte[] data) throws InvalidProtocolBufferException {
1654  return checkMessageInitialized(parsePartialFrom(
1655  defaultInstance, data, 0, data.length, ExtensionRegistryLite.getEmptyRegistry()));
1656  }
1657 
1658  // Validates last tag.
1659  protected static <T extends GeneratedMessageLite<T, ?>> T parseFrom(
1660  T defaultInstance, byte[] data, ExtensionRegistryLite extensionRegistry)
1662  return checkMessageInitialized(
1663  parsePartialFrom(defaultInstance, data, 0, data.length, extensionRegistry));
1664  }
1665 
1666  // Does not validate last tag.
1667  protected static <T extends GeneratedMessageLite<T, ?>> T parseFrom(
1668  T defaultInstance, InputStream input) throws InvalidProtocolBufferException {
1669  return checkMessageInitialized(
1670  parsePartialFrom(
1671  defaultInstance,
1674  }
1675 
1676  // Does not validate last tag.
1677  protected static <T extends GeneratedMessageLite<T, ?>> T parseFrom(
1678  T defaultInstance, InputStream input, ExtensionRegistryLite extensionRegistry)
1680  return checkMessageInitialized(
1681  parsePartialFrom(defaultInstance, CodedInputStream.newInstance(input), extensionRegistry));
1682  }
1683 
1684  // Does not validate last tag.
1685  protected static <T extends GeneratedMessageLite<T, ?>> T parseFrom(
1686  T defaultInstance, CodedInputStream input) throws InvalidProtocolBufferException {
1687  return parseFrom(defaultInstance, input, ExtensionRegistryLite.getEmptyRegistry());
1688  }
1689 
1690  // Does not validate last tag.
1691  protected static <T extends GeneratedMessageLite<T, ?>> T parseFrom(
1692  T defaultInstance, CodedInputStream input, ExtensionRegistryLite extensionRegistry)
1694  return checkMessageInitialized(parsePartialFrom(defaultInstance, input, extensionRegistry));
1695  }
1696 
1697  // Validates last tag.
1698  protected static <T extends GeneratedMessageLite<T, ?>> T parseDelimitedFrom(
1699  T defaultInstance, InputStream input) throws InvalidProtocolBufferException {
1700  return checkMessageInitialized(
1702  defaultInstance, input, ExtensionRegistryLite.getEmptyRegistry()));
1703  }
1704 
1705  // Validates last tag.
1706  protected static <T extends GeneratedMessageLite<T, ?>> T parseDelimitedFrom(
1707  T defaultInstance, InputStream input, ExtensionRegistryLite extensionRegistry)
1709  return checkMessageInitialized(
1710  parsePartialDelimitedFrom(defaultInstance, input, extensionRegistry));
1711  }
1712 
1713  private static <T extends GeneratedMessageLite<T, ?>> T parsePartialDelimitedFrom(
1714  T defaultInstance, InputStream input, ExtensionRegistryLite extensionRegistry)
1716  int size;
1717  try {
1718  int firstByte = input.read();
1719  if (firstByte == -1) {
1720  return null;
1721  }
1723  } catch (IOException e) {
1724  throw new InvalidProtocolBufferException(e.getMessage());
1725  }
1726  InputStream limitedInput = new LimitedInputStream(input, size);
1727  CodedInputStream codedInput = CodedInputStream.newInstance(limitedInput);
1728  T message = parsePartialFrom(defaultInstance, codedInput, extensionRegistry);
1729  try {
1730  codedInput.checkLastTagWas(0);
1731  } catch (InvalidProtocolBufferException e) {
1732  throw e.setUnfinishedMessage(message);
1733  }
1734  return message;
1735  }
1736 }
Map
struct Map Map
Definition: php/ext/google/protobuf/protobuf.h:648
com.google.protobuf.GeneratedMessageLite.GeneratedExtension.getMessageDefaultInstance
MessageLite getMessageDefaultInstance()
Definition: GeneratedMessageLite.java:1233
com.google.protobuf.GeneratedMessageLite.makeImmutable
void makeImmutable()
Definition: GeneratedMessageLite.java:169
com.google.protobuf.Internal.FloatList.mutableCopyWithCapacity
FloatList mutableCopyWithCapacity(int capacity)
java::lang
name
GLuint const GLchar * name
Definition: glcorearb.h:3055
com.google.protobuf.GeneratedMessageLite.Builder.clear
final BuilderType clear()
Definition: GeneratedMessageLite.java:367
com.google.protobuf.GeneratedMessageLite.getSerializedSize
int getSerializedSize()
Definition: GeneratedMessageLite.java:270
java::lang::reflect::Method
google::protobuf::EnumValueDescriptor::type
const EnumDescriptor * type() const
com.google.protobuf.GeneratedMessageLite.checkMessageInitialized
static< T extends GeneratedMessageLite< T, ?> T checkMessageInitialized(T message)
Definition: GeneratedMessageLite.java:1583
com.google.protobuf.GeneratedMessageLite.SerializedForm.of
static SerializedForm of(MessageLite message)
Definition: GeneratedMessageLite.java:1309
com.google.protobuf.GeneratedMessageLite.ExtendableBuilder.copyOnWrite
void copyOnWrite()
Definition: GeneratedMessageLite.java:922
com.google.protobuf.GeneratedMessageLite.parseFrom
static< T extends GeneratedMessageLite< T, ?> T parseFrom(T defaultInstance, byte[] data)
Definition: GeneratedMessageLite.java:1652
com.google.protobuf.Internal.ProtobufList.mutableCopyWithCapacity
ProtobufList< E > mutableCopyWithCapacity(int capacity)
com.google.protobuf.AbstractMessageLite< MessageType, BuilderType >::memoizedHashCode
int memoizedHashCode
Definition: AbstractMessageLite.java:53
com.google.protobuf.GeneratedMessageLite.mutableCopy
static BooleanList mutableCopy(BooleanList list)
Definition: GeneratedMessageLite.java:1472
com.google.protobuf.GeneratedMessageLite.parseFrom
static< T extends GeneratedMessageLite< T, ?> T parseFrom(T defaultInstance, ByteString data, ExtensionRegistryLite extensionRegistry)
Definition: GeneratedMessageLite.java:1616
com.google.protobuf.GeneratedMessageLite.MethodToInvoke.SET_MEMOIZED_IS_INITIALIZED
SET_MEMOIZED_IS_INITIALIZED
Definition: GeneratedMessageLite.java:209
com.google.protobuf.GeneratedMessageLite.ExtendableBuilder.verifyExtensionContainingType
void verifyExtensionContainingType(final GeneratedExtension< MessageType, ?> extension)
Definition: GeneratedMessageLite.java:950
google::protobuf::extension
const Descriptor::ReservedRange const EnumValueDescriptor const MethodDescriptor extension
Definition: src/google/protobuf/descriptor.h:2001
end
GLuint GLuint end
Definition: glcorearb.h:2858
com.google.protobuf.GeneratedMessageLite.isInitialized
final boolean isInitialized()
Definition: GeneratedMessageLite.java:188
com.google.protobuf.WireFormat.JavaType.MESSAGE
MESSAGE
Definition: WireFormat.java:93
com.google.protobuf.GeneratedMessageLite.MethodToInvoke.BUILD_MESSAGE_INFO
BUILD_MESSAGE_INFO
Definition: GeneratedMessageLite.java:212
com.google.protobuf.CodedInputStream.newInstance
static CodedInputStream newInstance(final InputStream input)
Definition: CodedInputStream.java:79
com.google.protobuf.Internal.EnumLiteMap
Definition: Internal.java:210
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.ExtensionWriter.messageSetWireFormat
final boolean messageSetWireFormat
Definition: GeneratedMessageLite.java:858
src
GLenum src
Definition: glcorearb.h:3364
com.google.protobuf.GeneratedMessageLite.parsePartialFrom
static< T extends GeneratedMessageLite< T, ?> T parsePartialFrom(T defaultInstance, ByteString data, ExtensionRegistryLite extensionRegistry)
Definition: GeneratedMessageLite.java:1624
com.google.protobuf.GeneratedMessageLite.DefaultInstanceBasedParser.parsePartialFrom
T parsePartialFrom(byte[] input, int offset, int length, ExtensionRegistryLite extensionRegistry)
Definition: GeneratedMessageLite.java:1509
com.google.protobuf.GeneratedMessageLite.newMessageInfo
static Object newMessageInfo(MessageLite defaultInstance, String info, Object[] objects)
Definition: GeneratedMessageLite.java:316
com.google.protobuf.GeneratedMessageLite
Definition: GeneratedMessageLite.java:60
com.google.protobuf.GeneratedMessageLite.getParserForType
final Parser< MessageType > getParserForType()
Definition: GeneratedMessageLite.java:73
length
GLenum GLuint GLenum GLsizei length
Definition: glcorearb.h:2695
com.google.protobuf.GeneratedMessageLite.GeneratedExtension.isRepeated
boolean isRepeated()
Definition: GeneratedMessageLite.java:1293
input
std::string input
Definition: tokenizer_unittest.cc:197
com.google.protobuf.GeneratedMessageLite.SerializedForm.messageClass
final Class<?> messageClass
Definition: GeneratedMessageLite.java:1316
com.google.protobuf.GeneratedMessageLite.MethodToInvoke.GET_PARSER
GET_PARSER
Definition: GeneratedMessageLite.java:216
com.google.protobuf.MessageLiteOrBuilder
Definition: MessageLiteOrBuilder.java:39
com.google.protobuf.UnknownFieldSetLite
Definition: UnknownFieldSetLite.java:46
com.google.protobuf.GeneratedMessageLite.Builder.copyOnWrite
void copyOnWrite()
Definition: GeneratedMessageLite.java:351
com.google.protobuf.Internal.LongList.mutableCopyWithCapacity
LongList mutableCopyWithCapacity(int capacity)
com.google.protobuf.GeneratedMessageLite.unknownFields
UnknownFieldSetLite unknownFields
Definition: GeneratedMessageLite.java:66
com.google.protobuf.GeneratedMessageLite.parsePartialFrom
static< T extends GeneratedMessageLite< T, ?> T parsePartialFrom(T defaultInstance, CodedInputStream input)
Definition: GeneratedMessageLite.java:1572
com.google.protobuf.FieldType
Definition: FieldType.java:41
com.google.protobuf.GeneratedMessageLite.mutableCopy
static DoubleList mutableCopy(DoubleList list)
Definition: GeneratedMessageLite.java:1462
com.google.protobuf.GeneratedMessageLite.DefaultInstanceBasedParser
Definition: GeneratedMessageLite.java:1493
com.google.protobuf.GeneratedMessageLite.parseFrom
static< T extends GeneratedMessageLite< T, ?> T parseFrom(T defaultInstance, ByteBuffer data, ExtensionRegistryLite extensionRegistry)
Definition: GeneratedMessageLite.java:1595
com.google.protobuf.CodedInputStream.checkLastTagWas
abstract void checkLastTagWas(final int value)
com.google.protobuf.GeneratedMessageLite.newSingularGeneratedExtension
static< ContainingType extends MessageLite, Type > GeneratedExtension< ContainingType, Type > newSingularGeneratedExtension(final ContainingType containingTypeDefaultInstance, final Type defaultValue, final MessageLite messageDefaultInstance, final Internal.EnumLiteMap<?> enumTypeMap, final int number, final WireFormat.FieldType type, final Class singularType)
Definition: GeneratedMessageLite.java:1039
com.google.protobuf.GeneratedMessageLite.registerDefaultInstance
static< T extends GeneratedMessageLite<?, ?> void registerDefaultInstance(Class< T > clazz, T defaultInstance)
Definition: GeneratedMessageLite.java:311
com.google.protobuf
Definition: ProtoCaliperBenchmark.java:2
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.ExtensionWriter.iter
final Iterator< Map.Entry< ExtensionDescriptor, Object > > iter
Definition: GeneratedMessageLite.java:856
com.google.protobuf.GeneratedMessageLite.Builder.mergeFrom
BuilderType mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
Definition: GeneratedMessageLite.java:449
descriptor
Descriptor * descriptor
Definition: php/ext/google/protobuf/protobuf.h:936
java::lang::reflect
com.google.protobuf.WireFormat
Definition: WireFormat.java:45
com.google.protobuf.GeneratedMessage.GeneratedExtension
Definition: GeneratedMessage.java:1757
com.google.protobuf.Descriptors.FieldDescriptor.Type
Definition: Descriptors.java:1215
com.google.protobuf.GeneratedMessageLite.ExtendableBuilder.setExtension
final< Type > BuilderType setExtension(final ExtensionLite< MessageType, Type > extension, final Type value)
Definition: GeneratedMessageLite.java:988
T
#define T(upbtypeconst, upbtype, ctype, default_value)
com.google.protobuf.GeneratedMessageLite.createBuilder
final< MessageType extends GeneratedMessageLite< MessageType, BuilderType >, BuilderType extends GeneratedMessageLite.Builder< MessageType, BuilderType > > BuilderType createBuilder()
Definition: GeneratedMessageLite.java:176
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.getExtensionCount
final< Type > int getExtensionCount(final ExtensionLite< MessageType, List< Type >> extension)
Definition: GeneratedMessageLite.java:806
com.google.protobuf.GeneratedMessageLite.Builder.defaultInstance
final MessageType defaultInstance
Definition: GeneratedMessageLite.java:336
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.ExtensionWriter.writeUntil
void writeUntil(final int end, final CodedOutputStream output)
Definition: GeneratedMessageLite.java:867
com.google.protobuf.GeneratedMessageLite.mergeVarintField
void mergeVarintField(int tag, int value)
Definition: GeneratedMessageLite.java:157
com.google.protobuf.GeneratedMessageLite.parseFrom
static< T extends GeneratedMessageLite< T, ?> T parseFrom(T defaultInstance, InputStream input)
Definition: GeneratedMessageLite.java:1667
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.extensionsAreInitialized
boolean extensionsAreInitialized()
Definition: GeneratedMessageLite.java:843
com.google.protobuf.GeneratedMessageLite.Builder.mergeFrom
BuilderType mergeFrom(byte[] input, int offset, int length, ExtensionRegistryLite extensionRegistry)
Definition: GeneratedMessageLite.java:423
com.google.protobuf.GeneratedMessageLite.parseDelimitedFrom
static< T extends GeneratedMessageLite< T, ?> T parseDelimitedFrom(T defaultInstance, InputStream input)
Definition: GeneratedMessageLite.java:1698
com.google.protobuf.GeneratedMessageLite.MethodToInvoke.GET_MEMOIZED_IS_INITIALIZED
GET_MEMOIZED_IS_INITIALIZED
Definition: GeneratedMessageLite.java:208
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.hasExtension
final< Type > boolean hasExtension(final ExtensionLite< MessageType, Type > extension)
Definition: GeneratedMessageLite.java:797
com.google.protobuf.GeneratedMessageLite.SerializedForm.messageClassName
final String messageClassName
Definition: GeneratedMessageLite.java:1318
com.google.protobuf.Internal.LongList
Definition: Internal.java:631
com.google.protobuf.GeneratedMessageLite.ExtendableBuilder.ExtendableBuilder
ExtendableBuilder(MessageType defaultInstance)
Definition: GeneratedMessageLite.java:911
com.google.protobuf.GeneratedMessageLite.mergeUnknownFields
final void mergeUnknownFields(UnknownFieldSetLite unknownFields)
Definition: GeneratedMessageLite.java:326
com.google.protobuf.GeneratedMessageLite.toString
String toString()
Definition: GeneratedMessageLite.java:102
com.google.protobuf.GeneratedMessageLite.ExtendableBuilder.getExtensionCount
final< Type > int getExtensionCount(final ExtensionLite< MessageType, List< Type >> extension)
Definition: GeneratedMessageLite.java:967
com.google.protobuf.GeneratedMessageLite.toBuilder
final BuilderType toBuilder()
Definition: GeneratedMessageLite.java:194
com.google.protobuf.GeneratedMessageLite.MethodToInvoke.NEW_BUILDER
NEW_BUILDER
Definition: GeneratedMessageLite.java:214
com.google.protobuf.GeneratedMessageLite.writeTo
void writeTo(CodedOutputStream output)
Definition: GeneratedMessageLite.java:264
com.google.protobuf.GeneratedMessageLite.mutableCopy
static FloatList mutableCopy(FloatList list)
Definition: GeneratedMessageLite.java:1452
com.google.protobuf.Parser
Definition: Parser.java:47
com.google.protobuf.WireFormat.JavaType.ENUM
ENUM
Definition: WireFormat.java:92
com.google.protobuf.GeneratedMessageLite.emptyFloatList
static FloatList emptyFloatList()
Definition: GeneratedMessageLite.java:1448
com.google.protobuf.GeneratedMessageLite.ExtendableMessage
Definition: GeneratedMessageLite.java:493
com.google.protobuf.GeneratedMessageLite.mutableCopy
static< E > ProtobufList< E > mutableCopy(ProtobufList< E > list)
Definition: GeneratedMessageLite.java:1482
com.google.protobuf.CodedInputStream
Definition: CodedInputStream.java:61
com.google.protobuf.GeneratedMessageLite.ExtendableBuilder.buildPartial
final MessageType buildPartial()
Definition: GeneratedMessageLite.java:941
com.google.protobuf.AbstractMessageLite.Builder
Definition: AbstractMessageLite.java:154
com.google.protobuf.GeneratedMessageLite.ExtendableBuilder.setExtension
final< Type > BuilderType setExtension(final ExtensionLite< MessageType, List< Type >> extension, final int index, final Type value)
Definition: GeneratedMessageLite.java:1000
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.mergeMessageSetExtensionFromBytes
void mergeMessageSetExtensionFromBytes(ByteString rawBytes, ExtensionRegistryLite extensionRegistry, GeneratedExtension<?, ?> extension)
Definition: GeneratedMessageLite.java:759
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.parseExtension
boolean parseExtension(CodedInputStream input, ExtensionRegistryLite extensionRegistry, GeneratedExtension<?, ?> extension, int tag, int fieldNumber)
Definition: GeneratedMessageLite.java:533
com.google.protobuf.Internal.FloatList
Definition: Internal.java:671
com.google.protobuf.UnknownFieldSetLite.getDefaultInstance
static UnknownFieldSetLite getDefaultInstance()
Definition: UnknownFieldSetLite.java:60
com.google.protobuf.MessageLite.Builder.buildPartial
MessageLite buildPartial()
com.google.protobuf.GeneratedMessageLite.Builder.mergeFrom
BuilderType mergeFrom(MessageType message)
Definition: GeneratedMessageLite.java:407
offset
GLintptr offset
Definition: glcorearb.h:2944
com.google.protobuf.GeneratedMessageLite.SerializedForm.readResolve
Object readResolve()
Definition: GeneratedMessageLite.java:1339
com.google.protobuf.GeneratedMessageLite.Builder.getDefaultInstanceForType
MessageType getDefaultInstanceForType()
Definition: GeneratedMessageLite.java:418
com.google.protobuf.GeneratedMessageLite.parseUnknownField
boolean parseUnknownField(int tag, CodedInputStream input)
Definition: GeneratedMessageLite.java:146
com.google.protobuf.GeneratedMessageLite.parseFrom
static< T extends GeneratedMessageLite< T, ?> T parseFrom(T defaultInstance, byte[] data, ExtensionRegistryLite extensionRegistry)
Definition: GeneratedMessageLite.java:1659
com.google.protobuf.GeneratedMessageLite.parseFrom
static< T extends GeneratedMessageLite< T, ?> T parseFrom(T defaultInstance, CodedInputStream input)
Definition: GeneratedMessageLite.java:1685
com.google.protobuf.GeneratedMessageLite.emptyIntList
static IntList emptyIntList()
Definition: GeneratedMessageLite.java:1428
com.google.protobuf.GeneratedMessageLite.SerializedForm.readResolveFallback
Object readResolveFallback()
Definition: GeneratedMessageLite.java:1364
com.google.protobuf.GeneratedMessageLite.ExtendableBuilder.clearExtension
final< Type > BuilderType clearExtension(final ExtensionLite< MessageType, ?> extension)
Definition: GeneratedMessageLite.java:1025
com.google.protobuf.GeneratedMessageLite.MethodToInvoke.NEW_MUTABLE_INSTANCE
NEW_MUTABLE_INSTANCE
Definition: GeneratedMessageLite.java:213
com.google.protobuf.GeneratedMessageLite.Builder.internalMergeFrom
BuilderType internalMergeFrom(MessageType message)
Definition: GeneratedMessageLite.java:402
com.google.protobuf.GeneratedMessageLite.parseFrom
static< T extends GeneratedMessageLite< T, ?> T parseFrom(T defaultInstance, ByteString data)
Definition: GeneratedMessageLite.java:1609
com.google.protobuf.AbstractMessageLite
Definition: AbstractMessageLite.java:49
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.extensionsSerializedSizeAsMessageSet
int extensionsSerializedSizeAsMessageSet()
Definition: GeneratedMessageLite.java:899
com.google.protobuf.GeneratedMessageLite.ExtendableMessageOrBuilder.hasExtension
< Type > boolean hasExtension(ExtensionLite< MessageType, Type > extension)
com.google.protobuf.WireFormat.FieldType.GROUP
GROUP
Definition: WireFormat.java:126
com.google.protobuf.GeneratedMessageLite.ExtendableMessageOrBuilder
Definition: GeneratedMessageLite.java:474
com.google.protobuf.GeneratedMessageLite.SerializedForm.serialVersionUID
static final long serialVersionUID
Definition: GeneratedMessageLite.java:1313
size
#define size
Definition: glcorearb.h:2944
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.mergeExtensionFields
final void mergeExtensionFields(final MessageType other)
Definition: GeneratedMessageLite.java:503
com.google.protobuf.GeneratedMessageLite.ExtendableBuilder.hasExtension
final< Type > boolean hasExtension(final ExtensionLite< MessageType, Type > extension)
Definition: GeneratedMessageLite.java:961
params
GLenum const GLfloat * params
Definition: glcorearb.h:2770
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.eagerlyMergeMessageSetExtension
void eagerlyMergeMessageSetExtension(CodedInputStream input, GeneratedExtension<?, ?> extension, ExtensionRegistryLite extensionRegistry, int typeId)
Definition: GeneratedMessageLite.java:748
com.google.protobuf.GeneratedMessageLite.defaultInstanceMap
static Map< Object, GeneratedMessageLite<?, ?> > defaultInstanceMap
Definition: GeneratedMessageLite.java:282
com.google.protobuf.GeneratedMessageLite.Builder.build
final MessageType build()
Definition: GeneratedMessageLite.java:393
com.google.protobuf.MessageLite.Builder
Definition: MessageLite.java:133
com.google.protobuf.ExtensionRegistryLite
Definition: ExtensionRegistryLite.java:70
com.google.protobuf.Internal.BooleanList
Definition: Internal.java:611
com.google.protobuf.GeneratedMessageLite.emptyBooleanList
static BooleanList emptyBooleanList()
Definition: GeneratedMessageLite.java:1468
com.google.protobuf.WireFormat.WIRETYPE_END_GROUP
static final int WIRETYPE_END_GROUP
Definition: WireFormat.java:59
com.google.protobuf.GeneratedMessageLite.hashCode
int hashCode()
Definition: GeneratedMessageLite.java:108
com.google.protobuf.GeneratedMessageLite.Builder.isBuilt
boolean isBuilt
Definition: GeneratedMessageLite.java:338
com.google.protobuf.GeneratedMessageLite.parseFrom
static< T extends GeneratedMessageLite< T, ?> T parseFrom(T defaultInstance, InputStream input, ExtensionRegistryLite extensionRegistry)
Definition: GeneratedMessageLite.java:1677
com.google.protobuf.MessageLite.newBuilderForType
Builder newBuilderForType()
com.google.protobuf.GeneratedMessageLite.Builder.buildPartial
MessageType buildPartial()
Definition: GeneratedMessageLite.java:381
com.google.protobuf.GeneratedMessageLite.Builder.mergeFrom
BuilderType mergeFrom(byte[] input, int offset, int length)
Definition: GeneratedMessageLite.java:442
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.ExtensionWriter
Definition: GeneratedMessageLite.java:852
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.newMessageSetExtensionWriter
ExtensionWriter newMessageSetExtensionWriter()
Definition: GeneratedMessageLite.java:890
com.google.protobuf.GeneratedMessageLite.dynamicMethod
Object dynamicMethod(MethodToInvoke method, Object arg0)
Definition: GeneratedMessageLite.java:245
com.google.protobuf.GeneratedMessageLite.parseFrom
static< T extends GeneratedMessageLite< T, ?> T parseFrom(T defaultInstance, ByteBuffer data)
Definition: GeneratedMessageLite.java:1603
com.google.protobuf.GeneratedMessageLite.ExtendableMessageOrBuilder.getExtension
< Type > Type getExtension(ExtensionLite< MessageType, Type > extension)
Builder
Definition: ruby/ext/google/protobuf_c/protobuf.h:162
com.google.protobuf.GeneratedMessageLite.parsePartialDelimitedFrom
static< T extends GeneratedMessageLite< T, ?> T parsePartialDelimitedFrom(T defaultInstance, InputStream input, ExtensionRegistryLite extensionRegistry)
Definition: GeneratedMessageLite.java:1713
com.google.protobuf.GeneratedMessageLite.createBuilder
final< MessageType extends GeneratedMessageLite< MessageType, BuilderType >, BuilderType extends GeneratedMessageLite.Builder< MessageType, BuilderType > > BuilderType createBuilder(MessageType prototype)
Definition: GeneratedMessageLite.java:183
com.google.protobuf.GeneratedMessageLite.memoizedSerializedSize
int memoizedSerializedSize
Definition: GeneratedMessageLite.java:69
com.google.protobuf.GeneratedMessageLite.ExtendableMessageOrBuilder.getExtensionCount
< Type > int getExtensionCount(ExtensionLite< MessageType, List< Type >> extension)
com.google.protobuf.AbstractMessageLite.Builder.LimitedInputStream
Definition: AbstractMessageLite.java:270
java
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.ExtensionWriter.ExtensionWriter
ExtensionWriter(boolean messageSetWireFormat)
Definition: GeneratedMessageLite.java:860
type
GLenum type
Definition: glcorearb.h:2695
com.google.protobuf.GeneratedMessageLite.GeneratedExtension.getNumber
int getNumber()
Definition: GeneratedMessageLite.java:1224
com.google.protobuf.GeneratedMessageLite.emptyProtobufList
static< E > ProtobufList< E > emptyProtobufList()
Definition: GeneratedMessageLite.java:1478
com.google.protobuf.WireFormat.WIRETYPE_LENGTH_DELIMITED
static final int WIRETYPE_LENGTH_DELIMITED
Definition: WireFormat.java:57
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.extensionsSerializedSize
int extensionsSerializedSize()
Definition: GeneratedMessageLite.java:895
com.google.protobuf.GeneratedMessageLite.GeneratedExtension.getLiteType
FieldType getLiteType()
Definition: GeneratedMessageLite.java:1288
com.google.protobuf.WireFormat.getTagWireType
static int getTagWireType(final int tag)
Definition: WireFormat.java:66
com.google.protobuf.GeneratedMessageLite.ExtendableBuilder
Definition: GeneratedMessageLite.java:906
com.google.protobuf.MessageLite.toBuilder
Builder toBuilder()
com.google.protobuf.Internal.BooleanList.mutableCopyWithCapacity
BooleanList mutableCopyWithCapacity(int capacity)
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.ExtensionWriter.next
Map.Entry< ExtensionDescriptor, Object > next
Definition: GeneratedMessageLite.java:857
com.google.protobuf.GeneratedMessageLite.equals
boolean equals(Object other)
Definition: GeneratedMessageLite.java:118
com.google.protobuf.GeneratedMessageLite.dynamicMethod
Object dynamicMethod(MethodToInvoke method)
Definition: GeneratedMessageLite.java:250
com.google.protobuf.Internal.ProtobufList
Definition: Internal.java:570
com.google.protobuf.GeneratedMessageLite.SerializedForm.asBytes
final byte[] asBytes
Definition: GeneratedMessageLite.java:1319
benchmarks.python.py_benchmark.dest
dest
Definition: py_benchmark.py:13
size
GLsizeiptr size
Definition: glcorearb.h:2943
com.google.protobuf.GeneratedMessageLite.mutableCopy
static LongList mutableCopy(LongList list)
Definition: GeneratedMessageLite.java:1442
com.google.protobuf.GeneratedMessageLite.ExtendableBuilder.addExtension
final< Type > BuilderType addExtension(final ExtensionLite< MessageType, List< Type >> extension, final Type value)
Definition: GeneratedMessageLite.java:1013
com.google.protobuf.GeneratedMessageLite.getDefaultInstanceForType
final MessageType getDefaultInstanceForType()
Definition: GeneratedMessageLite.java:79
com.google.protobuf.GeneratedMessageLite.SerializedForm.resolveMessageClass
Class<?> resolveMessageClass()
Definition: GeneratedMessageLite.java:1387
com.google.protobuf.GeneratedMessageLite.parseFrom
static< T extends GeneratedMessageLite< T, ?> T parseFrom(T defaultInstance, CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Definition: GeneratedMessageLite.java:1691
com.google.protobuf.GeneratedMessageLite.isInitialized
static final< T extends GeneratedMessageLite< T, ?> > boolean isInitialized(T message, boolean shouldMemoize)
Definition: GeneratedMessageLite.java:1410
com.google.protobuf.GeneratedMessageLite.MethodToInvoke
Definition: GeneratedMessageLite.java:206
com.google.protobuf.GeneratedMessageLite.GeneratedExtension.getContainingTypeDefaultInstance
ContainingType getContainingTypeDefaultInstance()
Definition: GeneratedMessageLite.java:1218
com.google.protobuf.Internal.DoubleList.mutableCopyWithCapacity
DoubleList mutableCopyWithCapacity(int capacity)
com.google.protobuf.InvalidProtocolBufferException.setUnfinishedMessage
InvalidProtocolBufferException setUnfinishedMessage(MessageLite unfinishedMessage)
Definition: InvalidProtocolBufferException.java:63
com.google.protobuf.Internal.IntList
Definition: Internal.java:591
com.google
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.extensions
FieldSet< ExtensionDescriptor > extensions
Definition: GeneratedMessageLite.java:500
com.google.protobuf.GeneratedMessageLite.SerializedForm
Definition: GeneratedMessageLite.java:1307
com
com.google.protobuf.GeneratedMessageLite.ensureUnknownFieldsInitialized
final void ensureUnknownFieldsInitialized()
Definition: GeneratedMessageLite.java:135
com.google.protobuf.GeneratedMessageLite.dynamicMethod
abstract Object dynamicMethod(MethodToInvoke method, Object arg0, Object arg1)
com.google.protobuf.GeneratedMessageLite.emptyDoubleList
static DoubleList emptyDoubleList()
Definition: GeneratedMessageLite.java:1458
Type
struct Type Type
Definition: php/ext/google/protobuf/protobuf.h:664
com.google.protobuf.ExtensionLite
Definition: ExtensionLite.java:39
com.google.protobuf.GeneratedMessageLite.newRepeatedGeneratedExtension
static< ContainingType extends MessageLite, Type > GeneratedExtension< ContainingType, Type > newRepeatedGeneratedExtension(final ContainingType containingTypeDefaultInstance, final MessageLite messageDefaultInstance, final Internal.EnumLiteMap<?> enumTypeMap, final int number, final WireFormat.FieldType type, final boolean isPacked, final Class singularType)
Definition: GeneratedMessageLite.java:1058
com.google.protobuf.GeneratedMessageLite.emptyLongList
static LongList emptyLongList()
Definition: GeneratedMessageLite.java:1438
com.google.protobuf.AbstractParser
Definition: AbstractParser.java:48
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: glcorearb.h:2879
com.google.protobuf.Internal
Definition: Internal.java:54
com.google.protobuf.GeneratedMessageLite.GeneratedExtension
Definition: GeneratedMessageLite.java:1181
com.google.protobuf.CodedOutputStream
Definition: CodedOutputStream.java:59
com.google.protobuf.WireFormat.getTagFieldNumber
static int getTagFieldNumber(final int tag)
Definition: WireFormat.java:71
com.google.protobuf.InvalidProtocolBufferException
Definition: InvalidProtocolBufferException.java:41
com.google.protobuf.GeneratedMessageLite.newBuilderForType
final BuilderType newBuilderForType()
Definition: GeneratedMessageLite.java:85
com.google.protobuf.MessageLite.Builder.mergeFrom
Builder mergeFrom(CodedInputStream input)
com.google.protobuf.GeneratedMessageLite.DefaultInstanceBasedParser.DefaultInstanceBasedParser
DefaultInstanceBasedParser(T defaultInstance)
Definition: GeneratedMessageLite.java:1498
com.google.protobuf.GeneratedMessageLite.Builder.isInitialized
final boolean isInitialized()
Definition: GeneratedMessageLite.java:362
com.google.protobuf.GeneratedMessageLite.Builder.mergeFromInstance
void mergeFromInstance(MessageType dest, MessageType src)
Definition: GeneratedMessageLite.java:413
com.google.protobuf.GeneratedMessageLite.Builder.Builder
Builder(MessageType defaultInstance)
Definition: GeneratedMessageLite.java:340
com.google.protobuf.GeneratedMessageLite.parseDelimitedFrom
static< T extends GeneratedMessageLite< T, ?> T parseDelimitedFrom(T defaultInstance, InputStream input, ExtensionRegistryLite extensionRegistry)
Definition: GeneratedMessageLite.java:1706
value
GLsizei const GLfloat * value
Definition: glcorearb.h:3093
com.google.protobuf.GeneratedMessageLite.mergeLengthDelimitedField
void mergeLengthDelimitedField(int fieldNumber, ByteString value)
Definition: GeneratedMessageLite.java:163
com.google.protobuf.WireFormat.FieldType
Definition: WireFormat.java:111
com.google.protobuf.Internal.DoubleList
Definition: Internal.java:651
com.google.protobuf.GeneratedMessageLite.ExtendableBuilder< MessageType, BuilderType >
static< MessageType extends ExtendableMessage< MessageType, BuilderType > BuilderType extends ExtendableBuilder< MessageType, BuilderType >
Definition: GeneratedMessageLite.java:1394
com.google.protobuf.ExtensionRegistryLite.getEmptyRegistry
static ExtensionRegistryLite getEmptyRegistry()
Definition: ExtensionRegistryLite.java:125
com.google.protobuf.GeneratedMessageLite.DefaultInstanceBasedParser.defaultInstance
final T defaultInstance
Definition: GeneratedMessageLite.java:1496
com.google.protobuf.GeneratedMessageLite.parsePartialFrom
static< T extends GeneratedMessageLite< T, ?> T parsePartialFrom(T defaultInstance, byte[] data, ExtensionRegistryLite extensionRegistry)
Definition: GeneratedMessageLite.java:1644
output
const upb_json_parsermethod const upb_symtab upb_sink * output
Definition: ruby/ext/google/protobuf_c/upb.h:10503
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.newExtensionWriter
ExtensionWriter newExtensionWriter()
Definition: GeneratedMessageLite.java:886
com.google.protobuf.GeneratedMessageLite.DefaultInstanceBasedParser.parsePartialFrom
T parsePartialFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Definition: GeneratedMessageLite.java:1503
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.getExtension
final< Type > Type getExtension(final ExtensionLite< MessageType, Type > extension)
Definition: GeneratedMessageLite.java:817
com.google.protobuf.MessageLite.toByteArray
byte[] toByteArray()
index
GLuint index
Definition: glcorearb.h:3055
com.google.protobuf.GeneratedMessageLite.Builder
Definition: GeneratedMessageLite.java:331
com.google.protobuf.CodedInputStream.readRawVarint32
abstract int readRawVarint32()
com.google.protobuf.Internal.IntList.mutableCopyWithCapacity
IntList mutableCopyWithCapacity(int capacity)
com.google.protobuf.GeneratedMessageLite.Builder.clone
BuilderType clone()
Definition: GeneratedMessageLite.java:374
com.google.protobuf.GeneratedMessageLite.ExtendableMessage.verifyExtensionContainingType
void verifyExtensionContainingType(final GeneratedExtension< MessageType, ?> extension)
Definition: GeneratedMessageLite.java:786
Method
Definition: api.pb.h:285
number
double number
Definition: cJSON.h:326
message
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glcorearb.h:2695
com.google.protobuf.WireFormat.FieldType.ENUM
ENUM
Definition: WireFormat.java:145
com.google.protobuf.FieldSet.FieldDescriptorLite
Definition: FieldSet.java:57
com.google.protobuf.GeneratedMessageLite.Builder.instance
MessageType instance
Definition: GeneratedMessageLite.java:337
com.google.protobuf.GeneratedMessageLite.MethodToInvoke.GET_DEFAULT_INSTANCE
GET_DEFAULT_INSTANCE
Definition: GeneratedMessageLite.java:215
com.google.protobuf.GeneratedMessageLite.mutableCopy
static IntList mutableCopy(IntList list)
Definition: GeneratedMessageLite.java:1432
google::protobuf::method
const Descriptor::ReservedRange const EnumValueDescriptor method
Definition: src/google/protobuf/descriptor.h:1973
com.google.protobuf.MessageLite
Definition: MessageLite.java:65
com.google.protobuf.WireFormat.FieldType.MESSAGE
MESSAGE
Definition: WireFormat.java:132
com.google.protobuf.GeneratedMessageLite.GeneratedExtension.getDefaultValue
Type getDefaultValue()
Definition: GeneratedMessageLite.java:1298
com.google.protobuf.ByteString
Definition: ByteString.java:67
com.google.protobuf.WireFormat.JavaType
Definition: WireFormat.java:84
com.google.protobuf.GeneratedMessageLite.ExtendableBuilder.ensureExtensionsAreMutable
FieldSet< ExtensionDescriptor > ensureExtensionsAreMutable()
Definition: GeneratedMessageLite.java:931


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:51