View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.hadoop.hbase.thrift.generated;
19  
20  import org.apache.commons.lang.builder.HashCodeBuilder;
21  import java.util.List;
22  import java.util.ArrayList;
23  import java.util.Map;
24  import java.util.HashMap;
25  import java.util.EnumMap;
26  import java.util.Set;
27  import java.util.HashSet;
28  import java.util.EnumSet;
29  import java.util.Collections;
30  import java.util.BitSet;
31  import java.util.Arrays;
32  import org.slf4j.Logger;
33  import org.slf4j.LoggerFactory;
34  
35  import org.apache.thrift.*;
36  import org.apache.thrift.meta_data.*;
37  import org.apache.thrift.protocol.*;
38  
39  /**
40   * An IOError exception signals that an error occurred communicating
41   * to the Hbase master or an Hbase region server.  Also used to return
42   * more general Hbase error conditions.
43   */
44  public class IOError extends Exception implements TBase<IOError._Fields>, java.io.Serializable, Cloneable, Comparable<IOError> {
45    private static final TStruct STRUCT_DESC = new TStruct("IOError");
46  
47    private static final TField MESSAGE_FIELD_DESC = new TField("message", TType.STRING, (short)1);
48  
49    public String message;
50  
51    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
52    public enum _Fields implements TFieldIdEnum {
53      MESSAGE((short)1, "message");
54  
55      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
56      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
57  
58      static {
59        for (_Fields field : EnumSet.allOf(_Fields.class)) {
60          byId.put((int)field._thriftId, field);
61          byName.put(field.getFieldName(), field);
62        }
63      }
64  
65      /**
66       * Find the _Fields constant that matches fieldId, or null if its not found.
67       */
68      public static _Fields findByThriftId(int fieldId) {
69        return byId.get(fieldId);
70      }
71  
72      /**
73       * Find the _Fields constant that matches fieldId, throwing an exception
74       * if it is not found.
75       */
76      public static _Fields findByThriftIdOrThrow(int fieldId) {
77        _Fields fields = findByThriftId(fieldId);
78        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
79        return fields;
80      }
81  
82      /**
83       * Find the _Fields constant that matches name, or null if its not found.
84       */
85      public static _Fields findByName(String name) {
86        return byName.get(name);
87      }
88  
89      private final short _thriftId;
90      private final String _fieldName;
91  
92      _Fields(short thriftId, String fieldName) {
93        _thriftId = thriftId;
94        _fieldName = fieldName;
95      }
96  
97      public short getThriftFieldId() {
98        return _thriftId;
99      }
100 
101     public String getFieldName() {
102       return _fieldName;
103     }
104   }
105 
106   // isset id assignments
107 
108   public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
109     put(_Fields.MESSAGE, new FieldMetaData("message", TFieldRequirementType.DEFAULT,
110         new FieldValueMetaData(TType.STRING)));
111   }});
112 
113   static {
114     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   @Deprecated
141   public IOError clone() {
142     return new IOError(this);
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 asigned 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 void setFieldValue(int fieldID, Object value) {
183     setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
184   }
185 
186   public Object getFieldValue(_Fields field) {
187     switch (field) {
188     case MESSAGE:
189       return getMessage();
190 
191     }
192     throw new IllegalStateException();
193   }
194 
195   public Object getFieldValue(int fieldId) {
196     return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
197   }
198 
199   /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
200   public boolean isSet(_Fields field) {
201     switch (field) {
202     case MESSAGE:
203       return isSetMessage();
204     }
205     throw new IllegalStateException();
206   }
207 
208   public boolean isSet(int fieldID) {
209     return isSet(_Fields.findByThriftIdOrThrow(fieldID));
210   }
211 
212   @Override
213   public boolean equals(Object that) {
214     if (that == null)
215       return false;
216     if (that instanceof IOError)
217       return this.equals((IOError)that);
218     return false;
219   }
220 
221   public boolean equals(IOError that) {
222     if (that == null)
223       return false;
224 
225     boolean this_present_message = true && this.isSetMessage();
226     boolean that_present_message = true && that.isSetMessage();
227     if (this_present_message || that_present_message) {
228       if (!(this_present_message && that_present_message))
229         return false;
230       if (!this.message.equals(that.message))
231         return false;
232     }
233 
234     return true;
235   }
236 
237   @Override
238   public int hashCode() {
239     HashCodeBuilder builder = new HashCodeBuilder();
240 
241     boolean present_message = true && (isSetMessage());
242     builder.append(present_message);
243     if (present_message)
244       builder.append(message);
245 
246     return builder.toHashCode();
247   }
248 
249   public int compareTo(IOError other) {
250     if (!getClass().equals(other.getClass())) {
251       return getClass().getName().compareTo(other.getClass().getName());
252     }
253 
254     int lastComparison = 0;
255     IOError typedOther = (IOError)other;
256 
257     lastComparison = Boolean.valueOf(isSetMessage()).compareTo(isSetMessage());
258     if (lastComparison != 0) {
259       return lastComparison;
260     }
261     lastComparison = TBaseHelper.compareTo(message, typedOther.message);
262     if (lastComparison != 0) {
263       return lastComparison;
264     }
265     return 0;
266   }
267 
268   public void read(TProtocol iprot) throws TException {
269     TField field;
270     iprot.readStructBegin();
271     while (true)
272     {
273       field = iprot.readFieldBegin();
274       if (field.type == TType.STOP) {
275         break;
276       }
277       _Fields fieldId = _Fields.findByThriftId(field.id);
278       if (fieldId == null) {
279         TProtocolUtil.skip(iprot, field.type);
280       } else {
281         switch (fieldId) {
282           case MESSAGE:
283             if (field.type == TType.STRING) {
284               this.message = iprot.readString();
285             } else {
286               TProtocolUtil.skip(iprot, field.type);
287             }
288             break;
289         }
290         iprot.readFieldEnd();
291       }
292     }
293     iprot.readStructEnd();
294 
295     // check for required fields of primitive type, which can't be checked in the validate method
296     validate();
297   }
298 
299   public void write(TProtocol oprot) throws TException {
300     validate();
301 
302     oprot.writeStructBegin(STRUCT_DESC);
303     if (this.message != null) {
304       oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
305       oprot.writeString(this.message);
306       oprot.writeFieldEnd();
307     }
308     oprot.writeFieldStop();
309     oprot.writeStructEnd();
310   }
311 
312   @Override
313   public String toString() {
314     StringBuilder sb = new StringBuilder("IOError(");
315     boolean first = true;
316 
317     sb.append("message:");
318     if (this.message == null) {
319       sb.append("null");
320     } else {
321       sb.append(this.message);
322     }
323     first = false;
324     sb.append(")");
325     return sb.toString();
326   }
327 
328   public void validate() throws TException {
329     // check for required fields
330   }
331 
332 }
333