blob: 43b4f07740aaf364426487197a6c12574331542b [file] [log] [blame]
Mark Slee83c52a82006-06-07 06:51:18 +00001package com.facebook.thrift.protocol;
2
Mark Slee83c52a82006-06-07 06:51:18 +00003import com.facebook.thrift.TException;
4import com.facebook.thrift.transport.TTransport;
5
6/**
7 * Protocol interface definition.
8 *
9 * @author Mark Slee <mcslee@facebook.com>
10 */
Mark Slee456b7a82006-10-25 20:53:37 +000011public abstract class TProtocol {
12
13 /**
14 * Prevent direct instantiation
15 */
16 private TProtocol() {}
17
18 /**
19 * Input transport
20 */
21 protected TTransport inputTransport_;
22
23 /**
24 * Output transport
25 */
26 protected TTransport outputTransport_;
27
28 /**
29 * Constructor
30 */
31 protected TProtocol(TTransport in, TTransport out) {
32 inputTransport_ = in;
33 outputTransport_ = out;
34 }
35
36 /**
37 * Input accessor
38 */
39 public TTransport getInputTransport() {
40 return inputTransport_;
41 }
42
43 /**
44 * Output accessor
45 */
46 public TTransport getOutputTransport() {
47 return outputTransport_;
48 }
Mark Slee83c52a82006-06-07 06:51:18 +000049
50 /**
51 * Writing methods.
52 */
53
Mark Slee456b7a82006-10-25 20:53:37 +000054 public abstract void writeMessageBegin(TMessage message) throws TException;
Mark Slee78f58e22006-09-02 04:17:07 +000055
Mark Slee456b7a82006-10-25 20:53:37 +000056 public abstract void writeMessageEnd() throws TException;
Mark Slee78f58e22006-09-02 04:17:07 +000057
Mark Slee456b7a82006-10-25 20:53:37 +000058 public abstract void writeStructBegin(TStruct struct) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000059
Mark Slee456b7a82006-10-25 20:53:37 +000060 public abstract void writeStructEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000061
Mark Slee456b7a82006-10-25 20:53:37 +000062 public abstract void writeFieldBegin(TField field) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000063
Mark Slee456b7a82006-10-25 20:53:37 +000064 public abstract void writeFieldEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000065
Mark Slee456b7a82006-10-25 20:53:37 +000066 public abstract void writeFieldStop() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000067
Mark Slee456b7a82006-10-25 20:53:37 +000068 public abstract void writeMapBegin(TMap map) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000069
Mark Slee456b7a82006-10-25 20:53:37 +000070 public abstract void writeMapEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000071
Mark Slee456b7a82006-10-25 20:53:37 +000072 public abstract void writeListBegin(TList list) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000073
Mark Slee456b7a82006-10-25 20:53:37 +000074 public abstract void writeListEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000075
Mark Slee456b7a82006-10-25 20:53:37 +000076 public abstract void writeSetBegin(TSet set) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000077
Mark Slee456b7a82006-10-25 20:53:37 +000078 public abstract void writeSetEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000079
Mark Slee456b7a82006-10-25 20:53:37 +000080 public abstract void writeBool(boolean b) throws TException;
Mark Slee78f58e22006-09-02 04:17:07 +000081
Mark Slee456b7a82006-10-25 20:53:37 +000082 public abstract void writeByte(byte b) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000083
Mark Slee456b7a82006-10-25 20:53:37 +000084 public abstract void writeI16(short i16) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000085
Mark Slee456b7a82006-10-25 20:53:37 +000086 public abstract void writeI32(int i32) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000087
Mark Slee456b7a82006-10-25 20:53:37 +000088 public abstract void writeI64(long i64) throws TException;
Mark Slee530fd662006-08-09 00:05:18 +000089
Mark Slee456b7a82006-10-25 20:53:37 +000090 public abstract void writeDouble(double dub) throws TException;
Mark Sleec98d0502006-09-06 02:42:25 +000091
Mark Slee456b7a82006-10-25 20:53:37 +000092 public abstract void writeString(String str) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000093
94 /**
95 * Reading methods.
96 */
97
Mark Slee456b7a82006-10-25 20:53:37 +000098 public abstract TMessage readMessageBegin() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000099
Mark Slee456b7a82006-10-25 20:53:37 +0000100 public abstract void readMessageEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000101
Mark Slee456b7a82006-10-25 20:53:37 +0000102 public abstract TStruct readStructBegin() throws TException;
Mark Slee78f58e22006-09-02 04:17:07 +0000103
Mark Slee456b7a82006-10-25 20:53:37 +0000104 public abstract void readStructEnd() throws TException;
Mark Slee78f58e22006-09-02 04:17:07 +0000105
Mark Slee456b7a82006-10-25 20:53:37 +0000106 public abstract TField readFieldBegin() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000107
Mark Slee456b7a82006-10-25 20:53:37 +0000108 public abstract void readFieldEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000109
Mark Slee456b7a82006-10-25 20:53:37 +0000110 public abstract TMap readMapBegin() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000111
Mark Slee456b7a82006-10-25 20:53:37 +0000112 public abstract void readMapEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000113
Mark Slee456b7a82006-10-25 20:53:37 +0000114 public abstract TList readListBegin() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000115
Mark Slee456b7a82006-10-25 20:53:37 +0000116 public abstract void readListEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000117
Mark Slee456b7a82006-10-25 20:53:37 +0000118 public abstract TSet readSetBegin() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000119
Mark Slee456b7a82006-10-25 20:53:37 +0000120 public abstract void readSetEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000121
Mark Slee456b7a82006-10-25 20:53:37 +0000122 public abstract boolean readBool() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000123
Mark Slee456b7a82006-10-25 20:53:37 +0000124 public abstract byte readByte() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000125
Mark Slee456b7a82006-10-25 20:53:37 +0000126 public abstract short readI16() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000127
Mark Slee456b7a82006-10-25 20:53:37 +0000128 public abstract int readI32() throws TException;
Mark Slee78f58e22006-09-02 04:17:07 +0000129
Mark Slee456b7a82006-10-25 20:53:37 +0000130 public abstract long readI64() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000131
Mark Slee456b7a82006-10-25 20:53:37 +0000132 public abstract double readDouble() throws TException;
Mark Sleec98d0502006-09-06 02:42:25 +0000133
Mark Slee456b7a82006-10-25 20:53:37 +0000134 public abstract String readString() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000135
136}