Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
305 ashish 1
/**
2
 * Autogenerated by Thrift
3
 *
4
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
 */
6
package in.shop2020.datalogger;
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.util.Arrays;
19
import org.slf4j.Logger;
20
import org.slf4j.LoggerFactory;
21
 
22
import org.apache.thrift.*;
23
import org.apache.thrift.meta_data.*;
24
import org.apache.thrift.protocol.*;
25
 
26
public class DataLogger {
27
 
28
  public interface Iface {
29
 
30
    public void log(MsgType messageType, String message) throws TException;
31
 
32
  }
33
 
34
  public static class Client implements Iface {
35
    public Client(TProtocol prot)
36
    {
37
      this(prot, prot);
38
    }
39
 
40
    public Client(TProtocol iprot, TProtocol oprot)
41
    {
42
      iprot_ = iprot;
43
      oprot_ = oprot;
44
    }
45
 
46
    protected TProtocol iprot_;
47
    protected TProtocol oprot_;
48
 
49
    protected int seqid_;
50
 
51
    public TProtocol getInputProtocol()
52
    {
53
      return this.iprot_;
54
    }
55
 
56
    public TProtocol getOutputProtocol()
57
    {
58
      return this.oprot_;
59
    }
60
 
61
    public void log(MsgType messageType, String message) throws TException
62
    {
63
      send_log(messageType, message);
64
      recv_log();
65
    }
66
 
67
    public void send_log(MsgType messageType, String message) throws TException
68
    {
69
      oprot_.writeMessageBegin(new TMessage("log", TMessageType.CALL, seqid_));
70
      log_args args = new log_args();
71
      args.messageType = messageType;
72
      args.message = message;
73
      args.write(oprot_);
74
      oprot_.writeMessageEnd();
75
      oprot_.getTransport().flush();
76
    }
77
 
78
    public void recv_log() throws TException
79
    {
80
      TMessage msg = iprot_.readMessageBegin();
81
      if (msg.type == TMessageType.EXCEPTION) {
82
        TApplicationException x = TApplicationException.read(iprot_);
83
        iprot_.readMessageEnd();
84
        throw x;
85
      }
86
      log_result result = new log_result();
87
      result.read(iprot_);
88
      iprot_.readMessageEnd();
89
      return;
90
    }
91
 
92
  }
93
  public static class Processor implements TProcessor {
94
    private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName());
95
    public Processor(Iface iface)
96
    {
97
      iface_ = iface;
98
      processMap_.put("log", new log());
99
    }
100
 
101
    protected static interface ProcessFunction {
102
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException;
103
    }
104
 
105
    private Iface iface_;
106
    protected final HashMap<String,ProcessFunction> processMap_ = new HashMap<String,ProcessFunction>();
107
 
108
    public boolean process(TProtocol iprot, TProtocol oprot) throws TException
109
    {
110
      TMessage msg = iprot.readMessageBegin();
111
      ProcessFunction fn = processMap_.get(msg.name);
112
      if (fn == null) {
113
        TProtocolUtil.skip(iprot, TType.STRUCT);
114
        iprot.readMessageEnd();
115
        TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, "Invalid method name: '"+msg.name+"'");
116
        oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));
117
        x.write(oprot);
118
        oprot.writeMessageEnd();
119
        oprot.getTransport().flush();
120
        return true;
121
      }
122
      fn.process(msg.seqid, iprot, oprot);
123
      return true;
124
    }
125
 
126
    private class log implements ProcessFunction {
127
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
128
      {
129
        log_args args = new log_args();
130
        args.read(iprot);
131
        iprot.readMessageEnd();
132
        log_result result = new log_result();
133
        iface_.log(args.messageType, args.message);
134
        oprot.writeMessageBegin(new TMessage("log", TMessageType.REPLY, seqid));
135
        result.write(oprot);
136
        oprot.writeMessageEnd();
137
        oprot.getTransport().flush();
138
      }
139
 
140
    }
141
 
142
  }
143
 
144
  public static class log_args implements TBase<log_args._Fields>, java.io.Serializable, Cloneable, Comparable<log_args>   {
145
    private static final TStruct STRUCT_DESC = new TStruct("log_args");
146
 
147
    private static final TField MESSAGE_TYPE_FIELD_DESC = new TField("messageType", TType.I32, (short)1);
148
    private static final TField MESSAGE_FIELD_DESC = new TField("message", TType.STRING, (short)2);
149
 
150
    private MsgType messageType;
151
    private String message;
152
 
153
    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
154
    public enum _Fields implements TFieldIdEnum {
155
      /**
156
       * 
157
       * @see MsgType
158
       */
159
      MESSAGE_TYPE((short)1, "messageType"),
160
      MESSAGE((short)2, "message");
161
 
162
      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
163
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
164
 
165
      static {
166
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
167
          byId.put((int)field._thriftId, field);
168
          byName.put(field.getFieldName(), field);
169
        }
170
      }
171
 
172
      /**
173
       * Find the _Fields constant that matches fieldId, or null if its not found.
174
       */
175
      public static _Fields findByThriftId(int fieldId) {
176
        return byId.get(fieldId);
177
      }
178
 
179
      /**
180
       * Find the _Fields constant that matches fieldId, throwing an exception
181
       * if it is not found.
182
       */
183
      public static _Fields findByThriftIdOrThrow(int fieldId) {
184
        _Fields fields = findByThriftId(fieldId);
185
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
186
        return fields;
187
      }
188
 
189
      /**
190
       * Find the _Fields constant that matches name, or null if its not found.
191
       */
192
      public static _Fields findByName(String name) {
193
        return byName.get(name);
194
      }
195
 
196
      private final short _thriftId;
197
      private final String _fieldName;
198
 
199
      _Fields(short thriftId, String fieldName) {
200
        _thriftId = thriftId;
201
        _fieldName = fieldName;
202
      }
203
 
204
      public short getThriftFieldId() {
205
        return _thriftId;
206
      }
207
 
208
      public String getFieldName() {
209
        return _fieldName;
210
      }
211
    }
212
 
213
    // isset id assignments
214
 
215
    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
216
      put(_Fields.MESSAGE_TYPE, new FieldMetaData("messageType", TFieldRequirementType.DEFAULT, 
217
          new EnumMetaData(TType.ENUM, MsgType.class)));
218
      put(_Fields.MESSAGE, new FieldMetaData("message", TFieldRequirementType.DEFAULT, 
219
          new FieldValueMetaData(TType.STRING)));
220
    }});
221
 
222
    static {
223
      FieldMetaData.addStructMetaDataMap(log_args.class, metaDataMap);
224
    }
225
 
226
    public log_args() {
227
    }
228
 
229
    public log_args(
230
      MsgType messageType,
231
      String message)
232
    {
233
      this();
234
      this.messageType = messageType;
235
      this.message = message;
236
    }
237
 
238
    /**
239
     * Performs a deep copy on <i>other</i>.
240
     */
241
    public log_args(log_args other) {
242
      if (other.isSetMessageType()) {
243
        this.messageType = other.messageType;
244
      }
245
      if (other.isSetMessage()) {
246
        this.message = other.message;
247
      }
248
    }
249
 
250
    public log_args deepCopy() {
251
      return new log_args(this);
252
    }
253
 
254
    @Deprecated
255
    public log_args clone() {
256
      return new log_args(this);
257
    }
258
 
259
    /**
260
     * 
261
     * @see MsgType
262
     */
263
    public MsgType getMessageType() {
264
      return this.messageType;
265
    }
266
 
267
    /**
268
     * 
269
     * @see MsgType
270
     */
271
    public log_args setMessageType(MsgType messageType) {
272
      this.messageType = messageType;
273
      return this;
274
    }
275
 
276
    public void unsetMessageType() {
277
      this.messageType = null;
278
    }
279
 
280
    /** Returns true if field messageType is set (has been asigned a value) and false otherwise */
281
    public boolean isSetMessageType() {
282
      return this.messageType != null;
283
    }
284
 
285
    public void setMessageTypeIsSet(boolean value) {
286
      if (!value) {
287
        this.messageType = null;
288
      }
289
    }
290
 
291
    public String getMessage() {
292
      return this.message;
293
    }
294
 
295
    public log_args setMessage(String message) {
296
      this.message = message;
297
      return this;
298
    }
299
 
300
    public void unsetMessage() {
301
      this.message = null;
302
    }
303
 
304
    /** Returns true if field message is set (has been asigned a value) and false otherwise */
305
    public boolean isSetMessage() {
306
      return this.message != null;
307
    }
308
 
309
    public void setMessageIsSet(boolean value) {
310
      if (!value) {
311
        this.message = null;
312
      }
313
    }
314
 
315
    public void setFieldValue(_Fields field, Object value) {
316
      switch (field) {
317
      case MESSAGE_TYPE:
318
        if (value == null) {
319
          unsetMessageType();
320
        } else {
321
          setMessageType((MsgType)value);
322
        }
323
        break;
324
 
325
      case MESSAGE:
326
        if (value == null) {
327
          unsetMessage();
328
        } else {
329
          setMessage((String)value);
330
        }
331
        break;
332
 
333
      }
334
    }
335
 
336
    public void setFieldValue(int fieldID, Object value) {
337
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
338
    }
339
 
340
    public Object getFieldValue(_Fields field) {
341
      switch (field) {
342
      case MESSAGE_TYPE:
343
        return getMessageType();
344
 
345
      case MESSAGE:
346
        return getMessage();
347
 
348
      }
349
      throw new IllegalStateException();
350
    }
351
 
352
    public Object getFieldValue(int fieldId) {
353
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
354
    }
355
 
356
    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
357
    public boolean isSet(_Fields field) {
358
      switch (field) {
359
      case MESSAGE_TYPE:
360
        return isSetMessageType();
361
      case MESSAGE:
362
        return isSetMessage();
363
      }
364
      throw new IllegalStateException();
365
    }
366
 
367
    public boolean isSet(int fieldID) {
368
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
369
    }
370
 
371
    @Override
372
    public boolean equals(Object that) {
373
      if (that == null)
374
        return false;
375
      if (that instanceof log_args)
376
        return this.equals((log_args)that);
377
      return false;
378
    }
379
 
380
    public boolean equals(log_args that) {
381
      if (that == null)
382
        return false;
383
 
384
      boolean this_present_messageType = true && this.isSetMessageType();
385
      boolean that_present_messageType = true && that.isSetMessageType();
386
      if (this_present_messageType || that_present_messageType) {
387
        if (!(this_present_messageType && that_present_messageType))
388
          return false;
389
        if (!this.messageType.equals(that.messageType))
390
          return false;
391
      }
392
 
393
      boolean this_present_message = true && this.isSetMessage();
394
      boolean that_present_message = true && that.isSetMessage();
395
      if (this_present_message || that_present_message) {
396
        if (!(this_present_message && that_present_message))
397
          return false;
398
        if (!this.message.equals(that.message))
399
          return false;
400
      }
401
 
402
      return true;
403
    }
404
 
405
    @Override
406
    public int hashCode() {
407
      return 0;
408
    }
409
 
410
    public int compareTo(log_args other) {
411
      if (!getClass().equals(other.getClass())) {
412
        return getClass().getName().compareTo(other.getClass().getName());
413
      }
414
 
415
      int lastComparison = 0;
416
      log_args typedOther = (log_args)other;
417
 
418
      lastComparison = Boolean.valueOf(isSetMessageType()).compareTo(isSetMessageType());
419
      if (lastComparison != 0) {
420
        return lastComparison;
421
      }
422
      lastComparison = TBaseHelper.compareTo(messageType, typedOther.messageType);
423
      if (lastComparison != 0) {
424
        return lastComparison;
425
      }
426
      lastComparison = Boolean.valueOf(isSetMessage()).compareTo(isSetMessage());
427
      if (lastComparison != 0) {
428
        return lastComparison;
429
      }
430
      lastComparison = TBaseHelper.compareTo(message, typedOther.message);
431
      if (lastComparison != 0) {
432
        return lastComparison;
433
      }
434
      return 0;
435
    }
436
 
437
    public void read(TProtocol iprot) throws TException {
438
      TField field;
439
      iprot.readStructBegin();
440
      while (true)
441
      {
442
        field = iprot.readFieldBegin();
443
        if (field.type == TType.STOP) { 
444
          break;
445
        }
446
        _Fields fieldId = _Fields.findByThriftId(field.id);
447
        if (fieldId == null) {
448
          TProtocolUtil.skip(iprot, field.type);
449
        } else {
450
          switch (fieldId) {
451
            case MESSAGE_TYPE:
452
              if (field.type == TType.I32) {
453
                this.messageType = MsgType.findByValue(iprot.readI32());
454
              } else { 
455
                TProtocolUtil.skip(iprot, field.type);
456
              }
457
              break;
458
            case MESSAGE:
459
              if (field.type == TType.STRING) {
460
                this.message = iprot.readString();
461
              } else { 
462
                TProtocolUtil.skip(iprot, field.type);
463
              }
464
              break;
465
          }
466
          iprot.readFieldEnd();
467
        }
468
      }
469
      iprot.readStructEnd();
470
      validate();
471
    }
472
 
473
    public void write(TProtocol oprot) throws TException {
474
      validate();
475
 
476
      oprot.writeStructBegin(STRUCT_DESC);
477
      if (this.messageType != null) {
478
        oprot.writeFieldBegin(MESSAGE_TYPE_FIELD_DESC);
479
        oprot.writeI32(this.messageType.getValue());
480
        oprot.writeFieldEnd();
481
      }
482
      if (this.message != null) {
483
        oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
484
        oprot.writeString(this.message);
485
        oprot.writeFieldEnd();
486
      }
487
      oprot.writeFieldStop();
488
      oprot.writeStructEnd();
489
    }
490
 
491
    @Override
492
    public String toString() {
493
      StringBuilder sb = new StringBuilder("log_args(");
494
      boolean first = true;
495
 
496
      sb.append("messageType:");
497
      if (this.messageType == null) {
498
        sb.append("null");
499
      } else {
500
        String messageType_name = messageType.name();
501
        if (messageType_name != null) {
502
          sb.append(messageType_name);
503
          sb.append(" (");
504
        }
505
        sb.append(this.messageType);
506
        if (messageType_name != null) {
507
          sb.append(")");
508
        }
509
      }
510
      first = false;
511
      if (!first) sb.append(", ");
512
      sb.append("message:");
513
      if (this.message == null) {
514
        sb.append("null");
515
      } else {
516
        sb.append(this.message);
517
      }
518
      first = false;
519
      sb.append(")");
520
      return sb.toString();
521
    }
522
 
523
    public void validate() throws TException {
524
      // check for required fields
525
    }
526
 
527
  }
528
 
529
  public static class log_result implements TBase<log_result._Fields>, java.io.Serializable, Cloneable, Comparable<log_result>   {
530
    private static final TStruct STRUCT_DESC = new TStruct("log_result");
531
 
532
 
533
 
534
    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
535
    public enum _Fields implements TFieldIdEnum {
536
;
537
 
538
      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
539
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
540
 
541
      static {
542
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
543
          byId.put((int)field._thriftId, field);
544
          byName.put(field.getFieldName(), field);
545
        }
546
      }
547
 
548
      /**
549
       * Find the _Fields constant that matches fieldId, or null if its not found.
550
       */
551
      public static _Fields findByThriftId(int fieldId) {
552
        return byId.get(fieldId);
553
      }
554
 
555
      /**
556
       * Find the _Fields constant that matches fieldId, throwing an exception
557
       * if it is not found.
558
       */
559
      public static _Fields findByThriftIdOrThrow(int fieldId) {
560
        _Fields fields = findByThriftId(fieldId);
561
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
562
        return fields;
563
      }
564
 
565
      /**
566
       * Find the _Fields constant that matches name, or null if its not found.
567
       */
568
      public static _Fields findByName(String name) {
569
        return byName.get(name);
570
      }
571
 
572
      private final short _thriftId;
573
      private final String _fieldName;
574
 
575
      _Fields(short thriftId, String fieldName) {
576
        _thriftId = thriftId;
577
        _fieldName = fieldName;
578
      }
579
 
580
      public short getThriftFieldId() {
581
        return _thriftId;
582
      }
583
 
584
      public String getFieldName() {
585
        return _fieldName;
586
      }
587
    }
588
    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
589
    }});
590
 
591
    static {
592
      FieldMetaData.addStructMetaDataMap(log_result.class, metaDataMap);
593
    }
594
 
595
    public log_result() {
596
    }
597
 
598
    /**
599
     * Performs a deep copy on <i>other</i>.
600
     */
601
    public log_result(log_result other) {
602
    }
603
 
604
    public log_result deepCopy() {
605
      return new log_result(this);
606
    }
607
 
608
    @Deprecated
609
    public log_result clone() {
610
      return new log_result(this);
611
    }
612
 
613
    public void setFieldValue(_Fields field, Object value) {
614
      switch (field) {
615
      }
616
    }
617
 
618
    public void setFieldValue(int fieldID, Object value) {
619
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
620
    }
621
 
622
    public Object getFieldValue(_Fields field) {
623
      switch (field) {
624
      }
625
      throw new IllegalStateException();
626
    }
627
 
628
    public Object getFieldValue(int fieldId) {
629
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
630
    }
631
 
632
    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
633
    public boolean isSet(_Fields field) {
634
      switch (field) {
635
      }
636
      throw new IllegalStateException();
637
    }
638
 
639
    public boolean isSet(int fieldID) {
640
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
641
    }
642
 
643
    @Override
644
    public boolean equals(Object that) {
645
      if (that == null)
646
        return false;
647
      if (that instanceof log_result)
648
        return this.equals((log_result)that);
649
      return false;
650
    }
651
 
652
    public boolean equals(log_result that) {
653
      if (that == null)
654
        return false;
655
 
656
      return true;
657
    }
658
 
659
    @Override
660
    public int hashCode() {
661
      return 0;
662
    }
663
 
664
    public int compareTo(log_result other) {
665
      if (!getClass().equals(other.getClass())) {
666
        return getClass().getName().compareTo(other.getClass().getName());
667
      }
668
 
669
      int lastComparison = 0;
670
      log_result typedOther = (log_result)other;
671
 
672
      return 0;
673
    }
674
 
675
    public void read(TProtocol iprot) throws TException {
676
      TField field;
677
      iprot.readStructBegin();
678
      while (true)
679
      {
680
        field = iprot.readFieldBegin();
681
        if (field.type == TType.STOP) { 
682
          break;
683
        }
684
        _Fields fieldId = _Fields.findByThriftId(field.id);
685
        if (fieldId == null) {
686
          TProtocolUtil.skip(iprot, field.type);
687
        } else {
688
          switch (fieldId) {
689
          }
690
          iprot.readFieldEnd();
691
        }
692
      }
693
      iprot.readStructEnd();
694
      validate();
695
    }
696
 
697
    public void write(TProtocol oprot) throws TException {
698
      oprot.writeStructBegin(STRUCT_DESC);
699
 
700
      oprot.writeFieldStop();
701
      oprot.writeStructEnd();
702
    }
703
 
704
    @Override
705
    public String toString() {
706
      StringBuilder sb = new StringBuilder("log_result(");
707
      boolean first = true;
708
 
709
      sb.append(")");
710
      return sb.toString();
711
    }
712
 
713
    public void validate() throws TException {
714
      // check for required fields
715
    }
716
 
717
  }
718
 
719
}