/** * Autogenerated by Thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING */ package com.flaptor.indextank.rpc; 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; import org.apache.thrift.*; import org.apache.thrift.async.*; import org.apache.thrift.meta_data.*; import org.apache.thrift.transport.*; import org.apache.thrift.protocol.*; @SuppressWarnings("all") public class Document implements TBase<Document, Document._Fields>, java.io.Serializable, Cloneable { private static final TStruct STRUCT_DESC = new TStruct("Document"); private static final TField FIELDS_FIELD_DESC = new TField("fields", TType.MAP, (short)1); private Map<String,String> fields; /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements TFieldIdEnum { FIELDS((short)1, "fields"); 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: // FIELDS return FIELDS; 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 public static final Map<_Fields, FieldMetaData> metaDataMap; static { Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class); tmpMap.put(_Fields.FIELDS, new FieldMetaData("fields", TFieldRequirementType.DEFAULT, new MapMetaData(TType.MAP, new FieldValueMetaData(TType.STRING), new FieldValueMetaData(TType.STRING)))); metaDataMap = Collections.unmodifiableMap(tmpMap); FieldMetaData.addStructMetaDataMap(Document.class, metaDataMap); } public Document() { } public Document( Map<String,String> fields) { this(); this.fields = fields; } /** * Performs a deep copy on <i>other</i>. */ public Document(Document other) { if (other.is_set_fields()) { Map<String,String> __this__fields = new HashMap<String,String>(); for (Map.Entry<String, String> other_element : other.fields.entrySet()) { String other_element_key = other_element.getKey(); String other_element_value = other_element.getValue(); String __this__fields_copy_key = other_element_key; String __this__fields_copy_value = other_element_value; __this__fields.put(__this__fields_copy_key, __this__fields_copy_value); } this.fields = __this__fields; } } public Document deepCopy() { return new Document(this); } @Override public void clear() { this.fields = null; } public int get_fields_size() { return (this.fields == null) ? 0 : this.fields.size(); } public void put_to_fields(String key, String val) { if (this.fields == null) { this.fields = new HashMap<String,String>(); } this.fields.put(key, val); } public Map<String,String> get_fields() { return this.fields; } public Document set_fields(Map<String,String> fields) { this.fields = fields; return this; } public void unset_fields() { this.fields = null; } /** Returns true if field fields is set (has been asigned a value) and false otherwise */ public boolean is_set_fields() { return this.fields != null; } public void set_fields_isSet(boolean value) { if (!value) { this.fields = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case FIELDS: if (value == null) { unset_fields(); } else { set_fields((Map<String,String>)value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case FIELDS: return get_fields(); } throw new IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case FIELDS: return is_set_fields(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof Document) return this.equals((Document)that); return false; } public boolean equals(Document that) { if (that == null) return false; boolean this_present_fields = true && this.is_set_fields(); boolean that_present_fields = true && that.is_set_fields(); if (this_present_fields || that_present_fields) { if (!(this_present_fields && that_present_fields)) return false; if (!this.fields.equals(that.fields)) return false; } return true; } @Override public int hashCode() { return 0; } public int compareTo(Document other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; Document typedOther = (Document)other; lastComparison = Boolean.valueOf(is_set_fields()).compareTo(typedOther.is_set_fields()); if (lastComparison != 0) { return lastComparison; } if (is_set_fields()) { lastComparison = TBaseHelper.compareTo(this.fields, typedOther.fields); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(TProtocol iprot) throws TException { TField field; iprot.readStructBegin(); while (true) { field = iprot.readFieldBegin(); if (field.type == TType.STOP) { break; } switch (field.id) { case 1: // FIELDS if (field.type == TType.MAP) { { TMap _map0 = iprot.readMapBegin(); this.fields = new HashMap<String,String>(2*_map0.size); for (int _i1 = 0; _i1 < _map0.size; ++_i1) { String _key2; String _val3; _key2 = iprot.readString(); _val3 = iprot.readString(); this.fields.put(_key2, _val3); } iprot.readMapEnd(); } } else { TProtocolUtil.skip(iprot, field.type); } break; default: TProtocolUtil.skip(iprot, field.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method validate(); } public void write(TProtocol oprot) throws TException { validate(); oprot.writeStructBegin(STRUCT_DESC); if (this.fields != null) { oprot.writeFieldBegin(FIELDS_FIELD_DESC); { oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING, this.fields.size())); for (Map.Entry<String, String> _iter4 : this.fields.entrySet()) { oprot.writeString(_iter4.getKey()); oprot.writeString(_iter4.getValue()); } oprot.writeMapEnd(); } oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } @Override public String toString() { StringBuilder sb = new StringBuilder("Document("); boolean first = true; sb.append("fields:"); if (this.fields == null) { sb.append("null"); } else { sb.append(this.fields); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws TException { // check for required fields } }