View Javadoc

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