예제 #1
0
파일: Advert.java 프로젝트: kbence/booktion
    public void write(org.apache.thrift.protocol.TProtocol oprot, Advert struct)
        throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(ID_FIELD_DESC);
      oprot.writeI32(struct.id);
      oprot.writeFieldEnd();
      if (struct.issuer != null) {
        oprot.writeFieldBegin(ISSUER_FIELD_DESC);
        struct.issuer.write(oprot);
        oprot.writeFieldEnd();
      }
      if (struct.book != null) {
        oprot.writeFieldBegin(BOOK_FIELD_DESC);
        struct.book.write(oprot);
        oprot.writeFieldEnd();
      }
      if (struct.advertType != null) {
        oprot.writeFieldBegin(ADVERT_TYPE_FIELD_DESC);
        oprot.writeI32(struct.advertType.getValue());
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(EXPIRES_FIELD_DESC);
      oprot.writeI64(struct.expires);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(PRICE_FIELD_DESC);
      oprot.writeDouble(struct.price);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(WINNER_FIELD_DESC);
      oprot.writeI32(struct.winner);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }
예제 #2
0
파일: Advert.java 프로젝트: kbence/booktion
    public void read(org.apache.thrift.protocol.TProtocol iprot, Advert struct)
        throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TField schemeField;
      iprot.readStructBegin();
      while (true) {
        schemeField = iprot.readFieldBegin();
        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
          break;
        }
        switch (schemeField.id) {
          case 1: // ID
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.id = iprot.readI32();
              struct.setIdIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // ISSUER
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.issuer = new com.booktion.thrift.User();
              struct.issuer.read(iprot);
              struct.setIssuerIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // BOOK
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.book = new com.booktion.thrift.Book();
              struct.book.read(iprot);
              struct.setBookIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // ADVERT_TYPE
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.advertType = com.booktion.thrift.AdvertType.findByValue(iprot.readI32());
              struct.setAdvertTypeIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // EXPIRES
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.expires = iprot.readI64();
              struct.setExpiresIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 6: // PRICE
            if (schemeField.type == org.apache.thrift.protocol.TType.DOUBLE) {
              struct.price = iprot.readDouble();
              struct.setPriceIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 7: // WINNER
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.winner = iprot.readI32();
              struct.setWinnerIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          default:
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
        }
        iprot.readFieldEnd();
      }
      iprot.readStructEnd();

      // check for required fields of primitive type, which can't be checked in the validate method
      struct.validate();
    }