예제 #1
0
 @Override
 public FieldDescriptorProto decode(ProtoReader reader) throws IOException {
   Builder builder = new Builder();
   long token = reader.beginMessage();
   for (int tag; (tag = reader.nextTag()) != -1; ) {
     switch (tag) {
       case 1:
         builder.name(ProtoAdapter.STRING.decode(reader));
         break;
       case 9:
         builder.doc(ProtoAdapter.STRING.decode(reader));
         break;
       case 3:
         builder.number(ProtoAdapter.INT32.decode(reader));
         break;
       case 4:
         {
           try {
             builder.label(Label.ADAPTER.decode(reader));
           } catch (ProtoAdapter.EnumConstantNotFoundException e) {
             builder.addUnknownField(tag, FieldEncoding.VARINT, (long) e.value);
           }
           break;
         }
       case 5:
         {
           try {
             builder.type(Type.ADAPTER.decode(reader));
           } catch (ProtoAdapter.EnumConstantNotFoundException e) {
             builder.addUnknownField(tag, FieldEncoding.VARINT, (long) e.value);
           }
           break;
         }
       case 6:
         builder.type_name(ProtoAdapter.STRING.decode(reader));
         break;
       case 2:
         builder.extendee(ProtoAdapter.STRING.decode(reader));
         break;
       case 7:
         builder.default_value(ProtoAdapter.STRING.decode(reader));
         break;
       case 8:
         builder.options(FieldOptions.ADAPTER.decode(reader));
         break;
       default:
         {
           FieldEncoding fieldEncoding = reader.peekFieldEncoding();
           Object value = fieldEncoding.rawProtoAdapter().decode(reader);
           builder.addUnknownField(tag, fieldEncoding, value);
         }
     }
   }
   reader.endMessage(token);
   return builder.build();
 }
예제 #2
0
 @Override
 public int encodedSize(DescriptorProto value) {
   return (value.name != null ? ProtoAdapter.STRING.encodedSize(1, value.name) : 0)
       + (value.doc != null ? ProtoAdapter.STRING.encodedSize(8, value.doc) : 0)
       + FieldDescriptorProto.ADAPTER.asRepeated().encodedSize(2, value.field)
       + FieldDescriptorProto.ADAPTER.asRepeated().encodedSize(6, value.extension)
       + DescriptorProto.ADAPTER.asRepeated().encodedSize(3, value.nested_type)
       + EnumDescriptorProto.ADAPTER.asRepeated().encodedSize(4, value.enum_type)
       + ExtensionRange.ADAPTER.asRepeated().encodedSize(5, value.extension_range)
       + (value.options != null ? MessageOptions.ADAPTER.encodedSize(7, value.options) : 0)
       + value.unknownFields().size();
 }
예제 #3
0
 @Override
 public void encode(ProtoWriter writer, FieldDescriptorProto value) throws IOException {
   if (value.name != null) ProtoAdapter.STRING.encodeTagged(writer, 1, value.name);
   if (value.doc != null) ProtoAdapter.STRING.encodeTagged(writer, 9, value.doc);
   if (value.number != null) ProtoAdapter.INT32.encodeTagged(writer, 3, value.number);
   if (value.label != null) Label.ADAPTER.encodeTagged(writer, 4, value.label);
   if (value.type != null) Type.ADAPTER.encodeTagged(writer, 5, value.type);
   if (value.type_name != null) ProtoAdapter.STRING.encodeTagged(writer, 6, value.type_name);
   if (value.extendee != null) ProtoAdapter.STRING.encodeTagged(writer, 2, value.extendee);
   if (value.default_value != null)
     ProtoAdapter.STRING.encodeTagged(writer, 7, value.default_value);
   if (value.options != null) FieldOptions.ADAPTER.encodeTagged(writer, 8, value.options);
   writer.writeBytes(value.unknownFields());
 }
예제 #4
0
 @Override
 public int encodedSize(FieldDescriptorProto value) {
   return (value.name != null ? ProtoAdapter.STRING.encodedSize(1, value.name) : 0)
       + (value.doc != null ? ProtoAdapter.STRING.encodedSize(9, value.doc) : 0)
       + (value.number != null ? ProtoAdapter.INT32.encodedSize(3, value.number) : 0)
       + (value.label != null ? Label.ADAPTER.encodedSize(4, value.label) : 0)
       + (value.type != null ? Type.ADAPTER.encodedSize(5, value.type) : 0)
       + (value.type_name != null ? ProtoAdapter.STRING.encodedSize(6, value.type_name) : 0)
       + (value.extendee != null ? ProtoAdapter.STRING.encodedSize(2, value.extendee) : 0)
       + (value.default_value != null
           ? ProtoAdapter.STRING.encodedSize(7, value.default_value)
           : 0)
       + (value.options != null ? FieldOptions.ADAPTER.encodedSize(8, value.options) : 0)
       + value.unknownFields().size();
 }
예제 #5
0
 @Override
 public void encode(ProtoWriter writer, RedactedChild value) throws IOException {
   if (value.a != null) ProtoAdapter.STRING.encodeWithTag(writer, 1, value.a);
   if (value.b != null) Redacted.ADAPTER.encodeWithTag(writer, 2, value.b);
   if (value.c != null) NotRedacted.ADAPTER.encodeWithTag(writer, 3, value.c);
   writer.writeBytes(value.unknownFields());
 }
예제 #6
0
 @Override
 public RedactedChild decode(ProtoReader reader) throws IOException {
   Builder builder = new Builder();
   long token = reader.beginMessage();
   for (int tag; (tag = reader.nextTag()) != -1; ) {
     switch (tag) {
       case 1:
         builder.a(ProtoAdapter.STRING.decode(reader));
         break;
       case 2:
         builder.b(Redacted.ADAPTER.decode(reader));
         break;
       case 3:
         builder.c(NotRedacted.ADAPTER.decode(reader));
         break;
       default:
         {
           FieldEncoding fieldEncoding = reader.peekFieldEncoding();
           Object value = fieldEncoding.rawProtoAdapter().decode(reader);
           builder.addUnknownField(tag, fieldEncoding, value);
         }
     }
   }
   reader.endMessage(token);
   return builder.build();
 }
예제 #7
0
 @Override
 public int encodedSize(RedactedChild value) {
   return (value.a != null ? ProtoAdapter.STRING.encodedSizeWithTag(1, value.a) : 0)
       + (value.b != null ? Redacted.ADAPTER.encodedSizeWithTag(2, value.b) : 0)
       + (value.c != null ? NotRedacted.ADAPTER.encodedSizeWithTag(3, value.c) : 0)
       + value.unknownFields().size();
 }
예제 #8
0
 @Override
 public void encode(ProtoWriter writer, DescriptorProto value) throws IOException {
   if (value.name != null) ProtoAdapter.STRING.encodeTagged(writer, 1, value.name);
   if (value.doc != null) ProtoAdapter.STRING.encodeTagged(writer, 8, value.doc);
   if (value.field != null)
     FieldDescriptorProto.ADAPTER.asRepeated().encodeTagged(writer, 2, value.field);
   if (value.extension != null)
     FieldDescriptorProto.ADAPTER.asRepeated().encodeTagged(writer, 6, value.extension);
   if (value.nested_type != null)
     DescriptorProto.ADAPTER.asRepeated().encodeTagged(writer, 3, value.nested_type);
   if (value.enum_type != null)
     EnumDescriptorProto.ADAPTER.asRepeated().encodeTagged(writer, 4, value.enum_type);
   if (value.extension_range != null)
     ExtensionRange.ADAPTER.asRepeated().encodeTagged(writer, 5, value.extension_range);
   if (value.options != null) MessageOptions.ADAPTER.encodeTagged(writer, 7, value.options);
   writer.writeBytes(value.unknownFields());
 }
예제 #9
0
파일: FooBar.java 프로젝트: pforhan/wire
 @Override
 public FooBar decode(ProtoReader reader) throws IOException {
   Builder builder = new Builder();
   long token = reader.beginMessage();
   for (int tag; (tag = reader.nextTag()) != -1; ) {
     switch (tag) {
       case 1:
         builder.foo(ProtoAdapter.INT32.decode(reader));
         break;
       case 2:
         builder.bar(ProtoAdapter.STRING.decode(reader));
         break;
       case 3:
         builder.baz(Nested.ADAPTER.decode(reader));
         break;
       case 4:
         builder.qux(ProtoAdapter.UINT64.decode(reader));
         break;
       case 5:
         builder.fred.add(ProtoAdapter.FLOAT.decode(reader));
         break;
       case 6:
         builder.daisy(ProtoAdapter.DOUBLE.decode(reader));
         break;
       case 7:
         builder.nested.add(FooBar.ADAPTER.decode(reader));
         break;
       case 101:
         {
           try {
             builder.ext(FooBarBazEnum.ADAPTER.decode(reader));
           } catch (ProtoAdapter.EnumConstantNotFoundException e) {
             builder.addUnknownField(tag, FieldEncoding.VARINT, (long) e.value);
           }
           break;
         }
       case 102:
         {
           try {
             builder.rep.add(FooBarBazEnum.ADAPTER.decode(reader));
           } catch (ProtoAdapter.EnumConstantNotFoundException e) {
             builder.addUnknownField(tag, FieldEncoding.VARINT, (long) e.value);
           }
           break;
         }
       default:
         {
           FieldEncoding fieldEncoding = reader.peekFieldEncoding();
           Object value = fieldEncoding.rawProtoAdapter().decode(reader);
           builder.addUnknownField(tag, fieldEncoding, value);
         }
     }
   }
   reader.endMessage(token);
   return builder.build();
 }
예제 #10
0
 @Override
 public DescriptorProto decode(ProtoReader reader) throws IOException {
   Builder builder = new Builder();
   long token = reader.beginMessage();
   for (int tag; (tag = reader.nextTag()) != -1; ) {
     switch (tag) {
       case 1:
         builder.name(ProtoAdapter.STRING.decode(reader));
         break;
       case 8:
         builder.doc(ProtoAdapter.STRING.decode(reader));
         break;
       case 2:
         builder.field.add(FieldDescriptorProto.ADAPTER.decode(reader));
         break;
       case 6:
         builder.extension.add(FieldDescriptorProto.ADAPTER.decode(reader));
         break;
       case 3:
         builder.nested_type.add(DescriptorProto.ADAPTER.decode(reader));
         break;
       case 4:
         builder.enum_type.add(EnumDescriptorProto.ADAPTER.decode(reader));
         break;
       case 5:
         builder.extension_range.add(ExtensionRange.ADAPTER.decode(reader));
         break;
       case 7:
         builder.options(MessageOptions.ADAPTER.decode(reader));
         break;
       default:
         {
           FieldEncoding fieldEncoding = reader.peekFieldEncoding();
           Object value = fieldEncoding.rawProtoAdapter().decode(reader);
           builder.addUnknownField(tag, fieldEncoding, value);
         }
     }
   }
   reader.endMessage(token);
   return builder.build();
 }
예제 #11
0
파일: FooBar.java 프로젝트: pforhan/wire
 @Override
 public int encodedSize(FooBar value) {
   return (value.foo != null ? ProtoAdapter.INT32.encodedSizeWithTag(1, value.foo) : 0)
       + (value.bar != null ? ProtoAdapter.STRING.encodedSizeWithTag(2, value.bar) : 0)
       + (value.baz != null ? Nested.ADAPTER.encodedSizeWithTag(3, value.baz) : 0)
       + (value.qux != null ? ProtoAdapter.UINT64.encodedSizeWithTag(4, value.qux) : 0)
       + ProtoAdapter.FLOAT.asRepeated().encodedSizeWithTag(5, value.fred)
       + (value.daisy != null ? ProtoAdapter.DOUBLE.encodedSizeWithTag(6, value.daisy) : 0)
       + FooBar.ADAPTER.asRepeated().encodedSizeWithTag(7, value.nested)
       + (value.ext != null ? FooBarBazEnum.ADAPTER.encodedSizeWithTag(101, value.ext) : 0)
       + FooBarBazEnum.ADAPTER.asRepeated().encodedSizeWithTag(102, value.rep)
       + value.unknownFields().size();
 }
예제 #12
0
파일: FooBar.java 프로젝트: pforhan/wire
 @Override
 public void encode(ProtoWriter writer, FooBar value) throws IOException {
   if (value.foo != null) ProtoAdapter.INT32.encodeWithTag(writer, 1, value.foo);
   if (value.bar != null) ProtoAdapter.STRING.encodeWithTag(writer, 2, value.bar);
   if (value.baz != null) Nested.ADAPTER.encodeWithTag(writer, 3, value.baz);
   if (value.qux != null) ProtoAdapter.UINT64.encodeWithTag(writer, 4, value.qux);
   if (value.fred != null) ProtoAdapter.FLOAT.asRepeated().encodeWithTag(writer, 5, value.fred);
   if (value.daisy != null) ProtoAdapter.DOUBLE.encodeWithTag(writer, 6, value.daisy);
   if (value.nested != null) FooBar.ADAPTER.asRepeated().encodeWithTag(writer, 7, value.nested);
   if (value.ext != null) FooBarBazEnum.ADAPTER.encodeWithTag(writer, 101, value.ext);
   if (value.rep != null)
     FooBarBazEnum.ADAPTER.asRepeated().encodeWithTag(writer, 102, value.rep);
   writer.writeBytes(value.unknownFields());
 }
예제 #13
0
 @Override
 public int encodedSize(RedactedExtension value) {
   return (value.d != null ? ProtoAdapter.STRING.encodedSizeWithTag(1, value.d) : 0)
       + (value.e != null ? ProtoAdapter.STRING.encodedSizeWithTag(2, value.e) : 0)
       + value.unknownFields().size();
 }
예제 #14
0
 @Override
 public void encode(ProtoWriter writer, RedactedExtension value) throws IOException {
   if (value.d != null) ProtoAdapter.STRING.encodeWithTag(writer, 1, value.d);
   if (value.e != null) ProtoAdapter.STRING.encodeWithTag(writer, 2, value.e);
   writer.writeBytes(value.unknownFields());
 }
예제 #15
0
 @Override
 public int encodedSize(Phone value) {
   return (value.number != null ? ProtoAdapter.STRING.encodedSizeWithTag(1, value.number) : 0)
       + value.unknownFields().size();
 }
예제 #16
0
 @Override
 public void encode(ProtoWriter writer, Phone value) throws IOException {
   if (value.number != null) ProtoAdapter.STRING.encodeWithTag(writer, 1, value.number);
   writer.writeBytes(value.unknownFields());
 }
예제 #17
0
 @Override
 public void encode(ProtoWriter writer, RedactedRequired value) throws IOException {
   ProtoAdapter.STRING.encodeWithTag(writer, 1, value.a);
   writer.writeBytes(value.unknownFields());
 }
예제 #18
0
 @Override
 public int encodedSize(RedactedRequired value) {
   return ProtoAdapter.STRING.encodedSizeWithTag(1, value.a) + value.unknownFields().size();
 }