Back to home page

OSCL-LXR

 
 

    


0001 /**
0002  * Autogenerated by Thrift Compiler (0.9.0)
0003  *
0004  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
0005  *  @generated
0006  */
0007 package org.apache.hive.service.cli.thrift;
0008 
0009 import org.apache.commons.lang.builder.HashCodeBuilder;
0010 import org.apache.thrift.scheme.IScheme;
0011 import org.apache.thrift.scheme.SchemeFactory;
0012 import org.apache.thrift.scheme.StandardScheme;
0013 
0014 import org.apache.thrift.scheme.TupleScheme;
0015 import org.apache.thrift.protocol.TTupleProtocol;
0016 import org.apache.thrift.protocol.TProtocolException;
0017 import org.apache.thrift.EncodingUtils;
0018 import org.apache.thrift.TException;
0019 import java.util.List;
0020 import java.util.ArrayList;
0021 import java.util.Map;
0022 import java.util.HashMap;
0023 import java.util.EnumMap;
0024 import java.util.Set;
0025 import java.util.HashSet;
0026 import java.util.EnumSet;
0027 import java.util.Collections;
0028 import java.util.BitSet;
0029 import java.nio.ByteBuffer;
0030 import java.util.Arrays;
0031 import org.slf4j.Logger;
0032 import org.slf4j.LoggerFactory;
0033 
0034 public class TTypeDesc implements org.apache.thrift.TBase<TTypeDesc, TTypeDesc._Fields>, java.io.Serializable, Cloneable {
0035   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TTypeDesc");
0036 
0037   private static final org.apache.thrift.protocol.TField TYPES_FIELD_DESC = new org.apache.thrift.protocol.TField("types", org.apache.thrift.protocol.TType.LIST, (short)1);
0038 
0039   private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
0040   static {
0041     schemes.put(StandardScheme.class, new TTypeDescStandardSchemeFactory());
0042     schemes.put(TupleScheme.class, new TTypeDescTupleSchemeFactory());
0043   }
0044 
0045   private List<TTypeEntry> types; // required
0046 
0047   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
0048   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
0049     TYPES((short)1, "types");
0050 
0051     private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
0052 
0053     static {
0054       for (_Fields field : EnumSet.allOf(_Fields.class)) {
0055         byName.put(field.getFieldName(), field);
0056       }
0057     }
0058 
0059     /**
0060      * Find the _Fields constant that matches fieldId, or null if its not found.
0061      */
0062     public static _Fields findByThriftId(int fieldId) {
0063       switch(fieldId) {
0064         case 1: // TYPES
0065           return TYPES;
0066         default:
0067           return null;
0068       }
0069     }
0070 
0071     /**
0072      * Find the _Fields constant that matches fieldId, throwing an exception
0073      * if it is not found.
0074      */
0075     public static _Fields findByThriftIdOrThrow(int fieldId) {
0076       _Fields fields = findByThriftId(fieldId);
0077       if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
0078       return fields;
0079     }
0080 
0081     /**
0082      * Find the _Fields constant that matches name, or null if its not found.
0083      */
0084     public static _Fields findByName(String name) {
0085       return byName.get(name);
0086     }
0087 
0088     private final short _thriftId;
0089     private final String _fieldName;
0090 
0091     _Fields(short thriftId, String fieldName) {
0092       _thriftId = thriftId;
0093       _fieldName = fieldName;
0094     }
0095 
0096     public short getThriftFieldId() {
0097       return _thriftId;
0098     }
0099 
0100     public String getFieldName() {
0101       return _fieldName;
0102     }
0103   }
0104 
0105   // isset id assignments
0106   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
0107   static {
0108     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
0109     tmpMap.put(_Fields.TYPES, new org.apache.thrift.meta_data.FieldMetaData("types", org.apache.thrift.TFieldRequirementType.REQUIRED, 
0110         new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
0111             new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TTypeEntry.class))));
0112     metaDataMap = Collections.unmodifiableMap(tmpMap);
0113     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TTypeDesc.class, metaDataMap);
0114   }
0115 
0116   public TTypeDesc() {
0117   }
0118 
0119   public TTypeDesc(
0120     List<TTypeEntry> types)
0121   {
0122     this();
0123     this.types = types;
0124   }
0125 
0126   /**
0127    * Performs a deep copy on <i>other</i>.
0128    */
0129   public TTypeDesc(TTypeDesc other) {
0130     if (other.isSetTypes()) {
0131       List<TTypeEntry> __this__types = new ArrayList<TTypeEntry>();
0132       for (TTypeEntry other_element : other.types) {
0133         __this__types.add(new TTypeEntry(other_element));
0134       }
0135       this.types = __this__types;
0136     }
0137   }
0138 
0139   public TTypeDesc deepCopy() {
0140     return new TTypeDesc(this);
0141   }
0142 
0143   @Override
0144   public void clear() {
0145     this.types = null;
0146   }
0147 
0148   public int getTypesSize() {
0149     return (this.types == null) ? 0 : this.types.size();
0150   }
0151 
0152   public java.util.Iterator<TTypeEntry> getTypesIterator() {
0153     return (this.types == null) ? null : this.types.iterator();
0154   }
0155 
0156   public void addToTypes(TTypeEntry elem) {
0157     if (this.types == null) {
0158       this.types = new ArrayList<TTypeEntry>();
0159     }
0160     this.types.add(elem);
0161   }
0162 
0163   public List<TTypeEntry> getTypes() {
0164     return this.types;
0165   }
0166 
0167   public void setTypes(List<TTypeEntry> types) {
0168     this.types = types;
0169   }
0170 
0171   public void unsetTypes() {
0172     this.types = null;
0173   }
0174 
0175   /** Returns true if field types is set (has been assigned a value) and false otherwise */
0176   public boolean isSetTypes() {
0177     return this.types != null;
0178   }
0179 
0180   public void setTypesIsSet(boolean value) {
0181     if (!value) {
0182       this.types = null;
0183     }
0184   }
0185 
0186   public void setFieldValue(_Fields field, Object value) {
0187     switch (field) {
0188     case TYPES:
0189       if (value == null) {
0190         unsetTypes();
0191       } else {
0192         setTypes((List<TTypeEntry>)value);
0193       }
0194       break;
0195 
0196     }
0197   }
0198 
0199   public Object getFieldValue(_Fields field) {
0200     switch (field) {
0201     case TYPES:
0202       return getTypes();
0203 
0204     }
0205     throw new IllegalStateException();
0206   }
0207 
0208   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
0209   public boolean isSet(_Fields field) {
0210     if (field == null) {
0211       throw new IllegalArgumentException();
0212     }
0213 
0214     switch (field) {
0215     case TYPES:
0216       return isSetTypes();
0217     }
0218     throw new IllegalStateException();
0219   }
0220 
0221   @Override
0222   public boolean equals(Object that) {
0223     if (that == null)
0224       return false;
0225     if (that instanceof TTypeDesc)
0226       return this.equals((TTypeDesc)that);
0227     return false;
0228   }
0229 
0230   public boolean equals(TTypeDesc that) {
0231     if (that == null)
0232       return false;
0233 
0234     boolean this_present_types = true && this.isSetTypes();
0235     boolean that_present_types = true && that.isSetTypes();
0236     if (this_present_types || that_present_types) {
0237       if (!(this_present_types && that_present_types))
0238         return false;
0239       if (!this.types.equals(that.types))
0240         return false;
0241     }
0242 
0243     return true;
0244   }
0245 
0246   @Override
0247   public int hashCode() {
0248     HashCodeBuilder builder = new HashCodeBuilder();
0249 
0250     boolean present_types = true && (isSetTypes());
0251     builder.append(present_types);
0252     if (present_types)
0253       builder.append(types);
0254 
0255     return builder.toHashCode();
0256   }
0257 
0258   public int compareTo(TTypeDesc other) {
0259     if (!getClass().equals(other.getClass())) {
0260       return getClass().getName().compareTo(other.getClass().getName());
0261     }
0262 
0263     int lastComparison = 0;
0264     TTypeDesc typedOther = (TTypeDesc)other;
0265 
0266     lastComparison = Boolean.valueOf(isSetTypes()).compareTo(typedOther.isSetTypes());
0267     if (lastComparison != 0) {
0268       return lastComparison;
0269     }
0270     if (isSetTypes()) {
0271       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.types, typedOther.types);
0272       if (lastComparison != 0) {
0273         return lastComparison;
0274       }
0275     }
0276     return 0;
0277   }
0278 
0279   public _Fields fieldForId(int fieldId) {
0280     return _Fields.findByThriftId(fieldId);
0281   }
0282 
0283   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
0284     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
0285   }
0286 
0287   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
0288     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
0289   }
0290 
0291   @Override
0292   public String toString() {
0293     StringBuilder sb = new StringBuilder("TTypeDesc(");
0294     boolean first = true;
0295 
0296     sb.append("types:");
0297     if (this.types == null) {
0298       sb.append("null");
0299     } else {
0300       sb.append(this.types);
0301     }
0302     first = false;
0303     sb.append(")");
0304     return sb.toString();
0305   }
0306 
0307   public void validate() throws org.apache.thrift.TException {
0308     // check for required fields
0309     if (!isSetTypes()) {
0310       throw new org.apache.thrift.protocol.TProtocolException("Required field 'types' is unset! Struct:" + toString());
0311     }
0312 
0313     // check for sub-struct validity
0314   }
0315 
0316   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
0317     try {
0318       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
0319     } catch (org.apache.thrift.TException te) {
0320       throw new java.io.IOException(te);
0321     }
0322   }
0323 
0324   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
0325     try {
0326       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
0327     } catch (org.apache.thrift.TException te) {
0328       throw new java.io.IOException(te);
0329     }
0330   }
0331 
0332   private static class TTypeDescStandardSchemeFactory implements SchemeFactory {
0333     public TTypeDescStandardScheme getScheme() {
0334       return new TTypeDescStandardScheme();
0335     }
0336   }
0337 
0338   private static class TTypeDescStandardScheme extends StandardScheme<TTypeDesc> {
0339 
0340     public void read(org.apache.thrift.protocol.TProtocol iprot, TTypeDesc struct) throws org.apache.thrift.TException {
0341       org.apache.thrift.protocol.TField schemeField;
0342       iprot.readStructBegin();
0343       while (true)
0344       {
0345         schemeField = iprot.readFieldBegin();
0346         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
0347           break;
0348         }
0349         switch (schemeField.id) {
0350           case 1: // TYPES
0351             if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
0352               {
0353                 org.apache.thrift.protocol.TList _list30 = iprot.readListBegin();
0354                 struct.types = new ArrayList<TTypeEntry>(_list30.size);
0355                 for (int _i31 = 0; _i31 < _list30.size; ++_i31)
0356                 {
0357                   TTypeEntry _elem32; // optional
0358                   _elem32 = new TTypeEntry();
0359                   _elem32.read(iprot);
0360                   struct.types.add(_elem32);
0361                 }
0362                 iprot.readListEnd();
0363               }
0364               struct.setTypesIsSet(true);
0365             } else { 
0366               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0367             }
0368             break;
0369           default:
0370             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0371         }
0372         iprot.readFieldEnd();
0373       }
0374       iprot.readStructEnd();
0375       struct.validate();
0376     }
0377 
0378     public void write(org.apache.thrift.protocol.TProtocol oprot, TTypeDesc struct) throws org.apache.thrift.TException {
0379       struct.validate();
0380 
0381       oprot.writeStructBegin(STRUCT_DESC);
0382       if (struct.types != null) {
0383         oprot.writeFieldBegin(TYPES_FIELD_DESC);
0384         {
0385           oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.types.size()));
0386           for (TTypeEntry _iter33 : struct.types)
0387           {
0388             _iter33.write(oprot);
0389           }
0390           oprot.writeListEnd();
0391         }
0392         oprot.writeFieldEnd();
0393       }
0394       oprot.writeFieldStop();
0395       oprot.writeStructEnd();
0396     }
0397 
0398   }
0399 
0400   private static class TTypeDescTupleSchemeFactory implements SchemeFactory {
0401     public TTypeDescTupleScheme getScheme() {
0402       return new TTypeDescTupleScheme();
0403     }
0404   }
0405 
0406   private static class TTypeDescTupleScheme extends TupleScheme<TTypeDesc> {
0407 
0408     @Override
0409     public void write(org.apache.thrift.protocol.TProtocol prot, TTypeDesc struct) throws org.apache.thrift.TException {
0410       TTupleProtocol oprot = (TTupleProtocol) prot;
0411       {
0412         oprot.writeI32(struct.types.size());
0413         for (TTypeEntry _iter34 : struct.types)
0414         {
0415           _iter34.write(oprot);
0416         }
0417       }
0418     }
0419 
0420     @Override
0421     public void read(org.apache.thrift.protocol.TProtocol prot, TTypeDesc struct) throws org.apache.thrift.TException {
0422       TTupleProtocol iprot = (TTupleProtocol) prot;
0423       {
0424         org.apache.thrift.protocol.TList _list35 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
0425         struct.types = new ArrayList<TTypeEntry>(_list35.size);
0426         for (int _i36 = 0; _i36 < _list35.size; ++_i36)
0427         {
0428           TTypeEntry _elem37; // optional
0429           _elem37 = new TTypeEntry();
0430           _elem37.read(iprot);
0431           struct.types.add(_elem37);
0432         }
0433       }
0434       struct.setTypesIsSet(true);
0435     }
0436   }
0437 
0438 }
0439