Package com.google.protobuf

Examples of com.google.protobuf.CodedOutputStream.writeTag()


         out.writeFloat(wrappedFloat, (Float) t);
      } else if (t instanceof Boolean) {
         out.writeBool(wrappedBool, (Boolean) t);
      } else if (t instanceof byte[]) {
         byte[] bytes = (byte[]) t;
         out.writeTag(wrappedBytes, WireFormat.WIRETYPE_LENGTH_DELIMITED);
         out.writeRawVarint32(bytes.length);
         out.writeRawBytes(bytes);
      } else if (t instanceof Enum) {
         // use an enum encoder
         EnumEncoder enumEncoder = ctx.getEnumEncoder((Class<Enum>) t.getClass());
View Full Code Here


      } else {
         // this is either an unknown primitive type or a message type
         // try to use a message marshaller
         MessageMarshaller marshaller = ctx.getMarshaller(t.getClass());
         out.writeString(wrappedDescriptorFullName, marshaller.getFullName());
         out.writeTag(wrappedMessageBytes, WireFormat.WIRETYPE_LENGTH_DELIMITED);

         ByteArrayOutputStream baos2 = new ByteArrayOutputStream();      //todo here we should use a better buffer allocation strategy
         CodedOutputStream out2 = CodedOutputStream.newInstance(baos2);
         ProtobufWriterImpl writer = new ProtobufWriterImpl(ctx);
         writer.write(out2, t);
View Full Code Here

         out.writeFloat(wrappedFloat, (Float) t);
      } else if (t instanceof Boolean) {
         out.writeBool(wrappedBool, (Boolean) t);
      } else if (t instanceof byte[]) {
         byte[] bytes = (byte[]) t;
         out.writeTag(wrappedBytes, WireFormat.WIRETYPE_LENGTH_DELIMITED);
         out.writeRawVarint32(bytes.length);
         out.writeRawBytes(bytes);
      } else if (t instanceof Enum) {
         // use an enum encoder
         EnumEncoder enumEncoder = ctx.getEnumEncoder((Class<Enum>) t.getClass());
View Full Code Here

         ByteArrayOutputStream buffer = new ByteArrayOutputStream();      //todo here we should use a better buffer allocation strategy
         ProtobufWriterImpl writer = new ProtobufWriterImpl(ctx);
         writer.write(CodedOutputStream.newInstance(buffer), t);

         out.writeTag(wrappedMessageBytes, WireFormat.WIRETYPE_LENGTH_DELIMITED);
         out.writeRawVarint32(buffer.size());
         out.writeRawBytes(buffer.toByteArray());
      }
      out.flush();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.