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 TUnionTypeEntry implements org.apache.thrift.TBase<TUnionTypeEntry, TUnionTypeEntry._Fields>, java.io.Serializable, Cloneable {
0035   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TUnionTypeEntry");
0036 
0037   private static final org.apache.thrift.protocol.TField NAME_TO_TYPE_PTR_FIELD_DESC = new org.apache.thrift.protocol.TField("nameToTypePtr", org.apache.thrift.protocol.TType.MAP, (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 TUnionTypeEntryStandardSchemeFactory());
0042     schemes.put(TupleScheme.class, new TUnionTypeEntryTupleSchemeFactory());
0043   }
0044 
0045   private Map<String,Integer> nameToTypePtr; // 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     NAME_TO_TYPE_PTR((short)1, "nameToTypePtr");
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: // NAME_TO_TYPE_PTR
0065           return NAME_TO_TYPE_PTR;
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.NAME_TO_TYPE_PTR, new org.apache.thrift.meta_data.FieldMetaData("nameToTypePtr", org.apache.thrift.TFieldRequirementType.REQUIRED, 
0110         new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, 
0111             new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), 
0112             new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32            , "TTypeEntryPtr"))));
0113     metaDataMap = Collections.unmodifiableMap(tmpMap);
0114     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TUnionTypeEntry.class, metaDataMap);
0115   }
0116 
0117   public TUnionTypeEntry() {
0118   }
0119 
0120   public TUnionTypeEntry(
0121     Map<String,Integer> nameToTypePtr)
0122   {
0123     this();
0124     this.nameToTypePtr = nameToTypePtr;
0125   }
0126 
0127   /**
0128    * Performs a deep copy on <i>other</i>.
0129    */
0130   public TUnionTypeEntry(TUnionTypeEntry other) {
0131     if (other.isSetNameToTypePtr()) {
0132       Map<String,Integer> __this__nameToTypePtr = new HashMap<String,Integer>();
0133       for (Map.Entry<String, Integer> other_element : other.nameToTypePtr.entrySet()) {
0134 
0135         String other_element_key = other_element.getKey();
0136         Integer other_element_value = other_element.getValue();
0137 
0138         String __this__nameToTypePtr_copy_key = other_element_key;
0139 
0140         Integer __this__nameToTypePtr_copy_value = other_element_value;
0141 
0142         __this__nameToTypePtr.put(__this__nameToTypePtr_copy_key, __this__nameToTypePtr_copy_value);
0143       }
0144       this.nameToTypePtr = __this__nameToTypePtr;
0145     }
0146   }
0147 
0148   public TUnionTypeEntry deepCopy() {
0149     return new TUnionTypeEntry(this);
0150   }
0151 
0152   @Override
0153   public void clear() {
0154     this.nameToTypePtr = null;
0155   }
0156 
0157   public int getNameToTypePtrSize() {
0158     return (this.nameToTypePtr == null) ? 0 : this.nameToTypePtr.size();
0159   }
0160 
0161   public void putToNameToTypePtr(String key, int val) {
0162     if (this.nameToTypePtr == null) {
0163       this.nameToTypePtr = new HashMap<String,Integer>();
0164     }
0165     this.nameToTypePtr.put(key, val);
0166   }
0167 
0168   public Map<String,Integer> getNameToTypePtr() {
0169     return this.nameToTypePtr;
0170   }
0171 
0172   public void setNameToTypePtr(Map<String,Integer> nameToTypePtr) {
0173     this.nameToTypePtr = nameToTypePtr;
0174   }
0175 
0176   public void unsetNameToTypePtr() {
0177     this.nameToTypePtr = null;
0178   }
0179 
0180   /** Returns true if field nameToTypePtr is set (has been assigned a value) and false otherwise */
0181   public boolean isSetNameToTypePtr() {
0182     return this.nameToTypePtr != null;
0183   }
0184 
0185   public void setNameToTypePtrIsSet(boolean value) {
0186     if (!value) {
0187       this.nameToTypePtr = null;
0188     }
0189   }
0190 
0191   public void setFieldValue(_Fields field, Object value) {
0192     switch (field) {
0193     case NAME_TO_TYPE_PTR:
0194       if (value == null) {
0195         unsetNameToTypePtr();
0196       } else {
0197         setNameToTypePtr((Map<String,Integer>)value);
0198       }
0199       break;
0200 
0201     }
0202   }
0203 
0204   public Object getFieldValue(_Fields field) {
0205     switch (field) {
0206     case NAME_TO_TYPE_PTR:
0207       return getNameToTypePtr();
0208 
0209     }
0210     throw new IllegalStateException();
0211   }
0212 
0213   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
0214   public boolean isSet(_Fields field) {
0215     if (field == null) {
0216       throw new IllegalArgumentException();
0217     }
0218 
0219     switch (field) {
0220     case NAME_TO_TYPE_PTR:
0221       return isSetNameToTypePtr();
0222     }
0223     throw new IllegalStateException();
0224   }
0225 
0226   @Override
0227   public boolean equals(Object that) {
0228     if (that == null)
0229       return false;
0230     if (that instanceof TUnionTypeEntry)
0231       return this.equals((TUnionTypeEntry)that);
0232     return false;
0233   }
0234 
0235   public boolean equals(TUnionTypeEntry that) {
0236     if (that == null)
0237       return false;
0238 
0239     boolean this_present_nameToTypePtr = true && this.isSetNameToTypePtr();
0240     boolean that_present_nameToTypePtr = true && that.isSetNameToTypePtr();
0241     if (this_present_nameToTypePtr || that_present_nameToTypePtr) {
0242       if (!(this_present_nameToTypePtr && that_present_nameToTypePtr))
0243         return false;
0244       if (!this.nameToTypePtr.equals(that.nameToTypePtr))
0245         return false;
0246     }
0247 
0248     return true;
0249   }
0250 
0251   @Override
0252   public int hashCode() {
0253     HashCodeBuilder builder = new HashCodeBuilder();
0254 
0255     boolean present_nameToTypePtr = true && (isSetNameToTypePtr());
0256     builder.append(present_nameToTypePtr);
0257     if (present_nameToTypePtr)
0258       builder.append(nameToTypePtr);
0259 
0260     return builder.toHashCode();
0261   }
0262 
0263   public int compareTo(TUnionTypeEntry other) {
0264     if (!getClass().equals(other.getClass())) {
0265       return getClass().getName().compareTo(other.getClass().getName());
0266     }
0267 
0268     int lastComparison = 0;
0269     TUnionTypeEntry typedOther = (TUnionTypeEntry)other;
0270 
0271     lastComparison = Boolean.valueOf(isSetNameToTypePtr()).compareTo(typedOther.isSetNameToTypePtr());
0272     if (lastComparison != 0) {
0273       return lastComparison;
0274     }
0275     if (isSetNameToTypePtr()) {
0276       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.nameToTypePtr, typedOther.nameToTypePtr);
0277       if (lastComparison != 0) {
0278         return lastComparison;
0279       }
0280     }
0281     return 0;
0282   }
0283 
0284   public _Fields fieldForId(int fieldId) {
0285     return _Fields.findByThriftId(fieldId);
0286   }
0287 
0288   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
0289     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
0290   }
0291 
0292   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
0293     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
0294   }
0295 
0296   @Override
0297   public String toString() {
0298     StringBuilder sb = new StringBuilder("TUnionTypeEntry(");
0299     boolean first = true;
0300 
0301     sb.append("nameToTypePtr:");
0302     if (this.nameToTypePtr == null) {
0303       sb.append("null");
0304     } else {
0305       sb.append(this.nameToTypePtr);
0306     }
0307     first = false;
0308     sb.append(")");
0309     return sb.toString();
0310   }
0311 
0312   public void validate() throws org.apache.thrift.TException {
0313     // check for required fields
0314     if (!isSetNameToTypePtr()) {
0315       throw new org.apache.thrift.protocol.TProtocolException("Required field 'nameToTypePtr' is unset! Struct:" + toString());
0316     }
0317 
0318     // check for sub-struct validity
0319   }
0320 
0321   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
0322     try {
0323       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
0324     } catch (org.apache.thrift.TException te) {
0325       throw new java.io.IOException(te);
0326     }
0327   }
0328 
0329   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
0330     try {
0331       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
0332     } catch (org.apache.thrift.TException te) {
0333       throw new java.io.IOException(te);
0334     }
0335   }
0336 
0337   private static class TUnionTypeEntryStandardSchemeFactory implements SchemeFactory {
0338     public TUnionTypeEntryStandardScheme getScheme() {
0339       return new TUnionTypeEntryStandardScheme();
0340     }
0341   }
0342 
0343   private static class TUnionTypeEntryStandardScheme extends StandardScheme<TUnionTypeEntry> {
0344 
0345     public void read(org.apache.thrift.protocol.TProtocol iprot, TUnionTypeEntry struct) throws org.apache.thrift.TException {
0346       org.apache.thrift.protocol.TField schemeField;
0347       iprot.readStructBegin();
0348       while (true)
0349       {
0350         schemeField = iprot.readFieldBegin();
0351         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
0352           break;
0353         }
0354         switch (schemeField.id) {
0355           case 1: // NAME_TO_TYPE_PTR
0356             if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
0357               {
0358                 org.apache.thrift.protocol.TMap _map20 = iprot.readMapBegin();
0359                 struct.nameToTypePtr = new HashMap<String,Integer>(2*_map20.size);
0360                 for (int _i21 = 0; _i21 < _map20.size; ++_i21)
0361                 {
0362                   String _key22; // required
0363                   int _val23; // required
0364                   _key22 = iprot.readString();
0365                   _val23 = iprot.readI32();
0366                   struct.nameToTypePtr.put(_key22, _val23);
0367                 }
0368                 iprot.readMapEnd();
0369               }
0370               struct.setNameToTypePtrIsSet(true);
0371             } else { 
0372               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0373             }
0374             break;
0375           default:
0376             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0377         }
0378         iprot.readFieldEnd();
0379       }
0380       iprot.readStructEnd();
0381       struct.validate();
0382     }
0383 
0384     public void write(org.apache.thrift.protocol.TProtocol oprot, TUnionTypeEntry struct) throws org.apache.thrift.TException {
0385       struct.validate();
0386 
0387       oprot.writeStructBegin(STRUCT_DESC);
0388       if (struct.nameToTypePtr != null) {
0389         oprot.writeFieldBegin(NAME_TO_TYPE_PTR_FIELD_DESC);
0390         {
0391           oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.I32, struct.nameToTypePtr.size()));
0392           for (Map.Entry<String, Integer> _iter24 : struct.nameToTypePtr.entrySet())
0393           {
0394             oprot.writeString(_iter24.getKey());
0395             oprot.writeI32(_iter24.getValue());
0396           }
0397           oprot.writeMapEnd();
0398         }
0399         oprot.writeFieldEnd();
0400       }
0401       oprot.writeFieldStop();
0402       oprot.writeStructEnd();
0403     }
0404 
0405   }
0406 
0407   private static class TUnionTypeEntryTupleSchemeFactory implements SchemeFactory {
0408     public TUnionTypeEntryTupleScheme getScheme() {
0409       return new TUnionTypeEntryTupleScheme();
0410     }
0411   }
0412 
0413   private static class TUnionTypeEntryTupleScheme extends TupleScheme<TUnionTypeEntry> {
0414 
0415     @Override
0416     public void write(org.apache.thrift.protocol.TProtocol prot, TUnionTypeEntry struct) throws org.apache.thrift.TException {
0417       TTupleProtocol oprot = (TTupleProtocol) prot;
0418       {
0419         oprot.writeI32(struct.nameToTypePtr.size());
0420         for (Map.Entry<String, Integer> _iter25 : struct.nameToTypePtr.entrySet())
0421         {
0422           oprot.writeString(_iter25.getKey());
0423           oprot.writeI32(_iter25.getValue());
0424         }
0425       }
0426     }
0427 
0428     @Override
0429     public void read(org.apache.thrift.protocol.TProtocol prot, TUnionTypeEntry struct) throws org.apache.thrift.TException {
0430       TTupleProtocol iprot = (TTupleProtocol) prot;
0431       {
0432         org.apache.thrift.protocol.TMap _map26 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.I32, iprot.readI32());
0433         struct.nameToTypePtr = new HashMap<String,Integer>(2*_map26.size);
0434         for (int _i27 = 0; _i27 < _map26.size; ++_i27)
0435         {
0436           String _key28; // required
0437           int _val29; // required
0438           _key28 = iprot.readString();
0439           _val29 = iprot.readI32();
0440           struct.nameToTypePtr.put(_key28, _val29);
0441         }
0442       }
0443       struct.setNameToTypePtrIsSet(true);
0444     }
0445   }
0446 
0447 }
0448