示例#1
0
 /** Like {@link #writeTo} but uses MessageSet wire format. */
 public void writeMessageSetTo(final CodedOutputStream output) throws IOException {
   for (int i = 0; i < fields.getNumArrayEntries(); i++) {
     writeMessageSetTo(fields.getArrayEntryAt(i), output);
   }
   for (final Map.Entry<FieldDescriptorType, Object> entry : fields.getOverflowEntries()) {
     writeMessageSetTo(entry, output);
   }
 }
示例#2
0
 /** See {@link Message#writeTo(CodedOutputStream)}. */
 public void writeTo(final CodedOutputStream output) throws IOException {
   for (int i = 0; i < fields.getNumArrayEntries(); i++) {
     final Map.Entry<FieldDescriptorType, Object> entry = fields.getArrayEntryAt(i);
     writeField(entry.getKey(), entry.getValue(), output);
   }
   for (final Map.Entry<FieldDescriptorType, Object> entry : fields.getOverflowEntries()) {
     writeField(entry.getKey(), entry.getValue(), output);
   }
 }
示例#3
0
 /** Like {@link #getSerializedSize} but uses MessageSet wire format. */
 public int getMessageSetSerializedSize() {
   int size = 0;
   for (int i = 0; i < fields.getNumArrayEntries(); i++) {
     size += getMessageSetSerializedSize(fields.getArrayEntryAt(i));
   }
   for (final Map.Entry<FieldDescriptorType, Object> entry : fields.getOverflowEntries()) {
     size += getMessageSetSerializedSize(entry);
   }
   return size;
 }
示例#4
0
 /**
  * See {@link Message#getSerializedSize()}. It's up to the caller to cache the resulting size if
  * desired.
  */
 public int getSerializedSize() {
   int size = 0;
   for (int i = 0; i < fields.getNumArrayEntries(); i++) {
     final Map.Entry<FieldDescriptorType, Object> entry = fields.getArrayEntryAt(i);
     size += computeFieldSize(entry.getKey(), entry.getValue());
   }
   for (final Map.Entry<FieldDescriptorType, Object> entry : fields.getOverflowEntries()) {
     size += computeFieldSize(entry.getKey(), entry.getValue());
   }
   return size;
 }
示例#5
0
 /**
  * See {@link Message#isInitialized()}. Note: Since {@code FieldSet} itself does not have any way
  * of knowing about required fields that aren't actually present in the set, it is up to the
  * caller to check that all required fields are present.
  */
 public boolean isInitialized() {
   for (int i = 0; i < fields.getNumArrayEntries(); i++) {
     if (!isInitialized(fields.getArrayEntryAt(i))) {
       return false;
     }
   }
   for (final Map.Entry<FieldDescriptorType, Object> entry : fields.getOverflowEntries()) {
     if (!isInitialized(entry)) {
       return false;
     }
   }
   return true;
 }
示例#6
0
 /**
  * Clones the FieldSet. The returned FieldSet will be mutable even if the original FieldSet was
  * immutable.
  *
  * @return the newly cloned FieldSet
  */
 @Override
 public FieldSet<FieldDescriptorType> clone() {
   // We can't just call fields.clone because List objects in the map
   // should not be shared.
   FieldSet<FieldDescriptorType> clone = FieldSet.newFieldSet();
   for (int i = 0; i < fields.getNumArrayEntries(); i++) {
     Map.Entry<FieldDescriptorType, Object> entry = fields.getArrayEntryAt(i);
     FieldDescriptorType descriptor = entry.getKey();
     clone.setField(descriptor, entry.getValue());
   }
   for (Map.Entry<FieldDescriptorType, Object> entry : fields.getOverflowEntries()) {
     FieldDescriptorType descriptor = entry.getKey();
     clone.setField(descriptor, entry.getValue());
   }
   return clone;
 }