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 com.x.protobuf.Bug11.C parseFrom(byte[] data, CurrentCursor cursor)
     throws java.io.IOException {
   com.x.protobuf.Bug11.C message = new com.x.protobuf.Bug11.C();
   while (true) {
     if (ProtobufInputStream.isAtEnd(data, cursor)) {
       return message;
     }
     int varint = ProtobufInputStream.readRawVarint32(data, cursor);
     int tag = ProtobufInputStream.getTagFieldNumber(varint);
     switch (tag) {
       case 0:
         return message;
       default:
         ProtobufInputStream.skipUnknown(varint, data, cursor);
         break;
       case 1:
         message.setVal(ProtobufInputStream.readString(data, cursor));
         break;
     }
   }
 }
Ejemplo n.º 3
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);
   }
 }