Java Code Examples for com.google.protobuf.Descriptors.FieldDescriptor#getLiteJavaType()

The following examples show how to use com.google.protobuf.Descriptors.FieldDescriptor#getLiteJavaType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeneratedMessage.java    From play-store-api with GNU General Public License v3.0 5 votes vote down vote up
public void writeUntil(final int end, final CodedOutputStream output)
                       throws IOException {
  while (next != null && next.getKey().getNumber() < end) {
    FieldDescriptor descriptor = next.getKey();
    if (messageSetWireFormat && descriptor.getLiteJavaType() ==
            WireFormat.JavaType.MESSAGE &&
        !descriptor.isRepeated()) {
      if (next instanceof LazyField.LazyEntry<?>) {
        output.writeRawMessageSetExtension(descriptor.getNumber(),
            ((LazyField.LazyEntry<?>) next).getField().toByteString());
      } else {
        output.writeMessageSetExtension(descriptor.getNumber(),
                                        (Message) next.getValue());
      }
    } else {
      // TODO(xiangl): Taken care of following code, it may cause
      // problem when we use LazyField for normal fields/extensions.
      // Due to the optional field can be duplicated at the end of
      // serialized bytes, which will make the serialized size change
      // after lazy field parsed. So when we use LazyField globally,
      // we need to change the following write method to write cached
      // bytes directly rather than write the parsed message.
      FieldSet.writeField(descriptor, next.getValue(), output);
    }
    if (iter.hasNext()) {
      next = iter.next();
    } else {
      next = null;
    }
  }
}
 
Example 2
Source File: GeneratedMessage.java    From travelguide with Apache License 2.0 5 votes vote down vote up
public void writeUntil(final int end, final CodedOutputStream output)
                       throws IOException {
  while (next != null && next.getKey().getNumber() < end) {
    FieldDescriptor descriptor = next.getKey();
    if (messageSetWireFormat && descriptor.getLiteJavaType() ==
            WireFormat.JavaType.MESSAGE &&
        !descriptor.isRepeated()) {
      if (next instanceof LazyField.LazyEntry<?>) {
        output.writeRawMessageSetExtension(descriptor.getNumber(),
            ((LazyField.LazyEntry<?>) next).getField().toByteString());
      } else {
        output.writeMessageSetExtension(descriptor.getNumber(),
                                        (Message) next.getValue());
      }
    } else {
      // TODO(xiangl): Taken care of following code, it may cause
      // problem when we use LazyField for normal fields/extensions.
      // Due to the optional field can be duplicated at the end of
      // serialized bytes, which will make the serialized size change
      // after lazy field parsed. So when we use LazyField globally,
      // we need to change the following write method to write cached
      // bytes directly rather than write the parsed message.
      FieldSet.writeField(descriptor, next.getValue(), output);
    }
    if (iter.hasNext()) {
      next = iter.next();
    } else {
      next = null;
    }
  }
}
 
Example 3
Source File: GeneratedMessage.java    From 365browser with Apache License 2.0 5 votes vote down vote up
public void writeUntil(final int end, final CodedOutputStream output)
                       throws IOException {
  while (next != null && next.getKey().getNumber() < end) {
    FieldDescriptor descriptor = next.getKey();
    if (messageSetWireFormat && descriptor.getLiteJavaType() ==
            WireFormat.JavaType.MESSAGE &&
        !descriptor.isRepeated()) {
      if (next instanceof LazyField.LazyEntry<?>) {
        output.writeRawMessageSetExtension(descriptor.getNumber(),
            ((LazyField.LazyEntry<?>) next).getField().toByteString());
      } else {
        output.writeMessageSetExtension(descriptor.getNumber(),
                                        (Message) next.getValue());
      }
    } else {
      // TODO(xiangl): Taken care of following code, it may cause
      // problem when we use LazyField for normal fields/extensions.
      // Due to the optional field can be duplicated at the end of
      // serialized bytes, which will make the serialized size change
      // after lazy field parsed. So when we use LazyField globally,
      // we need to change the following write method to write cached
      // bytes directly rather than write the parsed message.
      FieldSet.writeField(descriptor, next.getValue(), output);
    }
    if (iter.hasNext()) {
      next = iter.next();
    } else {
      next = null;
    }
  }
}
 
Example 4
Source File: GeneratedMessage.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void writeUntil(final int end, final CodedOutputStream output)
                       throws IOException {
  while (next != null && next.getKey().getNumber() < end) {
    FieldDescriptor descriptor = next.getKey();
    if (messageSetWireFormat && descriptor.getLiteJavaType() ==
            WireFormat.JavaType.MESSAGE &&
        !descriptor.isRepeated()) {
      if (next instanceof LazyField.LazyEntry<?>) {
        output.writeRawMessageSetExtension(descriptor.getNumber(),
            ((LazyField.LazyEntry<?>) next).getField().toByteString());
      } else {
        output.writeMessageSetExtension(descriptor.getNumber(),
                                        (Message) next.getValue());
      }
    } else {
      // TODO(xiangl): Taken care of following code, it may cause
      // problem when we use LazyField for normal fields/extensions.
      // Due to the optional field can be duplicated at the end of
      // serialized bytes, which will make the serialized size change
      // after lazy field parsed. So when we use LazyField globally,
      // we need to change the following write method to write cached
      // bytes directly rather than write the parsed message.
      FieldSet.writeField(descriptor, next.getValue(), output);
    }
    if (iter.hasNext()) {
      next = iter.next();
    } else {
      next = null;
    }
  }
}
 
Example 5
Source File: GeneratedMessage.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void writeUntil(final int end, final CodedOutputStream output)
                       throws IOException {
  while (next != null && next.getKey().getNumber() < end) {
    FieldDescriptor descriptor = next.getKey();
    if (messageSetWireFormat && descriptor.getLiteJavaType() ==
            WireFormat.JavaType.MESSAGE &&
        !descriptor.isRepeated()) {
      if (next instanceof LazyField.LazyEntry<?>) {
        output.writeRawMessageSetExtension(descriptor.getNumber(),
            ((LazyField.LazyEntry<?>) next).getField().toByteString());
      } else {
        output.writeMessageSetExtension(descriptor.getNumber(),
                                        (Message) next.getValue());
      }
    } else {
      // TODO(xiangl): Taken care of following code, it may cause
      // problem when we use LazyField for normal fields/extensions.
      // Due to the optional field can be duplicated at the end of
      // serialized bytes, which will make the serialized size change
      // after lazy field parsed. So when we use LazyField globally,
      // we need to change the following write method to write cached
      // bytes directly rather than write the parsed message.
      FieldSet.writeField(descriptor, next.getValue(), output);
    }
    if (iter.hasNext()) {
      next = iter.next();
    } else {
      next = null;
    }
  }
}