View Javadoc

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