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 TStringValue implements org.apache.thrift.TBase<TStringValue, TStringValue._Fields>, java.io.Serializable, Cloneable {
0035   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TStringValue");
0036 
0037   private static final org.apache.thrift.protocol.TField VALUE_FIELD_DESC = new org.apache.thrift.protocol.TField("value", org.apache.thrift.protocol.TType.STRING, (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 TStringValueStandardSchemeFactory());
0042     schemes.put(TupleScheme.class, new TStringValueTupleSchemeFactory());
0043   }
0044 
0045   private String value; // optional
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     VALUE((short)1, "value");
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: // VALUE
0065           return VALUE;
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   private _Fields optionals[] = {_Fields.VALUE};
0107   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
0108   static {
0109     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
0110     tmpMap.put(_Fields.VALUE, new org.apache.thrift.meta_data.FieldMetaData("value", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
0111         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
0112     metaDataMap = Collections.unmodifiableMap(tmpMap);
0113     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TStringValue.class, metaDataMap);
0114   }
0115 
0116   public TStringValue() {
0117   }
0118 
0119   /**
0120    * Performs a deep copy on <i>other</i>.
0121    */
0122   public TStringValue(TStringValue other) {
0123     if (other.isSetValue()) {
0124       this.value = other.value;
0125     }
0126   }
0127 
0128   public TStringValue deepCopy() {
0129     return new TStringValue(this);
0130   }
0131 
0132   @Override
0133   public void clear() {
0134     this.value = null;
0135   }
0136 
0137   public String getValue() {
0138     return this.value;
0139   }
0140 
0141   public void setValue(String value) {
0142     this.value = value;
0143   }
0144 
0145   public void unsetValue() {
0146     this.value = null;
0147   }
0148 
0149   /** Returns true if field value is set (has been assigned a value) and false otherwise */
0150   public boolean isSetValue() {
0151     return this.value != null;
0152   }
0153 
0154   public void setValueIsSet(boolean value) {
0155     if (!value) {
0156       this.value = null;
0157     }
0158   }
0159 
0160   public void setFieldValue(_Fields field, Object value) {
0161     switch (field) {
0162     case VALUE:
0163       if (value == null) {
0164         unsetValue();
0165       } else {
0166         setValue((String)value);
0167       }
0168       break;
0169 
0170     }
0171   }
0172 
0173   public Object getFieldValue(_Fields field) {
0174     switch (field) {
0175     case VALUE:
0176       return getValue();
0177 
0178     }
0179     throw new IllegalStateException();
0180   }
0181 
0182   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
0183   public boolean isSet(_Fields field) {
0184     if (field == null) {
0185       throw new IllegalArgumentException();
0186     }
0187 
0188     switch (field) {
0189     case VALUE:
0190       return isSetValue();
0191     }
0192     throw new IllegalStateException();
0193   }
0194 
0195   @Override
0196   public boolean equals(Object that) {
0197     if (that == null)
0198       return false;
0199     if (that instanceof TStringValue)
0200       return this.equals((TStringValue)that);
0201     return false;
0202   }
0203 
0204   public boolean equals(TStringValue that) {
0205     if (that == null)
0206       return false;
0207 
0208     boolean this_present_value = true && this.isSetValue();
0209     boolean that_present_value = true && that.isSetValue();
0210     if (this_present_value || that_present_value) {
0211       if (!(this_present_value && that_present_value))
0212         return false;
0213       if (!this.value.equals(that.value))
0214         return false;
0215     }
0216 
0217     return true;
0218   }
0219 
0220   @Override
0221   public int hashCode() {
0222     HashCodeBuilder builder = new HashCodeBuilder();
0223 
0224     boolean present_value = true && (isSetValue());
0225     builder.append(present_value);
0226     if (present_value)
0227       builder.append(value);
0228 
0229     return builder.toHashCode();
0230   }
0231 
0232   public int compareTo(TStringValue other) {
0233     if (!getClass().equals(other.getClass())) {
0234       return getClass().getName().compareTo(other.getClass().getName());
0235     }
0236 
0237     int lastComparison = 0;
0238     TStringValue typedOther = (TStringValue)other;
0239 
0240     lastComparison = Boolean.valueOf(isSetValue()).compareTo(typedOther.isSetValue());
0241     if (lastComparison != 0) {
0242       return lastComparison;
0243     }
0244     if (isSetValue()) {
0245       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.value, typedOther.value);
0246       if (lastComparison != 0) {
0247         return lastComparison;
0248       }
0249     }
0250     return 0;
0251   }
0252 
0253   public _Fields fieldForId(int fieldId) {
0254     return _Fields.findByThriftId(fieldId);
0255   }
0256 
0257   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
0258     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
0259   }
0260 
0261   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
0262     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
0263   }
0264 
0265   @Override
0266   public String toString() {
0267     StringBuilder sb = new StringBuilder("TStringValue(");
0268     boolean first = true;
0269 
0270     if (isSetValue()) {
0271       sb.append("value:");
0272       if (this.value == null) {
0273         sb.append("null");
0274       } else {
0275         sb.append(this.value);
0276       }
0277       first = false;
0278     }
0279     sb.append(")");
0280     return sb.toString();
0281   }
0282 
0283   public void validate() throws org.apache.thrift.TException {
0284     // check for required fields
0285     // check for sub-struct validity
0286   }
0287 
0288   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
0289     try {
0290       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
0291     } catch (org.apache.thrift.TException te) {
0292       throw new java.io.IOException(te);
0293     }
0294   }
0295 
0296   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
0297     try {
0298       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
0299     } catch (org.apache.thrift.TException te) {
0300       throw new java.io.IOException(te);
0301     }
0302   }
0303 
0304   private static class TStringValueStandardSchemeFactory implements SchemeFactory {
0305     public TStringValueStandardScheme getScheme() {
0306       return new TStringValueStandardScheme();
0307     }
0308   }
0309 
0310   private static class TStringValueStandardScheme extends StandardScheme<TStringValue> {
0311 
0312     public void read(org.apache.thrift.protocol.TProtocol iprot, TStringValue struct) throws org.apache.thrift.TException {
0313       org.apache.thrift.protocol.TField schemeField;
0314       iprot.readStructBegin();
0315       while (true)
0316       {
0317         schemeField = iprot.readFieldBegin();
0318         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
0319           break;
0320         }
0321         switch (schemeField.id) {
0322           case 1: // VALUE
0323             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
0324               struct.value = iprot.readString();
0325               struct.setValueIsSet(true);
0326             } else { 
0327               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0328             }
0329             break;
0330           default:
0331             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0332         }
0333         iprot.readFieldEnd();
0334       }
0335       iprot.readStructEnd();
0336       struct.validate();
0337     }
0338 
0339     public void write(org.apache.thrift.protocol.TProtocol oprot, TStringValue struct) throws org.apache.thrift.TException {
0340       struct.validate();
0341 
0342       oprot.writeStructBegin(STRUCT_DESC);
0343       if (struct.value != null) {
0344         if (struct.isSetValue()) {
0345           oprot.writeFieldBegin(VALUE_FIELD_DESC);
0346           oprot.writeString(struct.value);
0347           oprot.writeFieldEnd();
0348         }
0349       }
0350       oprot.writeFieldStop();
0351       oprot.writeStructEnd();
0352     }
0353 
0354   }
0355 
0356   private static class TStringValueTupleSchemeFactory implements SchemeFactory {
0357     public TStringValueTupleScheme getScheme() {
0358       return new TStringValueTupleScheme();
0359     }
0360   }
0361 
0362   private static class TStringValueTupleScheme extends TupleScheme<TStringValue> {
0363 
0364     @Override
0365     public void write(org.apache.thrift.protocol.TProtocol prot, TStringValue struct) throws org.apache.thrift.TException {
0366       TTupleProtocol oprot = (TTupleProtocol) prot;
0367       BitSet optionals = new BitSet();
0368       if (struct.isSetValue()) {
0369         optionals.set(0);
0370       }
0371       oprot.writeBitSet(optionals, 1);
0372       if (struct.isSetValue()) {
0373         oprot.writeString(struct.value);
0374       }
0375     }
0376 
0377     @Override
0378     public void read(org.apache.thrift.protocol.TProtocol prot, TStringValue struct) throws org.apache.thrift.TException {
0379       TTupleProtocol iprot = (TTupleProtocol) prot;
0380       BitSet incoming = iprot.readBitSet(1);
0381       if (incoming.get(0)) {
0382         struct.value = iprot.readString();
0383         struct.setValueIsSet(true);
0384       }
0385     }
0386   }
0387 
0388 }
0389