/** * Autogenerated by Thrift Compiler (0.8.0-dev) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package org.pyload.thrift; import org.apache.thrift.scheme.IScheme; import org.apache.thrift.scheme.SchemeFactory; import org.apache.thrift.scheme.StandardScheme; import org.apache.thrift.scheme.TupleScheme; import org.apache.thrift.protocol.TTupleProtocol; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.util.HashMap; import java.util.EnumMap; import java.util.Set; import java.util.HashSet; import java.util.EnumSet; import java.util.Collections; import java.util.BitSet; import java.nio.ByteBuffer; import java.util.Arrays; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class CaptchaTask implements org.apache.thrift.TBase<CaptchaTask, CaptchaTask._Fields>, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CaptchaTask"); private static final org.apache.thrift.protocol.TField TID_FIELD_DESC = new org.apache.thrift.protocol.TField("tid", org.apache.thrift.protocol.TType.I16, (short)1); private static final org.apache.thrift.protocol.TField DATA_FIELD_DESC = new org.apache.thrift.protocol.TField("data", org.apache.thrift.protocol.TType.STRING, (short)2); private static final org.apache.thrift.protocol.TField TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("type", org.apache.thrift.protocol.TType.STRING, (short)3); private static final org.apache.thrift.protocol.TField RESULT_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("resultType", org.apache.thrift.protocol.TType.STRING, (short)4); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { schemes.put(StandardScheme.class, new CaptchaTaskStandardSchemeFactory()); schemes.put(TupleScheme.class, new CaptchaTaskTupleSchemeFactory()); } public short tid; // required public ByteBuffer data; // required public String type; // required public String resultType; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { TID((short)1, "tid"), DATA((short)2, "data"), TYPE((short)3, "type"), RESULT_TYPE((short)4, "resultType"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); static { for (_Fields field : EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // TID return TID; case 2: // DATA return DATA; case 3: // TYPE return TYPE; case 4: // RESULT_TYPE return RESULT_TYPE; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(String name) { return byName.get(name); } private final short _thriftId; private final String _fieldName; _Fields(short thriftId, String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public String getFieldName() { return _fieldName; } } // isset id assignments private static final int __TID_ISSET_ID = 0; private BitSet __isset_bit_vector = new BitSet(1); public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.TID, new org.apache.thrift.meta_data.FieldMetaData("tid", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16))); tmpMap.put(_Fields.DATA, new org.apache.thrift.meta_data.FieldMetaData("data", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))); tmpMap.put(_Fields.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.RESULT_TYPE, new org.apache.thrift.meta_data.FieldMetaData("resultType", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CaptchaTask.class, metaDataMap); } public CaptchaTask() { } public CaptchaTask( short tid, ByteBuffer data, String type, String resultType) { this(); this.tid = tid; setTidIsSet(true); this.data = data; this.type = type; this.resultType = resultType; } /** * Performs a deep copy on <i>other</i>. */ public CaptchaTask(CaptchaTask other) { __isset_bit_vector.clear(); __isset_bit_vector.or(other.__isset_bit_vector); this.tid = other.tid; if (other.isSetData()) { this.data = org.apache.thrift.TBaseHelper.copyBinary(other.data); ; } if (other.isSetType()) { this.type = other.type; } if (other.isSetResultType()) { this.resultType = other.resultType; } } public CaptchaTask deepCopy() { return new CaptchaTask(this); } @Override public void clear() { setTidIsSet(false); this.tid = 0; this.data = null; this.type = null; this.resultType = null; } public short getTid() { return this.tid; } public CaptchaTask setTid(short tid) { this.tid = tid; setTidIsSet(true); return this; } public void unsetTid() { __isset_bit_vector.clear(__TID_ISSET_ID); } /** Returns true if field tid is set (has been assigned a value) and false otherwise */ public boolean isSetTid() { return __isset_bit_vector.get(__TID_ISSET_ID); } public void setTidIsSet(boolean value) { __isset_bit_vector.set(__TID_ISSET_ID, value); } public byte[] getData() { setData(org.apache.thrift.TBaseHelper.rightSize(data)); return data == null ? null : data.array(); } public ByteBuffer bufferForData() { return data; } public CaptchaTask setData(byte[] data) { setData(data == null ? (ByteBuffer)null : ByteBuffer.wrap(data)); return this; } public CaptchaTask setData(ByteBuffer data) { this.data = data; return this; } public void unsetData() { this.data = null; } /** Returns true if field data is set (has been assigned a value) and false otherwise */ public boolean isSetData() { return this.data != null; } public void setDataIsSet(boolean value) { if (!value) { this.data = null; } } public String getType() { return this.type; } public CaptchaTask setType(String type) { this.type = type; return this; } public void unsetType() { this.type = null; } /** Returns true if field type is set (has been assigned a value) and false otherwise */ public boolean isSetType() { return this.type != null; } public void setTypeIsSet(boolean value) { if (!value) { this.type = null; } } public String getResultType() { return this.resultType; } public CaptchaTask setResultType(String resultType) { this.resultType = resultType; return this; } public void unsetResultType() { this.resultType = null; } /** Returns true if field resultType is set (has been assigned a value) and false otherwise */ public boolean isSetResultType() { return this.resultType != null; } public void setResultTypeIsSet(boolean value) { if (!value) { this.resultType = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case TID: if (value == null) { unsetTid(); } else { setTid((Short)value); } break; case DATA: if (value == null) { unsetData(); } else { setData((ByteBuffer)value); } break; case TYPE: if (value == null) { unsetType(); } else { setType((String)value); } break; case RESULT_TYPE: if (value == null) { unsetResultType(); } else { setResultType((String)value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case TID: return Short.valueOf(getTid()); case DATA: return getData(); case TYPE: return getType(); case RESULT_TYPE: return getResultType(); } throw new IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case TID: return isSetTid(); case DATA: return isSetData(); case TYPE: return isSetType(); case RESULT_TYPE: return isSetResultType(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof CaptchaTask) return this.equals((CaptchaTask)that); return false; } public boolean equals(CaptchaTask that) { if (that == null) return false; boolean this_present_tid = true; boolean that_present_tid = true; if (this_present_tid || that_present_tid) { if (!(this_present_tid && that_present_tid)) return false; if (this.tid != that.tid) return false; } boolean this_present_data = true && this.isSetData(); boolean that_present_data = true && that.isSetData(); if (this_present_data || that_present_data) { if (!(this_present_data && that_present_data)) return false; if (!this.data.equals(that.data)) return false; } boolean this_present_type = true && this.isSetType(); boolean that_present_type = true && that.isSetType(); if (this_present_type || that_present_type) { if (!(this_present_type && that_present_type)) return false; if (!this.type.equals(that.type)) return false; } boolean this_present_resultType = true && this.isSetResultType(); boolean that_present_resultType = true && that.isSetResultType(); if (this_present_resultType || that_present_resultType) { if (!(this_present_resultType && that_present_resultType)) return false; if (!this.resultType.equals(that.resultType)) return false; } return true; } @Override public int hashCode() { return 0; } public int compareTo(CaptchaTask other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; CaptchaTask typedOther = (CaptchaTask)other; lastComparison = Boolean.valueOf(isSetTid()).compareTo(typedOther.isSetTid()); if (lastComparison != 0) { return lastComparison; } if (isSetTid()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tid, typedOther.tid); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetData()).compareTo(typedOther.isSetData()); if (lastComparison != 0) { return lastComparison; } if (isSetData()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.data, typedOther.data); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetType()).compareTo(typedOther.isSetType()); if (lastComparison != 0) { return lastComparison; } if (isSetType()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, typedOther.type); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetResultType()).compareTo(typedOther.isSetResultType()); if (lastComparison != 0) { return lastComparison; } if (isSetResultType()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.resultType, typedOther.resultType); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { schemes.get(iprot.getScheme()).getScheme().read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { schemes.get(oprot.getScheme()).getScheme().write(oprot, this); } @Override public String toString() { StringBuilder sb = new StringBuilder("CaptchaTask("); boolean first = true; sb.append("tid:"); sb.append(this.tid); first = false; if (!first) sb.append(", "); sb.append("data:"); if (this.data == null) { sb.append("null"); } else { org.apache.thrift.TBaseHelper.toString(this.data, sb); } first = false; if (!first) sb.append(", "); sb.append("type:"); if (this.type == null) { sb.append("null"); } else { sb.append(this.type); } first = false; if (!first) sb.append(", "); sb.append("resultType:"); if (this.resultType == null) { sb.append("null"); } else { sb.append(this.resultType); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te.getMessage()); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bit_vector = new BitSet(1); read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te.getMessage()); } } private static class CaptchaTaskStandardSchemeFactory implements SchemeFactory { public CaptchaTaskStandardScheme getScheme() { return new CaptchaTaskStandardScheme(); } } private static class CaptchaTaskStandardScheme extends StandardScheme<CaptchaTask> { public void read(org.apache.thrift.protocol.TProtocol iprot, CaptchaTask 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: // TID if (schemeField.type == org.apache.thrift.protocol.TType.I16) { struct.tid = iprot.readI16(); struct.setTidIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // DATA if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.data = iprot.readBinary(); struct.setDataIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // TYPE if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.type = iprot.readString(); struct.setTypeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // RESULT_TYPE if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.resultType = iprot.readString(); struct.setResultTypeIsSet(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(); } public void write(org.apache.thrift.protocol.TProtocol oprot, CaptchaTask struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(TID_FIELD_DESC); oprot.writeI16(struct.tid); oprot.writeFieldEnd(); if (struct.data != null) { oprot.writeFieldBegin(DATA_FIELD_DESC); oprot.writeBinary(struct.data); oprot.writeFieldEnd(); } if (struct.type != null) { oprot.writeFieldBegin(TYPE_FIELD_DESC); oprot.writeString(struct.type); oprot.writeFieldEnd(); } if (struct.resultType != null) { oprot.writeFieldBegin(RESULT_TYPE_FIELD_DESC); oprot.writeString(struct.resultType); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class CaptchaTaskTupleSchemeFactory implements SchemeFactory { public CaptchaTaskTupleScheme getScheme() { return new CaptchaTaskTupleScheme(); } } private static class CaptchaTaskTupleScheme extends TupleScheme<CaptchaTask> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, CaptchaTask struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetTid()) { optionals.set(0); } if (struct.isSetData()) { optionals.set(1); } if (struct.isSetType()) { optionals.set(2); } if (struct.isSetResultType()) { optionals.set(3); } oprot.writeBitSet(optionals, 4); if (struct.isSetTid()) { oprot.writeI16(struct.tid); } if (struct.isSetData()) { oprot.writeBinary(struct.data); } if (struct.isSetType()) { oprot.writeString(struct.type); } if (struct.isSetResultType()) { oprot.writeString(struct.resultType); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, CaptchaTask struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(4); if (incoming.get(0)) { struct.tid = iprot.readI16(); struct.setTidIsSet(true); } if (incoming.get(1)) { struct.data = iprot.readBinary(); struct.setDataIsSet(true); } if (incoming.get(2)) { struct.type = iprot.readString(); struct.setTypeIsSet(true); } if (incoming.get(3)) { struct.resultType = iprot.readString(); struct.setResultTypeIsSet(true); } } } }