Back to home page

OSCL-LXR

 
 

    


0001 /**
0002  * Autogenerated by Thrift Compiler (0.9.3)
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.rpc.thrift;
0008 
0009 import org.apache.thrift.scheme.IScheme;
0010 import org.apache.thrift.scheme.SchemeFactory;
0011 import org.apache.thrift.scheme.StandardScheme;
0012 
0013 import org.apache.thrift.scheme.TupleScheme;
0014 import org.apache.thrift.protocol.TTupleProtocol;
0015 import org.apache.thrift.protocol.TProtocolException;
0016 import org.apache.thrift.EncodingUtils;
0017 import org.apache.thrift.TException;
0018 import org.apache.thrift.async.AsyncMethodCallback;
0019 import org.apache.thrift.server.AbstractNonblockingServer.*;
0020 import java.util.List;
0021 import java.util.ArrayList;
0022 import java.util.Map;
0023 import java.util.HashMap;
0024 import java.util.EnumMap;
0025 import java.util.Set;
0026 import java.util.HashSet;
0027 import java.util.EnumSet;
0028 import java.util.Collections;
0029 import java.util.BitSet;
0030 import java.nio.ByteBuffer;
0031 import java.util.Arrays;
0032 import javax.annotation.Generated;
0033 import org.slf4j.Logger;
0034 import org.slf4j.LoggerFactory;
0035 
0036 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
0037 @Generated(value = "Autogenerated by Thrift Compiler (0.9.3)")
0038 public class THandleIdentifier implements org.apache.thrift.TBase<THandleIdentifier, THandleIdentifier._Fields>, java.io.Serializable, Cloneable, Comparable<THandleIdentifier> {
0039   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("THandleIdentifier");
0040 
0041   private static final org.apache.thrift.protocol.TField GUID_FIELD_DESC = new org.apache.thrift.protocol.TField("guid", org.apache.thrift.protocol.TType.STRING, (short)1);
0042   private static final org.apache.thrift.protocol.TField SECRET_FIELD_DESC = new org.apache.thrift.protocol.TField("secret", org.apache.thrift.protocol.TType.STRING, (short)2);
0043 
0044   private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
0045   static {
0046     schemes.put(StandardScheme.class, new THandleIdentifierStandardSchemeFactory());
0047     schemes.put(TupleScheme.class, new THandleIdentifierTupleSchemeFactory());
0048   }
0049 
0050   private ByteBuffer guid; // required
0051   private ByteBuffer secret; // required
0052 
0053   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
0054   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
0055     GUID((short)1, "guid"),
0056     SECRET((short)2, "secret");
0057 
0058     private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
0059 
0060     static {
0061       for (_Fields field : EnumSet.allOf(_Fields.class)) {
0062         byName.put(field.getFieldName(), field);
0063       }
0064     }
0065 
0066     /**
0067      * Find the _Fields constant that matches fieldId, or null if its not found.
0068      */
0069     public static _Fields findByThriftId(int fieldId) {
0070       switch(fieldId) {
0071         case 1: // GUID
0072           return GUID;
0073         case 2: // SECRET
0074           return SECRET;
0075         default:
0076           return null;
0077       }
0078     }
0079 
0080     /**
0081      * Find the _Fields constant that matches fieldId, throwing an exception
0082      * if it is not found.
0083      */
0084     public static _Fields findByThriftIdOrThrow(int fieldId) {
0085       _Fields fields = findByThriftId(fieldId);
0086       if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
0087       return fields;
0088     }
0089 
0090     /**
0091      * Find the _Fields constant that matches name, or null if its not found.
0092      */
0093     public static _Fields findByName(String name) {
0094       return byName.get(name);
0095     }
0096 
0097     private final short _thriftId;
0098     private final String _fieldName;
0099 
0100     _Fields(short thriftId, String fieldName) {
0101       _thriftId = thriftId;
0102       _fieldName = fieldName;
0103     }
0104 
0105     public short getThriftFieldId() {
0106       return _thriftId;
0107     }
0108 
0109     public String getFieldName() {
0110       return _fieldName;
0111     }
0112   }
0113 
0114   // isset id assignments
0115   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
0116   static {
0117     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
0118     tmpMap.put(_Fields.GUID, new org.apache.thrift.meta_data.FieldMetaData("guid", org.apache.thrift.TFieldRequirementType.REQUIRED, 
0119         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
0120     tmpMap.put(_Fields.SECRET, new org.apache.thrift.meta_data.FieldMetaData("secret", org.apache.thrift.TFieldRequirementType.REQUIRED, 
0121         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
0122     metaDataMap = Collections.unmodifiableMap(tmpMap);
0123     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(THandleIdentifier.class, metaDataMap);
0124   }
0125 
0126   public THandleIdentifier() {
0127   }
0128 
0129   public THandleIdentifier(
0130     ByteBuffer guid,
0131     ByteBuffer secret)
0132   {
0133     this();
0134     this.guid = org.apache.thrift.TBaseHelper.copyBinary(guid);
0135     this.secret = org.apache.thrift.TBaseHelper.copyBinary(secret);
0136   }
0137 
0138   /**
0139    * Performs a deep copy on <i>other</i>.
0140    */
0141   public THandleIdentifier(THandleIdentifier other) {
0142     if (other.isSetGuid()) {
0143       this.guid = org.apache.thrift.TBaseHelper.copyBinary(other.guid);
0144     }
0145     if (other.isSetSecret()) {
0146       this.secret = org.apache.thrift.TBaseHelper.copyBinary(other.secret);
0147     }
0148   }
0149 
0150   public THandleIdentifier deepCopy() {
0151     return new THandleIdentifier(this);
0152   }
0153 
0154   @Override
0155   public void clear() {
0156     this.guid = null;
0157     this.secret = null;
0158   }
0159 
0160   public byte[] getGuid() {
0161     setGuid(org.apache.thrift.TBaseHelper.rightSize(guid));
0162     return guid == null ? null : guid.array();
0163   }
0164 
0165   public ByteBuffer bufferForGuid() {
0166     return org.apache.thrift.TBaseHelper.copyBinary(guid);
0167   }
0168 
0169   public void setGuid(byte[] guid) {
0170     this.guid = guid == null ? (ByteBuffer)null : ByteBuffer.wrap(Arrays.copyOf(guid, guid.length));
0171   }
0172 
0173   public void setGuid(ByteBuffer guid) {
0174     this.guid = org.apache.thrift.TBaseHelper.copyBinary(guid);
0175   }
0176 
0177   public void unsetGuid() {
0178     this.guid = null;
0179   }
0180 
0181   /** Returns true if field guid is set (has been assigned a value) and false otherwise */
0182   public boolean isSetGuid() {
0183     return this.guid != null;
0184   }
0185 
0186   public void setGuidIsSet(boolean value) {
0187     if (!value) {
0188       this.guid = null;
0189     }
0190   }
0191 
0192   public byte[] getSecret() {
0193     setSecret(org.apache.thrift.TBaseHelper.rightSize(secret));
0194     return secret == null ? null : secret.array();
0195   }
0196 
0197   public ByteBuffer bufferForSecret() {
0198     return org.apache.thrift.TBaseHelper.copyBinary(secret);
0199   }
0200 
0201   public void setSecret(byte[] secret) {
0202     this.secret = secret == null ? (ByteBuffer)null : ByteBuffer.wrap(Arrays.copyOf(secret, secret.length));
0203   }
0204 
0205   public void setSecret(ByteBuffer secret) {
0206     this.secret = org.apache.thrift.TBaseHelper.copyBinary(secret);
0207   }
0208 
0209   public void unsetSecret() {
0210     this.secret = null;
0211   }
0212 
0213   /** Returns true if field secret is set (has been assigned a value) and false otherwise */
0214   public boolean isSetSecret() {
0215     return this.secret != null;
0216   }
0217 
0218   public void setSecretIsSet(boolean value) {
0219     if (!value) {
0220       this.secret = null;
0221     }
0222   }
0223 
0224   public void setFieldValue(_Fields field, Object value) {
0225     switch (field) {
0226     case GUID:
0227       if (value == null) {
0228         unsetGuid();
0229       } else {
0230         setGuid((ByteBuffer)value);
0231       }
0232       break;
0233 
0234     case SECRET:
0235       if (value == null) {
0236         unsetSecret();
0237       } else {
0238         setSecret((ByteBuffer)value);
0239       }
0240       break;
0241 
0242     }
0243   }
0244 
0245   public Object getFieldValue(_Fields field) {
0246     switch (field) {
0247     case GUID:
0248       return getGuid();
0249 
0250     case SECRET:
0251       return getSecret();
0252 
0253     }
0254     throw new IllegalStateException();
0255   }
0256 
0257   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
0258   public boolean isSet(_Fields field) {
0259     if (field == null) {
0260       throw new IllegalArgumentException();
0261     }
0262 
0263     switch (field) {
0264     case GUID:
0265       return isSetGuid();
0266     case SECRET:
0267       return isSetSecret();
0268     }
0269     throw new IllegalStateException();
0270   }
0271 
0272   @Override
0273   public boolean equals(Object that) {
0274     if (that == null)
0275       return false;
0276     if (that instanceof THandleIdentifier)
0277       return this.equals((THandleIdentifier)that);
0278     return false;
0279   }
0280 
0281   public boolean equals(THandleIdentifier that) {
0282     if (that == null)
0283       return false;
0284 
0285     boolean this_present_guid = true && this.isSetGuid();
0286     boolean that_present_guid = true && that.isSetGuid();
0287     if (this_present_guid || that_present_guid) {
0288       if (!(this_present_guid && that_present_guid))
0289         return false;
0290       if (!this.guid.equals(that.guid))
0291         return false;
0292     }
0293 
0294     boolean this_present_secret = true && this.isSetSecret();
0295     boolean that_present_secret = true && that.isSetSecret();
0296     if (this_present_secret || that_present_secret) {
0297       if (!(this_present_secret && that_present_secret))
0298         return false;
0299       if (!this.secret.equals(that.secret))
0300         return false;
0301     }
0302 
0303     return true;
0304   }
0305 
0306   @Override
0307   public int hashCode() {
0308     List<Object> list = new ArrayList<Object>();
0309 
0310     boolean present_guid = true && (isSetGuid());
0311     list.add(present_guid);
0312     if (present_guid)
0313       list.add(guid);
0314 
0315     boolean present_secret = true && (isSetSecret());
0316     list.add(present_secret);
0317     if (present_secret)
0318       list.add(secret);
0319 
0320     return list.hashCode();
0321   }
0322 
0323   @Override
0324   public int compareTo(THandleIdentifier other) {
0325     if (!getClass().equals(other.getClass())) {
0326       return getClass().getName().compareTo(other.getClass().getName());
0327     }
0328 
0329     int lastComparison = 0;
0330 
0331     lastComparison = Boolean.valueOf(isSetGuid()).compareTo(other.isSetGuid());
0332     if (lastComparison != 0) {
0333       return lastComparison;
0334     }
0335     if (isSetGuid()) {
0336       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.guid, other.guid);
0337       if (lastComparison != 0) {
0338         return lastComparison;
0339       }
0340     }
0341     lastComparison = Boolean.valueOf(isSetSecret()).compareTo(other.isSetSecret());
0342     if (lastComparison != 0) {
0343       return lastComparison;
0344     }
0345     if (isSetSecret()) {
0346       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.secret, other.secret);
0347       if (lastComparison != 0) {
0348         return lastComparison;
0349       }
0350     }
0351     return 0;
0352   }
0353 
0354   public _Fields fieldForId(int fieldId) {
0355     return _Fields.findByThriftId(fieldId);
0356   }
0357 
0358   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
0359     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
0360   }
0361 
0362   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
0363     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
0364   }
0365 
0366   @Override
0367   public String toString() {
0368     StringBuilder sb = new StringBuilder("THandleIdentifier(");
0369     boolean first = true;
0370 
0371     sb.append("guid:");
0372     if (this.guid == null) {
0373       sb.append("null");
0374     } else {
0375       org.apache.thrift.TBaseHelper.toString(this.guid, sb);
0376     }
0377     first = false;
0378     if (!first) sb.append(", ");
0379     sb.append("secret:");
0380     if (this.secret == null) {
0381       sb.append("null");
0382     } else {
0383       org.apache.thrift.TBaseHelper.toString(this.secret, sb);
0384     }
0385     first = false;
0386     sb.append(")");
0387     return sb.toString();
0388   }
0389 
0390   public void validate() throws org.apache.thrift.TException {
0391     // check for required fields
0392     if (!isSetGuid()) {
0393       throw new org.apache.thrift.protocol.TProtocolException("Required field 'guid' is unset! Struct:" + toString());
0394     }
0395 
0396     if (!isSetSecret()) {
0397       throw new org.apache.thrift.protocol.TProtocolException("Required field 'secret' is unset! Struct:" + toString());
0398     }
0399 
0400     // check for sub-struct validity
0401   }
0402 
0403   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
0404     try {
0405       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
0406     } catch (org.apache.thrift.TException te) {
0407       throw new java.io.IOException(te);
0408     }
0409   }
0410 
0411   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
0412     try {
0413       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
0414     } catch (org.apache.thrift.TException te) {
0415       throw new java.io.IOException(te);
0416     }
0417   }
0418 
0419   private static class THandleIdentifierStandardSchemeFactory implements SchemeFactory {
0420     public THandleIdentifierStandardScheme getScheme() {
0421       return new THandleIdentifierStandardScheme();
0422     }
0423   }
0424 
0425   private static class THandleIdentifierStandardScheme extends StandardScheme<THandleIdentifier> {
0426 
0427     public void read(org.apache.thrift.protocol.TProtocol iprot, THandleIdentifier struct) throws org.apache.thrift.TException {
0428       org.apache.thrift.protocol.TField schemeField;
0429       iprot.readStructBegin();
0430       while (true)
0431       {
0432         schemeField = iprot.readFieldBegin();
0433         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
0434           break;
0435         }
0436         switch (schemeField.id) {
0437           case 1: // GUID
0438             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
0439               struct.guid = iprot.readBinary();
0440               struct.setGuidIsSet(true);
0441             } else { 
0442               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0443             }
0444             break;
0445           case 2: // SECRET
0446             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
0447               struct.secret = iprot.readBinary();
0448               struct.setSecretIsSet(true);
0449             } else { 
0450               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0451             }
0452             break;
0453           default:
0454             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0455         }
0456         iprot.readFieldEnd();
0457       }
0458       iprot.readStructEnd();
0459       struct.validate();
0460     }
0461 
0462     public void write(org.apache.thrift.protocol.TProtocol oprot, THandleIdentifier struct) throws org.apache.thrift.TException {
0463       struct.validate();
0464 
0465       oprot.writeStructBegin(STRUCT_DESC);
0466       if (struct.guid != null) {
0467         oprot.writeFieldBegin(GUID_FIELD_DESC);
0468         oprot.writeBinary(struct.guid);
0469         oprot.writeFieldEnd();
0470       }
0471       if (struct.secret != null) {
0472         oprot.writeFieldBegin(SECRET_FIELD_DESC);
0473         oprot.writeBinary(struct.secret);
0474         oprot.writeFieldEnd();
0475       }
0476       oprot.writeFieldStop();
0477       oprot.writeStructEnd();
0478     }
0479 
0480   }
0481 
0482   private static class THandleIdentifierTupleSchemeFactory implements SchemeFactory {
0483     public THandleIdentifierTupleScheme getScheme() {
0484       return new THandleIdentifierTupleScheme();
0485     }
0486   }
0487 
0488   private static class THandleIdentifierTupleScheme extends TupleScheme<THandleIdentifier> {
0489 
0490     @Override
0491     public void write(org.apache.thrift.protocol.TProtocol prot, THandleIdentifier struct) throws org.apache.thrift.TException {
0492       TTupleProtocol oprot = (TTupleProtocol) prot;
0493       oprot.writeBinary(struct.guid);
0494       oprot.writeBinary(struct.secret);
0495     }
0496 
0497     @Override
0498     public void read(org.apache.thrift.protocol.TProtocol prot, THandleIdentifier struct) throws org.apache.thrift.TException {
0499       TTupleProtocol iprot = (TTupleProtocol) prot;
0500       struct.guid = iprot.readBinary();
0501       struct.setGuidIsSet(true);
0502       struct.secret = iprot.readBinary();
0503       struct.setSecretIsSet(true);
0504     }
0505   }
0506 
0507 }
0508