View Javadoc

1   /**
2    * Autogenerated by Thrift Compiler (0.8.0)
3    *
4    * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5    *  @generated
6    */
7   package org.apache.hadoop.hbase.thrift2.generated;
8   
9   import org.apache.thrift.scheme.IScheme;
10  import org.apache.thrift.scheme.SchemeFactory;
11  import org.apache.thrift.scheme.StandardScheme;
12  
13  import org.apache.thrift.scheme.TupleScheme;
14  import org.apache.thrift.protocol.TTupleProtocol;
15  import java.util.List;
16  import java.util.ArrayList;
17  import java.util.Map;
18  import java.util.HashMap;
19  import java.util.EnumMap;
20  import java.util.Set;
21  import java.util.HashSet;
22  import java.util.EnumSet;
23  import java.util.Collections;
24  import java.util.BitSet;
25  import java.nio.ByteBuffer;
26  import java.util.Arrays;
27  import org.slf4j.Logger;
28  import org.slf4j.LoggerFactory;
29  
30  /**
31   * A TIllegalArgument exception indicates an illegal or invalid
32   * argument was passed into a procedure.
33   */
34  public class TIllegalArgument extends Exception implements org.apache.thrift.TBase<TIllegalArgument, TIllegalArgument._Fields>, java.io.Serializable, Cloneable {
35    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TIllegalArgument");
36  
37    private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
38  
39    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
40    static {
41      schemes.put(StandardScheme.class, new TIllegalArgumentStandardSchemeFactory());
42      schemes.put(TupleScheme.class, new TIllegalArgumentTupleSchemeFactory());
43    }
44  
45    public String message; // optional
46  
47    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
48    public enum _Fields implements org.apache.thrift.TFieldIdEnum {
49      MESSAGE((short)1, "message");
50  
51      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
52  
53      static {
54        for (_Fields field : EnumSet.allOf(_Fields.class)) {
55          byName.put(field.getFieldName(), field);
56        }
57      }
58  
59      /**
60       * Find the _Fields constant that matches fieldId, or null if its not found.
61       */
62      public static _Fields findByThriftId(int fieldId) {
63        switch(fieldId) {
64          case 1: // MESSAGE
65            return MESSAGE;
66          default:
67            return null;
68        }
69      }
70  
71      /**
72       * Find the _Fields constant that matches fieldId, throwing an exception
73       * if it is not found.
74       */
75      public static _Fields findByThriftIdOrThrow(int fieldId) {
76        _Fields fields = findByThriftId(fieldId);
77        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
78        return fields;
79      }
80  
81      /**
82       * Find the _Fields constant that matches name, or null if its not found.
83       */
84      public static _Fields findByName(String name) {
85        return byName.get(name);
86      }
87  
88      private final short _thriftId;
89      private final String _fieldName;
90  
91      _Fields(short thriftId, String fieldName) {
92        _thriftId = thriftId;
93        _fieldName = fieldName;
94      }
95  
96      public short getThriftFieldId() {
97        return _thriftId;
98      }
99  
100     public String getFieldName() {
101       return _fieldName;
102     }
103   }
104 
105   // isset id assignments
106   private _Fields optionals[] = {_Fields.MESSAGE};
107   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
108   static {
109     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
110     tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
111         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
112     metaDataMap = Collections.unmodifiableMap(tmpMap);
113     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TIllegalArgument.class, metaDataMap);
114   }
115 
116   public TIllegalArgument() {
117   }
118 
119   /**
120    * Performs a deep copy on <i>other</i>.
121    */
122   public TIllegalArgument(TIllegalArgument other) {
123     if (other.isSetMessage()) {
124       this.message = other.message;
125     }
126   }
127 
128   public TIllegalArgument deepCopy() {
129     return new TIllegalArgument(this);
130   }
131 
132   @Override
133   public void clear() {
134     this.message = null;
135   }
136 
137   public String getMessage() {
138     return this.message;
139   }
140 
141   public TIllegalArgument setMessage(String message) {
142     this.message = message;
143     return this;
144   }
145 
146   public void unsetMessage() {
147     this.message = null;
148   }
149 
150   /** Returns true if field message is set (has been assigned a value) and false otherwise */
151   public boolean isSetMessage() {
152     return this.message != null;
153   }
154 
155   public void setMessageIsSet(boolean value) {
156     if (!value) {
157       this.message = null;
158     }
159   }
160 
161   public void setFieldValue(_Fields field, Object value) {
162     switch (field) {
163     case MESSAGE:
164       if (value == null) {
165         unsetMessage();
166       } else {
167         setMessage((String)value);
168       }
169       break;
170 
171     }
172   }
173 
174   public Object getFieldValue(_Fields field) {
175     switch (field) {
176     case MESSAGE:
177       return getMessage();
178 
179     }
180     throw new IllegalStateException();
181   }
182 
183   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
184   public boolean isSet(_Fields field) {
185     if (field == null) {
186       throw new IllegalArgumentException();
187     }
188 
189     switch (field) {
190     case MESSAGE:
191       return isSetMessage();
192     }
193     throw new IllegalStateException();
194   }
195 
196   @Override
197   public boolean equals(Object that) {
198     if (that == null)
199       return false;
200     if (that instanceof TIllegalArgument)
201       return this.equals((TIllegalArgument)that);
202     return false;
203   }
204 
205   public boolean equals(TIllegalArgument that) {
206     if (that == null)
207       return false;
208 
209     boolean this_present_message = true && this.isSetMessage();
210     boolean that_present_message = true && that.isSetMessage();
211     if (this_present_message || that_present_message) {
212       if (!(this_present_message && that_present_message))
213         return false;
214       if (!this.message.equals(that.message))
215         return false;
216     }
217 
218     return true;
219   }
220 
221   @Override
222   public int hashCode() {
223     return 0;
224   }
225 
226   public int compareTo(TIllegalArgument other) {
227     if (!getClass().equals(other.getClass())) {
228       return getClass().getName().compareTo(other.getClass().getName());
229     }
230 
231     int lastComparison = 0;
232     TIllegalArgument typedOther = (TIllegalArgument)other;
233 
234     lastComparison = Boolean.valueOf(isSetMessage()).compareTo(typedOther.isSetMessage());
235     if (lastComparison != 0) {
236       return lastComparison;
237     }
238     if (isSetMessage()) {
239       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, typedOther.message);
240       if (lastComparison != 0) {
241         return lastComparison;
242       }
243     }
244     return 0;
245   }
246 
247   public _Fields fieldForId(int fieldId) {
248     return _Fields.findByThriftId(fieldId);
249   }
250 
251   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
252     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
253   }
254 
255   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
256     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
257   }
258 
259   @Override
260   public String toString() {
261     StringBuilder sb = new StringBuilder("TIllegalArgument(");
262     boolean first = true;
263 
264     if (isSetMessage()) {
265       sb.append("message:");
266       if (this.message == null) {
267         sb.append("null");
268       } else {
269         sb.append(this.message);
270       }
271       first = false;
272     }
273     sb.append(")");
274     return sb.toString();
275   }
276 
277   public void validate() throws org.apache.thrift.TException {
278     // check for required fields
279   }
280 
281   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
282     try {
283       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
284     } catch (org.apache.thrift.TException te) {
285       throw new java.io.IOException(te);
286     }
287   }
288 
289   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
290     try {
291       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
292     } catch (org.apache.thrift.TException te) {
293       throw new java.io.IOException(te);
294     }
295   }
296 
297   private static class TIllegalArgumentStandardSchemeFactory implements SchemeFactory {
298     public TIllegalArgumentStandardScheme getScheme() {
299       return new TIllegalArgumentStandardScheme();
300     }
301   }
302 
303   private static class TIllegalArgumentStandardScheme extends StandardScheme<TIllegalArgument> {
304 
305     public void read(org.apache.thrift.protocol.TProtocol iprot, TIllegalArgument struct) throws org.apache.thrift.TException {
306       org.apache.thrift.protocol.TField schemeField;
307       iprot.readStructBegin();
308       while (true)
309       {
310         schemeField = iprot.readFieldBegin();
311         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
312           break;
313         }
314         switch (schemeField.id) {
315           case 1: // MESSAGE
316             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
317               struct.message = iprot.readString();
318               struct.setMessageIsSet(true);
319             } else { 
320               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
321             }
322             break;
323           default:
324             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
325         }
326         iprot.readFieldEnd();
327       }
328       iprot.readStructEnd();
329 
330       // check for required fields of primitive type, which can't be checked in the validate method
331       struct.validate();
332     }
333 
334     public void write(org.apache.thrift.protocol.TProtocol oprot, TIllegalArgument struct) throws org.apache.thrift.TException {
335       struct.validate();
336 
337       oprot.writeStructBegin(STRUCT_DESC);
338       if (struct.message != null) {
339         if (struct.isSetMessage()) {
340           oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
341           oprot.writeString(struct.message);
342           oprot.writeFieldEnd();
343         }
344       }
345       oprot.writeFieldStop();
346       oprot.writeStructEnd();
347     }
348 
349   }
350 
351   private static class TIllegalArgumentTupleSchemeFactory implements SchemeFactory {
352     public TIllegalArgumentTupleScheme getScheme() {
353       return new TIllegalArgumentTupleScheme();
354     }
355   }
356 
357   private static class TIllegalArgumentTupleScheme extends TupleScheme<TIllegalArgument> {
358 
359     @Override
360     public void write(org.apache.thrift.protocol.TProtocol prot, TIllegalArgument struct) throws org.apache.thrift.TException {
361       TTupleProtocol oprot = (TTupleProtocol) prot;
362       BitSet optionals = new BitSet();
363       if (struct.isSetMessage()) {
364         optionals.set(0);
365       }
366       oprot.writeBitSet(optionals, 1);
367       if (struct.isSetMessage()) {
368         oprot.writeString(struct.message);
369       }
370     }
371 
372     @Override
373     public void read(org.apache.thrift.protocol.TProtocol prot, TIllegalArgument struct) throws org.apache.thrift.TException {
374       TTupleProtocol iprot = (TTupleProtocol) prot;
375       BitSet incoming = iprot.readBitSet(1);
376       if (incoming.get(0)) {
377         struct.message = iprot.readString();
378         struct.setMessageIsSet(true);
379       }
380     }
381   }
382 
383 }
384