示例#1
0
    public void write(org.apache.thrift.protocol.TProtocol oprot, JSONField struct)
        throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.string_val != null) {
        if (struct.isSetString_val()) {
          oprot.writeFieldBegin(STRING_VAL_FIELD_DESC);
          oprot.writeString(struct.string_val);
          oprot.writeFieldEnd();
        }
      }
      if (struct.isSetBool_val()) {
        oprot.writeFieldBegin(BOOL_VAL_FIELD_DESC);
        oprot.writeBool(struct.bool_val);
        oprot.writeFieldEnd();
      }
      if (struct.isSetI32_val()) {
        oprot.writeFieldBegin(I32_VAL_FIELD_DESC);
        oprot.writeI32(struct.i32_val);
        oprot.writeFieldEnd();
      }
      if (struct.isSetI64_val()) {
        oprot.writeFieldBegin(I64_VAL_FIELD_DESC);
        oprot.writeI64(struct.i64_val);
        oprot.writeFieldEnd();
      }
      if (struct.isSetDouble_val()) {
        oprot.writeFieldBegin(DOUBLE_VAL_FIELD_DESC);
        oprot.writeDouble(struct.double_val);
        oprot.writeFieldEnd();
      }
      if (struct.isSetNull_val()) {
        oprot.writeFieldBegin(NULL_VAL_FIELD_DESC);
        oprot.writeBool(struct.null_val);
        oprot.writeFieldEnd();
      }
      if (struct.isSetRef_val()) {
        oprot.writeFieldBegin(REF_VAL_FIELD_DESC);
        oprot.writeI32(struct.ref_val);
        oprot.writeFieldEnd();
      }
      if (struct.array_val != null) {
        if (struct.isSetArray_val()) {
          oprot.writeFieldBegin(ARRAY_VAL_FIELD_DESC);
          {
            oprot.writeListBegin(
                new org.apache.thrift.protocol.TList(
                    org.apache.thrift.protocol.TType.I32, struct.array_val.size()));
            for (int _iter115 : struct.array_val) {
              oprot.writeI32(_iter115);
            }
            oprot.writeListEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }
示例#2
0
    public void read(org.apache.thrift.protocol.TProtocol iprot, JSONField 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: // STRING_VAL
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.string_val = iprot.readString();
              struct.setString_valIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // BOOL_VAL
            if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
              struct.bool_val = iprot.readBool();
              struct.setBool_valIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // I32_VAL
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.i32_val = iprot.readI32();
              struct.setI32_valIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // I64_VAL
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.i64_val = iprot.readI64();
              struct.setI64_valIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // DOUBLE_VAL
            if (schemeField.type == org.apache.thrift.protocol.TType.DOUBLE) {
              struct.double_val = iprot.readDouble();
              struct.setDouble_valIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 6: // NULL_VAL
            if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
              struct.null_val = iprot.readBool();
              struct.setNull_valIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 7: // REF_VAL
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.ref_val = iprot.readI32();
              struct.setRef_valIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 8: // ARRAY_VAL
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list112 = iprot.readListBegin();
                struct.array_val = new ArrayList<Integer>(_list112.size);
                for (int _i113 = 0; _i113 < _list112.size; ++_i113) {
                  int _elem114;
                  _elem114 = iprot.readI32();
                  struct.array_val.add(_elem114);
                }
                iprot.readListEnd();
              }
              struct.setArray_valIsSet(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();
    }