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