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.thrift.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   * An IOError exception signals that an error occurred communicating
33   * to the Hbase master or an Hbase region server.  Also used to return
34   * more general Hbase error conditions.
35   */
36  public class IOError extends Exception implements org.apache.thrift.TBase<IOError, IOError._Fields>, java.io.Serializable, Cloneable {
37    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("IOError");
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 IOErrorStandardSchemeFactory());
44      schemes.put(TupleScheme.class, new IOErrorTupleSchemeFactory());
45    }
46  
47    public String message; // required
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   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
109   static {
110     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
111     tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.DEFAULT, 
112         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
113     metaDataMap = Collections.unmodifiableMap(tmpMap);
114     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(IOError.class, metaDataMap);
115   }
116 
117   public IOError() {
118   }
119 
120   public IOError(
121     String message)
122   {
123     this();
124     this.message = message;
125   }
126 
127   /**
128    * Performs a deep copy on <i>other</i>.
129    */
130   public IOError(IOError other) {
131     if (other.isSetMessage()) {
132       this.message = other.message;
133     }
134   }
135 
136   public IOError deepCopy() {
137     return new IOError(this);
138   }
139 
140   @Override
141   public void clear() {
142     this.message = null;
143   }
144 
145   public String getMessage() {
146     return this.message;
147   }
148 
149   public IOError setMessage(String message) {
150     this.message = message;
151     return this;
152   }
153 
154   public void unsetMessage() {
155     this.message = null;
156   }
157 
158   /** Returns true if field message is set (has been assigned a value) and false otherwise */
159   public boolean isSetMessage() {
160     return this.message != null;
161   }
162 
163   public void setMessageIsSet(boolean value) {
164     if (!value) {
165       this.message = null;
166     }
167   }
168 
169   public void setFieldValue(_Fields field, Object value) {
170     switch (field) {
171     case MESSAGE:
172       if (value == null) {
173         unsetMessage();
174       } else {
175         setMessage((String)value);
176       }
177       break;
178 
179     }
180   }
181 
182   public Object getFieldValue(_Fields field) {
183     switch (field) {
184     case MESSAGE:
185       return getMessage();
186 
187     }
188     throw new IllegalStateException();
189   }
190 
191   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
192   public boolean isSet(_Fields field) {
193     if (field == null) {
194       throw new IllegalArgumentException();
195     }
196 
197     switch (field) {
198     case MESSAGE:
199       return isSetMessage();
200     }
201     throw new IllegalStateException();
202   }
203 
204   @Override
205   public boolean equals(Object that) {
206     if (that == null)
207       return false;
208     if (that instanceof IOError)
209       return this.equals((IOError)that);
210     return false;
211   }
212 
213   public boolean equals(IOError that) {
214     if (that == null)
215       return false;
216 
217     boolean this_present_message = true && this.isSetMessage();
218     boolean that_present_message = true && that.isSetMessage();
219     if (this_present_message || that_present_message) {
220       if (!(this_present_message && that_present_message))
221         return false;
222       if (!this.message.equals(that.message))
223         return false;
224     }
225 
226     return true;
227   }
228 
229   @Override
230   public int hashCode() {
231     HashCodeBuilder builder = new HashCodeBuilder();
232 
233     boolean present_message = true && (isSetMessage());
234     builder.append(present_message);
235     if (present_message)
236       builder.append(message);
237 
238     return builder.toHashCode();
239   }
240 
241   public int compareTo(IOError other) {
242     if (!getClass().equals(other.getClass())) {
243       return getClass().getName().compareTo(other.getClass().getName());
244     }
245 
246     int lastComparison = 0;
247     IOError typedOther = (IOError)other;
248 
249     lastComparison = Boolean.valueOf(isSetMessage()).compareTo(typedOther.isSetMessage());
250     if (lastComparison != 0) {
251       return lastComparison;
252     }
253     if (isSetMessage()) {
254       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, typedOther.message);
255       if (lastComparison != 0) {
256         return lastComparison;
257       }
258     }
259     return 0;
260   }
261 
262   public _Fields fieldForId(int fieldId) {
263     return _Fields.findByThriftId(fieldId);
264   }
265 
266   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
267     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
268   }
269 
270   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
271     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
272   }
273 
274   @Override
275   public String toString() {
276     StringBuilder sb = new StringBuilder("IOError(");
277     boolean first = true;
278 
279     sb.append("message:");
280     if (this.message == null) {
281       sb.append("null");
282     } else {
283       sb.append(this.message);
284     }
285     first = false;
286     sb.append(")");
287     return sb.toString();
288   }
289 
290   public void validate() throws org.apache.thrift.TException {
291     // check for required fields
292   }
293 
294   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
295     try {
296       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
297     } catch (org.apache.thrift.TException te) {
298       throw new java.io.IOException(te);
299     }
300   }
301 
302   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
303     try {
304       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
305     } catch (org.apache.thrift.TException te) {
306       throw new java.io.IOException(te);
307     }
308   }
309 
310   private static class IOErrorStandardSchemeFactory implements SchemeFactory {
311     public IOErrorStandardScheme getScheme() {
312       return new IOErrorStandardScheme();
313     }
314   }
315 
316   private static class IOErrorStandardScheme extends StandardScheme<IOError> {
317 
318     public void read(org.apache.thrift.protocol.TProtocol iprot, IOError struct) throws org.apache.thrift.TException {
319       org.apache.thrift.protocol.TField schemeField;
320       iprot.readStructBegin();
321       while (true)
322       {
323         schemeField = iprot.readFieldBegin();
324         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
325           break;
326         }
327         switch (schemeField.id) {
328           case 1: // MESSAGE
329             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
330               struct.message = iprot.readString();
331               struct.setMessageIsSet(true);
332             } else { 
333               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
334             }
335             break;
336           default:
337             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
338         }
339         iprot.readFieldEnd();
340       }
341       iprot.readStructEnd();
342 
343       // check for required fields of primitive type, which can't be checked in the validate method
344       struct.validate();
345     }
346 
347     public void write(org.apache.thrift.protocol.TProtocol oprot, IOError struct) throws org.apache.thrift.TException {
348       struct.validate();
349 
350       oprot.writeStructBegin(STRUCT_DESC);
351       if (struct.message != null) {
352         oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
353         oprot.writeString(struct.message);
354         oprot.writeFieldEnd();
355       }
356       oprot.writeFieldStop();
357       oprot.writeStructEnd();
358     }
359 
360   }
361 
362   private static class IOErrorTupleSchemeFactory implements SchemeFactory {
363     public IOErrorTupleScheme getScheme() {
364       return new IOErrorTupleScheme();
365     }
366   }
367 
368   private static class IOErrorTupleScheme extends TupleScheme<IOError> {
369 
370     @Override
371     public void write(org.apache.thrift.protocol.TProtocol prot, IOError struct) throws org.apache.thrift.TException {
372       TTupleProtocol oprot = (TTupleProtocol) prot;
373       BitSet optionals = new BitSet();
374       if (struct.isSetMessage()) {
375         optionals.set(0);
376       }
377       oprot.writeBitSet(optionals, 1);
378       if (struct.isSetMessage()) {
379         oprot.writeString(struct.message);
380       }
381     }
382 
383     @Override
384     public void read(org.apache.thrift.protocol.TProtocol prot, IOError struct) throws org.apache.thrift.TException {
385       TTupleProtocol iprot = (TTupleProtocol) prot;
386       BitSet incoming = iprot.readBitSet(1);
387       if (incoming.get(0)) {
388         struct.message = iprot.readString();
389         struct.setMessageIsSet(true);
390       }
391     }
392   }
393 
394 }
395