ThriftResult.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. /**
  2. * Autogenerated by Thrift Compiler (0.9.3)
  3. *
  4. * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  5. * @generated
  6. */
  7. package com.sec.xinhua.gateway.thrift;
  8. import java.util.ArrayList;
  9. import java.util.BitSet;
  10. import java.util.Collections;
  11. import java.util.EnumMap;
  12. import java.util.EnumSet;
  13. import java.util.HashMap;
  14. import java.util.List;
  15. import java.util.Map;
  16. import javax.annotation.Generated;
  17. import org.apache.thrift.EncodingUtils;
  18. import org.apache.thrift.protocol.TTupleProtocol;
  19. import org.apache.thrift.scheme.IScheme;
  20. import org.apache.thrift.scheme.SchemeFactory;
  21. import org.apache.thrift.scheme.StandardScheme;
  22. import org.apache.thrift.scheme.TupleScheme;
  23. @SuppressWarnings({ "cast", "rawtypes", "serial", "unchecked" })
  24. @Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2015-12-21")
  25. public class ThriftResult implements org.apache.thrift.TBase<ThriftResult, ThriftResult._Fields>, java.io.Serializable,
  26. Cloneable, Comparable<ThriftResult> {
  27. private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct(
  28. "ThriftResult");
  29. private static final org.apache.thrift.protocol.TField CODE_FIELD_DESC = new org.apache.thrift.protocol.TField(
  30. "code",
  31. org.apache.thrift.protocol.TType.I32,
  32. (short) 1);
  33. private static final org.apache.thrift.protocol.TField MSG_FIELD_DESC = new org.apache.thrift.protocol.TField(
  34. "msg",
  35. org.apache.thrift.protocol.TType.STRING,
  36. (short) 2);
  37. private static final org.apache.thrift.protocol.TField DATA_FIELD_DESC = new org.apache.thrift.protocol.TField(
  38. "data",
  39. org.apache.thrift.protocol.TType.STRING,
  40. (short) 3);
  41. private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
  42. static {
  43. schemes.put(StandardScheme.class, new ThriftResultStandardSchemeFactory());
  44. schemes.put(TupleScheme.class, new ThriftResultTupleSchemeFactory());
  45. }
  46. public int code; // required
  47. public String msg; // required
  48. public String data; // required
  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. CODE((short) 1, "code"), MSG((short) 2, "msg"), DATA((short) 3, "data");
  52. private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
  53. static {
  54. for (_Fields field : EnumSet.allOf(_Fields.class)) {
  55. byName.put(field.getFieldName(), field);
  56. }
  57. }
  58. /**
  59. * Find the _Fields constant that matches fieldId, or null if its not found.
  60. */
  61. public static _Fields findByThriftId(int fieldId) {
  62. switch (fieldId) {
  63. case 1: // CODE
  64. return CODE;
  65. case 2: // MSG
  66. return MSG;
  67. case 3: // DATA
  68. return DATA;
  69. default:
  70. return null;
  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)
  80. throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
  81. return fields;
  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. private final short _thriftId;
  90. private final String _fieldName;
  91. _Fields(short thriftId, String fieldName) {
  92. _thriftId = thriftId;
  93. _fieldName = fieldName;
  94. }
  95. public short getThriftFieldId() {
  96. return _thriftId;
  97. }
  98. public String getFieldName() {
  99. return _fieldName;
  100. }
  101. }
  102. // isset id assignments
  103. private static final int __CODE_ISSET_ID = 0;
  104. private byte __isset_bitfield = 0;
  105. public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
  106. static {
  107. Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(
  108. _Fields.class);
  109. tmpMap.put(_Fields.CODE, new org.apache.thrift.meta_data.FieldMetaData("code",
  110. org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(
  111. org.apache.thrift.protocol.TType.I32)));
  112. tmpMap.put(_Fields.MSG, new org.apache.thrift.meta_data.FieldMetaData("msg",
  113. org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(
  114. org.apache.thrift.protocol.TType.STRING)));
  115. tmpMap.put(_Fields.DATA, new org.apache.thrift.meta_data.FieldMetaData("data",
  116. org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(
  117. org.apache.thrift.protocol.TType.STRING)));
  118. metaDataMap = Collections.unmodifiableMap(tmpMap);
  119. org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ThriftResult.class, metaDataMap);
  120. }
  121. public ThriftResult() {
  122. }
  123. public ThriftResult(int code, String msg, String data) {
  124. this();
  125. this.code = code;
  126. setCodeIsSet(true);
  127. this.msg = msg;
  128. this.data = data;
  129. }
  130. /**
  131. * Performs a deep copy on <i>other</i>.
  132. */
  133. public ThriftResult(ThriftResult other) {
  134. __isset_bitfield = other.__isset_bitfield;
  135. this.code = other.code;
  136. if (other.isSetMsg()) {
  137. this.msg = other.msg;
  138. }
  139. if (other.isSetData()) {
  140. this.data = other.data;
  141. }
  142. }
  143. public ThriftResult deepCopy() {
  144. return new ThriftResult(this);
  145. }
  146. @Override
  147. public void clear() {
  148. setCodeIsSet(false);
  149. this.code = 0;
  150. this.msg = null;
  151. this.data = null;
  152. }
  153. public int getCode() {
  154. return this.code;
  155. }
  156. public ThriftResult setCode(int code) {
  157. this.code = code;
  158. setCodeIsSet(true);
  159. return this;
  160. }
  161. public void unsetCode() {
  162. __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __CODE_ISSET_ID);
  163. }
  164. /** Returns true if field code is set (has been assigned a value) and false otherwise */
  165. public boolean isSetCode() {
  166. return EncodingUtils.testBit(__isset_bitfield, __CODE_ISSET_ID);
  167. }
  168. public void setCodeIsSet(boolean value) {
  169. __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __CODE_ISSET_ID, value);
  170. }
  171. public String getMsg() {
  172. return this.msg;
  173. }
  174. public ThriftResult setMsg(String msg) {
  175. this.msg = msg;
  176. return this;
  177. }
  178. public void unsetMsg() {
  179. this.msg = null;
  180. }
  181. /** Returns true if field msg is set (has been assigned a value) and false otherwise */
  182. public boolean isSetMsg() {
  183. return this.msg != null;
  184. }
  185. public void setMsgIsSet(boolean value) {
  186. if (!value) {
  187. this.msg = null;
  188. }
  189. }
  190. public String getData() {
  191. return this.data;
  192. }
  193. public ThriftResult setData(String data) {
  194. this.data = data;
  195. return this;
  196. }
  197. public void unsetData() {
  198. this.data = null;
  199. }
  200. /** Returns true if field data is set (has been assigned a value) and false otherwise */
  201. public boolean isSetData() {
  202. return this.data != null;
  203. }
  204. public void setDataIsSet(boolean value) {
  205. if (!value) {
  206. this.data = null;
  207. }
  208. }
  209. public void setFieldValue(_Fields field, Object value) {
  210. switch (field) {
  211. case CODE:
  212. if (value == null) {
  213. unsetCode();
  214. } else {
  215. setCode((Integer) value);
  216. }
  217. break;
  218. case MSG:
  219. if (value == null) {
  220. unsetMsg();
  221. } else {
  222. setMsg((String) value);
  223. }
  224. break;
  225. case DATA:
  226. if (value == null) {
  227. unsetData();
  228. } else {
  229. setData((String) value);
  230. }
  231. break;
  232. }
  233. }
  234. public Object getFieldValue(_Fields field) {
  235. switch (field) {
  236. case CODE:
  237. return getCode();
  238. case MSG:
  239. return getMsg();
  240. case DATA:
  241. return getData();
  242. }
  243. throw new IllegalStateException();
  244. }
  245. /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
  246. public boolean isSet(_Fields field) {
  247. if (field == null) {
  248. throw new IllegalArgumentException();
  249. }
  250. switch (field) {
  251. case CODE:
  252. return isSetCode();
  253. case MSG:
  254. return isSetMsg();
  255. case DATA:
  256. return isSetData();
  257. }
  258. throw new IllegalStateException();
  259. }
  260. @Override
  261. public boolean equals(Object that) {
  262. if (that == null)
  263. return false;
  264. if (that instanceof ThriftResult)
  265. return this.equals((ThriftResult) that);
  266. return false;
  267. }
  268. public boolean equals(ThriftResult that) {
  269. if (that == null)
  270. return false;
  271. boolean this_present_code = true;
  272. boolean that_present_code = true;
  273. if (this_present_code || that_present_code) {
  274. if (!(this_present_code && that_present_code))
  275. return false;
  276. if (this.code != that.code)
  277. return false;
  278. }
  279. boolean this_present_msg = true && this.isSetMsg();
  280. boolean that_present_msg = true && that.isSetMsg();
  281. if (this_present_msg || that_present_msg) {
  282. if (!(this_present_msg && that_present_msg))
  283. return false;
  284. if (!this.msg.equals(that.msg))
  285. return false;
  286. }
  287. boolean this_present_data = true && this.isSetData();
  288. boolean that_present_data = true && that.isSetData();
  289. if (this_present_data || that_present_data) {
  290. if (!(this_present_data && that_present_data))
  291. return false;
  292. if (!this.data.equals(that.data))
  293. return false;
  294. }
  295. return true;
  296. }
  297. @Override
  298. public int hashCode() {
  299. List<Object> list = new ArrayList<Object>();
  300. boolean present_code = true;
  301. list.add(present_code);
  302. if (present_code)
  303. list.add(code);
  304. boolean present_msg = true && (isSetMsg());
  305. list.add(present_msg);
  306. if (present_msg)
  307. list.add(msg);
  308. boolean present_data = true && (isSetData());
  309. list.add(present_data);
  310. if (present_data)
  311. list.add(data);
  312. return list.hashCode();
  313. }
  314. @Override
  315. public int compareTo(ThriftResult other) {
  316. if (!getClass().equals(other.getClass())) {
  317. return getClass().getName().compareTo(other.getClass().getName());
  318. }
  319. int lastComparison = 0;
  320. lastComparison = Boolean.valueOf(isSetCode()).compareTo(other.isSetCode());
  321. if (lastComparison != 0) {
  322. return lastComparison;
  323. }
  324. if (isSetCode()) {
  325. lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.code, other.code);
  326. if (lastComparison != 0) {
  327. return lastComparison;
  328. }
  329. }
  330. lastComparison = Boolean.valueOf(isSetMsg()).compareTo(other.isSetMsg());
  331. if (lastComparison != 0) {
  332. return lastComparison;
  333. }
  334. if (isSetMsg()) {
  335. lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.msg, other.msg);
  336. if (lastComparison != 0) {
  337. return lastComparison;
  338. }
  339. }
  340. lastComparison = Boolean.valueOf(isSetData()).compareTo(other.isSetData());
  341. if (lastComparison != 0) {
  342. return lastComparison;
  343. }
  344. if (isSetData()) {
  345. lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.data, other.data);
  346. if (lastComparison != 0) {
  347. return lastComparison;
  348. }
  349. }
  350. return 0;
  351. }
  352. public _Fields fieldForId(int fieldId) {
  353. return _Fields.findByThriftId(fieldId);
  354. }
  355. public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
  356. schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
  357. }
  358. public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
  359. schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
  360. }
  361. @Override
  362. public String toString() {
  363. StringBuilder sb = new StringBuilder("ThriftResult(");
  364. boolean first = true;
  365. sb.append("code:");
  366. sb.append(this.code);
  367. first = false;
  368. if (!first)
  369. sb.append(", ");
  370. sb.append("msg:");
  371. if (this.msg == null) {
  372. sb.append("null");
  373. } else {
  374. sb.append(this.msg);
  375. }
  376. first = false;
  377. if (!first)
  378. sb.append(", ");
  379. sb.append("data:");
  380. if (this.data == null) {
  381. sb.append("null");
  382. } else {
  383. sb.append(this.data);
  384. }
  385. first = false;
  386. sb.append(")");
  387. return sb.toString();
  388. }
  389. public void validate() throws org.apache.thrift.TException {
  390. // check for required fields
  391. // check for sub-struct validity
  392. }
  393. private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
  394. try {
  395. write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(
  396. out)));
  397. } catch (org.apache.thrift.TException te) {
  398. throw new java.io.IOException(te);
  399. }
  400. }
  401. private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
  402. try {
  403. // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
  404. __isset_bitfield = 0;
  405. read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
  406. } catch (org.apache.thrift.TException te) {
  407. throw new java.io.IOException(te);
  408. }
  409. }
  410. private static class ThriftResultStandardSchemeFactory implements SchemeFactory {
  411. public ThriftResultStandardScheme getScheme() {
  412. return new ThriftResultStandardScheme();
  413. }
  414. }
  415. private static class ThriftResultStandardScheme extends StandardScheme<ThriftResult> {
  416. public void read(org.apache.thrift.protocol.TProtocol iprot, ThriftResult struct)
  417. throws org.apache.thrift.TException {
  418. org.apache.thrift.protocol.TField schemeField;
  419. iprot.readStructBegin();
  420. while (true) {
  421. schemeField = iprot.readFieldBegin();
  422. if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
  423. break;
  424. }
  425. switch (schemeField.id) {
  426. case 1: // CODE
  427. if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
  428. struct.code = iprot.readI32();
  429. struct.setCodeIsSet(true);
  430. } else {
  431. org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
  432. }
  433. break;
  434. case 2: // MSG
  435. if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
  436. struct.msg = iprot.readString();
  437. struct.setMsgIsSet(true);
  438. } else {
  439. org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
  440. }
  441. break;
  442. case 3: // DATA
  443. if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
  444. struct.data = iprot.readString();
  445. struct.setDataIsSet(true);
  446. } else {
  447. org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
  448. }
  449. break;
  450. default:
  451. org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
  452. }
  453. iprot.readFieldEnd();
  454. }
  455. iprot.readStructEnd();
  456. // check for required fields of primitive type, which can't be checked in the validate method
  457. struct.validate();
  458. }
  459. public void write(org.apache.thrift.protocol.TProtocol oprot, ThriftResult struct)
  460. throws org.apache.thrift.TException {
  461. struct.validate();
  462. oprot.writeStructBegin(STRUCT_DESC);
  463. oprot.writeFieldBegin(CODE_FIELD_DESC);
  464. oprot.writeI32(struct.code);
  465. oprot.writeFieldEnd();
  466. if (struct.msg != null) {
  467. oprot.writeFieldBegin(MSG_FIELD_DESC);
  468. oprot.writeString(struct.msg);
  469. oprot.writeFieldEnd();
  470. }
  471. if (struct.data != null) {
  472. oprot.writeFieldBegin(DATA_FIELD_DESC);
  473. oprot.writeString(struct.data);
  474. oprot.writeFieldEnd();
  475. }
  476. oprot.writeFieldStop();
  477. oprot.writeStructEnd();
  478. }
  479. }
  480. private static class ThriftResultTupleSchemeFactory implements SchemeFactory {
  481. public ThriftResultTupleScheme getScheme() {
  482. return new ThriftResultTupleScheme();
  483. }
  484. }
  485. private static class ThriftResultTupleScheme extends TupleScheme<ThriftResult> {
  486. @Override
  487. public void write(org.apache.thrift.protocol.TProtocol prot, ThriftResult struct)
  488. throws org.apache.thrift.TException {
  489. TTupleProtocol oprot = (TTupleProtocol) prot;
  490. BitSet optionals = new BitSet();
  491. if (struct.isSetCode()) {
  492. optionals.set(0);
  493. }
  494. if (struct.isSetMsg()) {
  495. optionals.set(1);
  496. }
  497. if (struct.isSetData()) {
  498. optionals.set(2);
  499. }
  500. oprot.writeBitSet(optionals, 3);
  501. if (struct.isSetCode()) {
  502. oprot.writeI32(struct.code);
  503. }
  504. if (struct.isSetMsg()) {
  505. oprot.writeString(struct.msg);
  506. }
  507. if (struct.isSetData()) {
  508. oprot.writeString(struct.data);
  509. }
  510. }
  511. @Override
  512. public void read(org.apache.thrift.protocol.TProtocol prot, ThriftResult struct)
  513. throws org.apache.thrift.TException {
  514. TTupleProtocol iprot = (TTupleProtocol) prot;
  515. BitSet incoming = iprot.readBitSet(3);
  516. if (incoming.get(0)) {
  517. struct.code = iprot.readI32();
  518. struct.setCodeIsSet(true);
  519. }
  520. if (incoming.get(1)) {
  521. struct.msg = iprot.readString();
  522. struct.setMsgIsSet(true);
  523. }
  524. if (incoming.get(2)) {
  525. struct.data = iprot.readString();
  526. struct.setDataIsSet(true);
  527. }
  528. }
  529. }
  530. }