Ejemplo n.º 1
0
 public static void serialize(com.x.protobuf.Bug11.C message, java.io.OutputStream os) {
   try {
     if (message.hasVal()) {
       ProtobufOutputStream.writeString(1, message.getVal(), os);
     }
   } catch (IOException e) {
     throw new RuntimeException(
         "Serializing to a byte array threw an IOException (should never happen).", e);
   }
 }
Ejemplo n.º 2
0
 public static byte[] serialize(com.x.protobuf.Bug11.C message) {
   try {
     int totalSize = 0;
     byte[] valBuffer = null;
     if (message.hasVal()) {
       valBuffer = message.getVal().getBytes("UTF-8");
       totalSize += valBuffer.length;
       totalSize += ProtobufOutputStream.computeTagSize(1);
       totalSize += ProtobufOutputStream.computeRawVarint32Size(valBuffer.length);
     }
     final byte[] result = new byte[totalSize];
     int position = 0;
     if (message.hasVal()) {
       position = ProtobufOutputStream.writeString(1, valBuffer, result, position);
     }
     ProtobufOutputStream.checkNoSpaceLeft(result, position);
     return result;
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }