Example #1
0
 public static byte[] serialize(com.x.protobuf.Bug11.B 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);
     }
     byte[] cvalBuffer = null;
     if (message.hasCval()) {
       cvalBuffer = com.x.protobuf.Bug11.CSerializer.serialize(message.getCval());
       totalSize += ProtobufOutputStream.computeTagSize(2);
       totalSize += ProtobufOutputStream.computeRawVarint32Size(cvalBuffer.length);
       totalSize += cvalBuffer.length;
     }
     byte[] resultBuffer = null;
     if (message.hasResult()) {
       java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
       for (int i = 0; i < message.getResult().size(); i++) {
         byte[] curMessageData =
             com.x.protobuf.Bug11.B.ResultSerializer.serialize(message.getResult().get(i));
         ProtobufOutputStream.writeTag(3, ProtobufInputStream.WIRETYPE_GROUP_START, baos);
         baos.write(curMessageData);
         ProtobufOutputStream.writeTag(3, ProtobufInputStream.WIRETYPE_GROUP_END, baos);
       }
       resultBuffer = baos.toByteArray();
       totalSize += resultBuffer.length;
     }
     final byte[] result = new byte[totalSize];
     int position = 0;
     if (message.hasVal()) {
       position = ProtobufOutputStream.writeString(1, valBuffer, result, position);
     }
     if (message.hasCval()) {
       position = ProtobufOutputStream.writeBytes(2, cvalBuffer, result, position);
     }
     if (message.hasResult()) {
       position = ProtobufOutputStream.writeRawBytes(resultBuffer, result, position);
     }
     ProtobufOutputStream.checkNoSpaceLeft(result, position);
     return result;
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
Example #2
0
 public static void serialize(com.x.protobuf.Bug11.A message, java.io.OutputStream os) {
   try {
     if (message.hasEntry()) {
       for (int i = 0; i < message.getEntry().size(); i++) {
         byte[] curMessageData =
             com.x.protobuf.Bug11.BSerializer.serialize(message.getEntry().get(i));
         ProtobufOutputStream.writeMessageTag(32904, os);
         ProtobufOutputStream.writeRawVarint32(curMessageData.length, os);
         os.write(curMessageData);
       }
     }
     if (message.hasEntry2()) {
       ProtobufOutputStream.writeInt32(32902, message.getEntry2(), os);
     }
   } catch (IOException e) {
     throw new RuntimeException(
         "Serializing to a byte array threw an IOException (should never happen).", e);
   }
 }
Example #3
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);
   }
 }
Example #4
0
 public static void serialize(com.x.protobuf.Bug11.B.Result message, java.io.OutputStream os) {
   try {
     assertInitialized(message);
     if (message.hasUrl()) {
       ProtobufOutputStream.writeString(2, message.getUrl(), os);
     }
     if (message.hasTitle()) {
       ProtobufOutputStream.writeString(3, message.getTitle(), os);
     }
     if (message.hasSnippets()) {
       for (int i = 0; i < message.getSnippets().size(); i++) {
         ProtobufOutputStream.writeString(4, message.getSnippets().get(i), os);
       }
     }
   } catch (IOException e) {
     throw new RuntimeException(
         "Serializing to a byte array threw an IOException (should never happen).", e);
   }
 }
Example #5
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);
   }
 }
Example #6
0
 public static byte[] serialize(com.x.protobuf.Bug11.A message) {
   try {
     int totalSize = 0;
     byte[] entryBuffer = null;
     if (message.hasEntry()) {
       java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
       for (int i = 0; i < message.getEntry().size(); i++) {
         byte[] curMessageData =
             com.x.protobuf.Bug11.BSerializer.serialize(message.getEntry().get(i));
         ProtobufOutputStream.writeMessageTag(32904, baos);
         ProtobufOutputStream.writeRawVarint32(curMessageData.length, baos);
         baos.write(curMessageData);
       }
       entryBuffer = baos.toByteArray();
       totalSize += entryBuffer.length;
     }
     if (message.hasEntry2()) {
       totalSize += ProtobufOutputStream.computeInt32Size(32902, message.getEntry2());
     }
     final byte[] result = new byte[totalSize];
     int position = 0;
     if (message.hasEntry()) {
       position = ProtobufOutputStream.writeRawBytes(entryBuffer, result, position);
     }
     if (message.hasEntry2()) {
       position = ProtobufOutputStream.writeInt32(32902, message.getEntry2(), result, position);
     }
     ProtobufOutputStream.checkNoSpaceLeft(result, position);
     return result;
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
Example #7
0
 public static byte[] serialize(com.x.protobuf.Bug11.B.Result message) {
   try {
     assertInitialized(message);
     int totalSize = 0;
     byte[] urlBuffer = null;
     if (message.hasUrl()) {
       urlBuffer = message.getUrl().getBytes("UTF-8");
       totalSize += urlBuffer.length;
       totalSize += ProtobufOutputStream.computeTagSize(2);
       totalSize += ProtobufOutputStream.computeRawVarint32Size(urlBuffer.length);
     }
     byte[] titleBuffer = null;
     if (message.hasTitle()) {
       titleBuffer = message.getTitle().getBytes("UTF-8");
       totalSize += titleBuffer.length;
       totalSize += ProtobufOutputStream.computeTagSize(3);
       totalSize += ProtobufOutputStream.computeRawVarint32Size(titleBuffer.length);
     }
     byte[] snippetsBuffer = null;
     if (message.hasSnippets()) {
       java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
       for (int i = 0; i < message.getSnippets().size(); i++) {
         ProtobufOutputStream.writeString(4, message.getSnippets().get(i), baos);
       }
       snippetsBuffer = baos.toByteArray();
       totalSize += snippetsBuffer.length;
     }
     final byte[] result = new byte[totalSize];
     int position = 0;
     if (message.hasUrl()) {
       position = ProtobufOutputStream.writeString(2, urlBuffer, result, position);
     }
     if (message.hasTitle()) {
       position = ProtobufOutputStream.writeString(3, titleBuffer, result, position);
     }
     if (message.hasSnippets()) {
       position = ProtobufOutputStream.writeRawBytes(snippetsBuffer, result, position);
     }
     ProtobufOutputStream.checkNoSpaceLeft(result, position);
     return result;
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
Example #8
0
 public static void serialize(com.x.protobuf.Bug11.B message, java.io.OutputStream os) {
   try {
     if (message.hasVal()) {
       ProtobufOutputStream.writeString(1, message.getVal(), os);
     }
     if (message.hasCval()) {
       byte[] curMessageData = com.x.protobuf.Bug11.CSerializer.serialize(message.getCval());
       ProtobufOutputStream.writeMessageTag(2, os);
       ProtobufOutputStream.writeRawVarint32(curMessageData.length, os);
       os.write(curMessageData);
     }
     if (message.hasResult()) {
       for (int i = 0; i < message.getResult().size(); i++) {
         ProtobufOutputStream.writeTag(3, ProtobufInputStream.WIRETYPE_GROUP_START, os);
         os.write(com.x.protobuf.Bug11.B.ResultSerializer.serialize(message.getResult().get(i)));
         ProtobufOutputStream.writeTag(3, ProtobufInputStream.WIRETYPE_GROUP_END, os);
       }
     }
   } catch (IOException e) {
     throw new RuntimeException(
         "Serializing to a byte array threw an IOException (should never happen).", e);
   }
 }