示例#1
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();
 }
示例#2
0
文件: FooBar.java 项目: pforhan/wire
 @Override
 public Nested decode(ProtoReader reader) throws IOException {
   Builder builder = new Builder();
   long token = reader.beginMessage();
   for (int tag; (tag = reader.nextTag()) != -1; ) {
     switch (tag) {
       case 1:
         {
           try {
             builder.value(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();
 }
示例#3
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();
 }
示例#4
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();
 }
示例#5
0
文件: FooBar.java 项目: pforhan/wire
 @Override
 public More 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.serial.add(ProtoAdapter.INT32.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();
 }
示例#6
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();
 }
示例#7
0
 @Override
 public MethodOptions decode(ProtoReader reader) throws IOException {
   Builder builder = new Builder();
   long token = reader.beginMessage();
   for (int tag; (tag = reader.nextTag()) != -1; ) {
     switch (tag) {
       case 33:
         builder.deprecated(ProtoAdapter.BOOL.decode(reader));
         break;
       case 999:
         builder.uninterpreted_option.add(UninterpretedOption.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();
 }