Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 1 | package com.facebook.thrift.protocol; |
2 | |||||
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 3 | import com.facebook.thrift.TException; |
4 | import com.facebook.thrift.transport.TTransport; | ||||
5 | |||||
6 | /** | ||||
7 | * Protocol interface definition. | ||||
8 | * | ||||
9 | * @author Mark Slee <mcslee@facebook.com> | ||||
10 | */ | ||||
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 11 | public abstract class TProtocol { |
12 | |||||
13 | /** | ||||
14 | * Prevent direct instantiation | ||||
15 | */ | ||||
16 | private TProtocol() {} | ||||
17 | |||||
18 | /** | ||||
Aditya Agarwal | 5a42958 | 2007-02-06 02:51:15 +0000 | [diff] [blame^] | 19 | * Transport |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 20 | */ |
Aditya Agarwal | 5a42958 | 2007-02-06 02:51:15 +0000 | [diff] [blame^] | 21 | protected TTransport trans_; |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 22 | |
23 | /** | ||||
24 | * Constructor | ||||
25 | */ | ||||
Aditya Agarwal | 5a42958 | 2007-02-06 02:51:15 +0000 | [diff] [blame^] | 26 | protected TProtocol(TTransport trans) { |
27 | trans_ = trans; | ||||
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 28 | } |
29 | |||||
30 | /** | ||||
Aditya Agarwal | 5a42958 | 2007-02-06 02:51:15 +0000 | [diff] [blame^] | 31 | * Transport accessor |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 32 | */ |
Aditya Agarwal | 5a42958 | 2007-02-06 02:51:15 +0000 | [diff] [blame^] | 33 | public TTransport getTransport() { |
34 | return trans_; | ||||
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 35 | } |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 36 | |
37 | /** | ||||
38 | * Writing methods. | ||||
39 | */ | ||||
40 | |||||
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 41 | public abstract void writeMessageBegin(TMessage message) throws TException; |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 42 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 43 | public abstract void writeMessageEnd() throws TException; |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 44 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 45 | public abstract void writeStructBegin(TStruct struct) throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 46 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 47 | public abstract void writeStructEnd() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 48 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 49 | public abstract void writeFieldBegin(TField field) throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 50 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 51 | public abstract void writeFieldEnd() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 52 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 53 | public abstract void writeFieldStop() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 54 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 55 | public abstract void writeMapBegin(TMap map) throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 56 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 57 | public abstract void writeMapEnd() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 58 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 59 | public abstract void writeListBegin(TList list) throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 60 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 61 | public abstract void writeListEnd() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 62 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 63 | public abstract void writeSetBegin(TSet set) throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 64 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 65 | public abstract void writeSetEnd() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 66 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 67 | public abstract void writeBool(boolean b) throws TException; |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 68 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 69 | public abstract void writeByte(byte b) throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 70 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 71 | public abstract void writeI16(short i16) throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 72 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 73 | public abstract void writeI32(int i32) throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 74 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 75 | public abstract void writeI64(long i64) throws TException; |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 76 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 77 | public abstract void writeDouble(double dub) throws TException; |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 78 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 79 | public abstract void writeString(String str) throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 80 | |
81 | /** | ||||
82 | * Reading methods. | ||||
83 | */ | ||||
84 | |||||
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 85 | public abstract TMessage readMessageBegin() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 86 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 87 | public abstract void readMessageEnd() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 88 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 89 | public abstract TStruct readStructBegin() throws TException; |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 90 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 91 | public abstract void readStructEnd() throws TException; |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 92 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 93 | public abstract TField readFieldBegin() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 94 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 95 | public abstract void readFieldEnd() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 96 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 97 | public abstract TMap readMapBegin() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 98 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 99 | public abstract void readMapEnd() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 100 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 101 | public abstract TList readListBegin() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 102 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 103 | public abstract void readListEnd() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 104 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 105 | public abstract TSet readSetBegin() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 106 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 107 | public abstract void readSetEnd() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 108 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 109 | public abstract boolean readBool() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 110 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 111 | public abstract byte readByte() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 112 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 113 | public abstract short readI16() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 114 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 115 | public abstract int readI32() throws TException; |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 116 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 117 | public abstract long readI64() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 118 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 119 | public abstract double readDouble() throws TException; |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 120 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 121 | public abstract String readString() throws TException; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 122 | |
123 | } |