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.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 java.util.List;
16  import java.util.ArrayList;
17  import java.util.Map;
18  import java.util.HashMap;
19  import java.util.EnumMap;
20  import java.util.Set;
21  import java.util.HashSet;
22  import java.util.EnumSet;
23  import java.util.Collections;
24  import java.util.BitSet;
25  import java.nio.ByteBuffer;
26  import java.util.Arrays;
27  import org.slf4j.Logger;
28  import org.slf4j.LoggerFactory;
29  
30  /**
31   * Holds column name and the cell.
32   */
33  public class TColumn implements org.apache.thrift.TBase<TColumn, TColumn._Fields>, java.io.Serializable, Cloneable {
34    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TColumn");
35  
36    private static final org.apache.thrift.protocol.TField COLUMN_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("columnName", org.apache.thrift.protocol.TType.STRING, (short)1);
37    private static final org.apache.thrift.protocol.TField CELL_FIELD_DESC = new org.apache.thrift.protocol.TField("cell", org.apache.thrift.protocol.TType.STRUCT, (short)2);
38  
39    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
40    static {
41      schemes.put(StandardScheme.class, new TColumnStandardSchemeFactory());
42      schemes.put(TupleScheme.class, new TColumnTupleSchemeFactory());
43    }
44  
45    public ByteBuffer columnName; // required
46    public TCell cell; // required
47  
48    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
49    public enum _Fields implements org.apache.thrift.TFieldIdEnum {
50      COLUMN_NAME((short)1, "columnName"),
51      CELL((short)2, "cell");
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: // COLUMN_NAME
67            return COLUMN_NAME;
68          case 2: // CELL
69            return CELL;
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.COLUMN_NAME, new org.apache.thrift.meta_data.FieldMetaData("columnName", org.apache.thrift.TFieldRequirementType.DEFAULT, 
114         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , "Text")));
115     tmpMap.put(_Fields.CELL, new org.apache.thrift.meta_data.FieldMetaData("cell", org.apache.thrift.TFieldRequirementType.DEFAULT, 
116         new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TCell.class)));
117     metaDataMap = Collections.unmodifiableMap(tmpMap);
118     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TColumn.class, metaDataMap);
119   }
120 
121   public TColumn() {
122   }
123 
124   public TColumn(
125     ByteBuffer columnName,
126     TCell cell)
127   {
128     this();
129     this.columnName = columnName;
130     this.cell = cell;
131   }
132 
133   /**
134    * Performs a deep copy on <i>other</i>.
135    */
136   public TColumn(TColumn other) {
137     if (other.isSetColumnName()) {
138       this.columnName = other.columnName;
139     }
140     if (other.isSetCell()) {
141       this.cell = new TCell(other.cell);
142     }
143   }
144 
145   public TColumn deepCopy() {
146     return new TColumn(this);
147   }
148 
149   @Override
150   public void clear() {
151     this.columnName = null;
152     this.cell = null;
153   }
154 
155   public byte[] getColumnName() {
156     setColumnName(org.apache.thrift.TBaseHelper.rightSize(columnName));
157     return columnName == null ? null : columnName.array();
158   }
159 
160   public ByteBuffer bufferForColumnName() {
161     return columnName;
162   }
163 
164   public TColumn setColumnName(byte[] columnName) {
165     setColumnName(columnName == null ? (ByteBuffer)null : ByteBuffer.wrap(columnName));
166     return this;
167   }
168 
169   public TColumn setColumnName(ByteBuffer columnName) {
170     this.columnName = columnName;
171     return this;
172   }
173 
174   public void unsetColumnName() {
175     this.columnName = null;
176   }
177 
178   /** Returns true if field columnName is set (has been assigned a value) and false otherwise */
179   public boolean isSetColumnName() {
180     return this.columnName != null;
181   }
182 
183   public void setColumnNameIsSet(boolean value) {
184     if (!value) {
185       this.columnName = null;
186     }
187   }
188 
189   public TCell getCell() {
190     return this.cell;
191   }
192 
193   public TColumn setCell(TCell cell) {
194     this.cell = cell;
195     return this;
196   }
197 
198   public void unsetCell() {
199     this.cell = null;
200   }
201 
202   /** Returns true if field cell is set (has been assigned a value) and false otherwise */
203   public boolean isSetCell() {
204     return this.cell != null;
205   }
206 
207   public void setCellIsSet(boolean value) {
208     if (!value) {
209       this.cell = null;
210     }
211   }
212 
213   public void setFieldValue(_Fields field, Object value) {
214     switch (field) {
215     case COLUMN_NAME:
216       if (value == null) {
217         unsetColumnName();
218       } else {
219         setColumnName((ByteBuffer)value);
220       }
221       break;
222 
223     case CELL:
224       if (value == null) {
225         unsetCell();
226       } else {
227         setCell((TCell)value);
228       }
229       break;
230 
231     }
232   }
233 
234   public Object getFieldValue(_Fields field) {
235     switch (field) {
236     case COLUMN_NAME:
237       return getColumnName();
238 
239     case CELL:
240       return getCell();
241 
242     }
243     throw new IllegalStateException();
244   }
245 
246   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
247   public boolean isSet(_Fields field) {
248     if (field == null) {
249       throw new IllegalArgumentException();
250     }
251 
252     switch (field) {
253     case COLUMN_NAME:
254       return isSetColumnName();
255     case CELL:
256       return isSetCell();
257     }
258     throw new IllegalStateException();
259   }
260 
261   @Override
262   public boolean equals(Object that) {
263     if (that == null)
264       return false;
265     if (that instanceof TColumn)
266       return this.equals((TColumn)that);
267     return false;
268   }
269 
270   public boolean equals(TColumn that) {
271     if (that == null)
272       return false;
273 
274     boolean this_present_columnName = true && this.isSetColumnName();
275     boolean that_present_columnName = true && that.isSetColumnName();
276     if (this_present_columnName || that_present_columnName) {
277       if (!(this_present_columnName && that_present_columnName))
278         return false;
279       if (!this.columnName.equals(that.columnName))
280         return false;
281     }
282 
283     boolean this_present_cell = true && this.isSetCell();
284     boolean that_present_cell = true && that.isSetCell();
285     if (this_present_cell || that_present_cell) {
286       if (!(this_present_cell && that_present_cell))
287         return false;
288       if (!this.cell.equals(that.cell))
289         return false;
290     }
291 
292     return true;
293   }
294 
295   @Override
296   public int hashCode() {
297     return 0;
298   }
299 
300   public int compareTo(TColumn other) {
301     if (!getClass().equals(other.getClass())) {
302       return getClass().getName().compareTo(other.getClass().getName());
303     }
304 
305     int lastComparison = 0;
306     TColumn typedOther = (TColumn)other;
307 
308     lastComparison = Boolean.valueOf(isSetColumnName()).compareTo(typedOther.isSetColumnName());
309     if (lastComparison != 0) {
310       return lastComparison;
311     }
312     if (isSetColumnName()) {
313       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.columnName, typedOther.columnName);
314       if (lastComparison != 0) {
315         return lastComparison;
316       }
317     }
318     lastComparison = Boolean.valueOf(isSetCell()).compareTo(typedOther.isSetCell());
319     if (lastComparison != 0) {
320       return lastComparison;
321     }
322     if (isSetCell()) {
323       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.cell, typedOther.cell);
324       if (lastComparison != 0) {
325         return lastComparison;
326       }
327     }
328     return 0;
329   }
330 
331   public _Fields fieldForId(int fieldId) {
332     return _Fields.findByThriftId(fieldId);
333   }
334 
335   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
336     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
337   }
338 
339   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
340     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
341   }
342 
343   @Override
344   public String toString() {
345     StringBuilder sb = new StringBuilder("TColumn(");
346     boolean first = true;
347 
348     sb.append("columnName:");
349     if (this.columnName == null) {
350       sb.append("null");
351     } else {
352       sb.append(this.columnName);
353     }
354     first = false;
355     if (!first) sb.append(", ");
356     sb.append("cell:");
357     if (this.cell == null) {
358       sb.append("null");
359     } else {
360       sb.append(this.cell);
361     }
362     first = false;
363     sb.append(")");
364     return sb.toString();
365   }
366 
367   public void validate() throws org.apache.thrift.TException {
368     // check for required fields
369   }
370 
371   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
372     try {
373       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
374     } catch (org.apache.thrift.TException te) {
375       throw new java.io.IOException(te);
376     }
377   }
378 
379   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
380     try {
381       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
382     } catch (org.apache.thrift.TException te) {
383       throw new java.io.IOException(te);
384     }
385   }
386 
387   private static class TColumnStandardSchemeFactory implements SchemeFactory {
388     public TColumnStandardScheme getScheme() {
389       return new TColumnStandardScheme();
390     }
391   }
392 
393   private static class TColumnStandardScheme extends StandardScheme<TColumn> {
394 
395     public void read(org.apache.thrift.protocol.TProtocol iprot, TColumn struct) throws org.apache.thrift.TException {
396       org.apache.thrift.protocol.TField schemeField;
397       iprot.readStructBegin();
398       while (true)
399       {
400         schemeField = iprot.readFieldBegin();
401         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
402           break;
403         }
404         switch (schemeField.id) {
405           case 1: // COLUMN_NAME
406             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
407               struct.columnName = iprot.readBinary();
408               struct.setColumnNameIsSet(true);
409             } else { 
410               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
411             }
412             break;
413           case 2: // CELL
414             if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
415               struct.cell = new TCell();
416               struct.cell.read(iprot);
417               struct.setCellIsSet(true);
418             } else { 
419               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
420             }
421             break;
422           default:
423             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
424         }
425         iprot.readFieldEnd();
426       }
427       iprot.readStructEnd();
428 
429       // check for required fields of primitive type, which can't be checked in the validate method
430       struct.validate();
431     }
432 
433     public void write(org.apache.thrift.protocol.TProtocol oprot, TColumn struct) throws org.apache.thrift.TException {
434       struct.validate();
435 
436       oprot.writeStructBegin(STRUCT_DESC);
437       if (struct.columnName != null) {
438         oprot.writeFieldBegin(COLUMN_NAME_FIELD_DESC);
439         oprot.writeBinary(struct.columnName);
440         oprot.writeFieldEnd();
441       }
442       if (struct.cell != null) {
443         oprot.writeFieldBegin(CELL_FIELD_DESC);
444         struct.cell.write(oprot);
445         oprot.writeFieldEnd();
446       }
447       oprot.writeFieldStop();
448       oprot.writeStructEnd();
449     }
450 
451   }
452 
453   private static class TColumnTupleSchemeFactory implements SchemeFactory {
454     public TColumnTupleScheme getScheme() {
455       return new TColumnTupleScheme();
456     }
457   }
458 
459   private static class TColumnTupleScheme extends TupleScheme<TColumn> {
460 
461     @Override
462     public void write(org.apache.thrift.protocol.TProtocol prot, TColumn struct) throws org.apache.thrift.TException {
463       TTupleProtocol oprot = (TTupleProtocol) prot;
464       BitSet optionals = new BitSet();
465       if (struct.isSetColumnName()) {
466         optionals.set(0);
467       }
468       if (struct.isSetCell()) {
469         optionals.set(1);
470       }
471       oprot.writeBitSet(optionals, 2);
472       if (struct.isSetColumnName()) {
473         oprot.writeBinary(struct.columnName);
474       }
475       if (struct.isSetCell()) {
476         struct.cell.write(oprot);
477       }
478     }
479 
480     @Override
481     public void read(org.apache.thrift.protocol.TProtocol prot, TColumn struct) throws org.apache.thrift.TException {
482       TTupleProtocol iprot = (TTupleProtocol) prot;
483       BitSet incoming = iprot.readBitSet(2);
484       if (incoming.get(0)) {
485         struct.columnName = iprot.readBinary();
486         struct.setColumnNameIsSet(true);
487       }
488       if (incoming.get(1)) {
489         struct.cell = new TCell();
490         struct.cell.read(iprot);
491         struct.setCellIsSet(true);
492       }
493     }
494   }
495 
496 }
497