blob: 502f4738d2e7ee5346a043748e77af924d041d36 [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 /**
Aditya Agarwal5a429582007-02-06 02:51:15 +000019 * Transport
Mark Slee456b7a82006-10-25 20:53:37 +000020 */
Aditya Agarwal5a429582007-02-06 02:51:15 +000021 protected TTransport trans_;
Mark Slee456b7a82006-10-25 20:53:37 +000022
23 /**
24 * Constructor
25 */
Aditya Agarwal5a429582007-02-06 02:51:15 +000026 protected TProtocol(TTransport trans) {
27 trans_ = trans;
Mark Slee456b7a82006-10-25 20:53:37 +000028 }
29
30 /**
Aditya Agarwal5a429582007-02-06 02:51:15 +000031 * Transport accessor
Mark Slee456b7a82006-10-25 20:53:37 +000032 */
Aditya Agarwal5a429582007-02-06 02:51:15 +000033 public TTransport getTransport() {
34 return trans_;
Mark Slee456b7a82006-10-25 20:53:37 +000035 }
Mark Slee83c52a82006-06-07 06:51:18 +000036
37 /**
38 * Writing methods.
39 */
40
Mark Slee456b7a82006-10-25 20:53:37 +000041 public abstract void writeMessageBegin(TMessage message) throws TException;
Mark Slee78f58e22006-09-02 04:17:07 +000042
Mark Slee456b7a82006-10-25 20:53:37 +000043 public abstract void writeMessageEnd() throws TException;
Mark Slee78f58e22006-09-02 04:17:07 +000044
Mark Slee456b7a82006-10-25 20:53:37 +000045 public abstract void writeStructBegin(TStruct struct) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000046
Mark Slee456b7a82006-10-25 20:53:37 +000047 public abstract void writeStructEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000048
Mark Slee456b7a82006-10-25 20:53:37 +000049 public abstract void writeFieldBegin(TField field) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000050
Mark Slee456b7a82006-10-25 20:53:37 +000051 public abstract void writeFieldEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000052
Mark Slee456b7a82006-10-25 20:53:37 +000053 public abstract void writeFieldStop() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000054
Mark Slee456b7a82006-10-25 20:53:37 +000055 public abstract void writeMapBegin(TMap map) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000056
Mark Slee456b7a82006-10-25 20:53:37 +000057 public abstract void writeMapEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000058
Mark Slee456b7a82006-10-25 20:53:37 +000059 public abstract void writeListBegin(TList list) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000060
Mark Slee456b7a82006-10-25 20:53:37 +000061 public abstract void writeListEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000062
Mark Slee456b7a82006-10-25 20:53:37 +000063 public abstract void writeSetBegin(TSet set) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000064
Mark Slee456b7a82006-10-25 20:53:37 +000065 public abstract void writeSetEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000066
Mark Slee456b7a82006-10-25 20:53:37 +000067 public abstract void writeBool(boolean b) throws TException;
Mark Slee78f58e22006-09-02 04:17:07 +000068
Mark Slee456b7a82006-10-25 20:53:37 +000069 public abstract void writeByte(byte b) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000070
Mark Slee456b7a82006-10-25 20:53:37 +000071 public abstract void writeI16(short i16) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000072
Mark Slee456b7a82006-10-25 20:53:37 +000073 public abstract void writeI32(int i32) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000074
Mark Slee456b7a82006-10-25 20:53:37 +000075 public abstract void writeI64(long i64) throws TException;
Mark Slee530fd662006-08-09 00:05:18 +000076
Mark Slee456b7a82006-10-25 20:53:37 +000077 public abstract void writeDouble(double dub) throws TException;
Mark Sleec98d0502006-09-06 02:42:25 +000078
Mark Slee456b7a82006-10-25 20:53:37 +000079 public abstract void writeString(String str) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000080
81 /**
82 * Reading methods.
83 */
84
Mark Slee456b7a82006-10-25 20:53:37 +000085 public abstract TMessage readMessageBegin() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000086
Mark Slee456b7a82006-10-25 20:53:37 +000087 public abstract void readMessageEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000088
Mark Slee456b7a82006-10-25 20:53:37 +000089 public abstract TStruct readStructBegin() throws TException;
Mark Slee78f58e22006-09-02 04:17:07 +000090
Mark Slee456b7a82006-10-25 20:53:37 +000091 public abstract void readStructEnd() throws TException;
Mark Slee78f58e22006-09-02 04:17:07 +000092
Mark Slee456b7a82006-10-25 20:53:37 +000093 public abstract TField readFieldBegin() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000094
Mark Slee456b7a82006-10-25 20:53:37 +000095 public abstract void readFieldEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000096
Mark Slee456b7a82006-10-25 20:53:37 +000097 public abstract TMap readMapBegin() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000098
Mark Slee456b7a82006-10-25 20:53:37 +000099 public abstract void readMapEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000100
Mark Slee456b7a82006-10-25 20:53:37 +0000101 public abstract TList readListBegin() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000102
Mark Slee456b7a82006-10-25 20:53:37 +0000103 public abstract void readListEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000104
Mark Slee456b7a82006-10-25 20:53:37 +0000105 public abstract TSet readSetBegin() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000106
Mark Slee456b7a82006-10-25 20:53:37 +0000107 public abstract void readSetEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000108
Mark Slee456b7a82006-10-25 20:53:37 +0000109 public abstract boolean readBool() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000110
Mark Slee456b7a82006-10-25 20:53:37 +0000111 public abstract byte readByte() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000112
Mark Slee456b7a82006-10-25 20:53:37 +0000113 public abstract short readI16() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000114
Mark Slee456b7a82006-10-25 20:53:37 +0000115 public abstract int readI32() throws TException;
Mark Slee78f58e22006-09-02 04:17:07 +0000116
Mark Slee456b7a82006-10-25 20:53:37 +0000117 public abstract long readI64() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000118
Mark Slee456b7a82006-10-25 20:53:37 +0000119 public abstract double readDouble() throws TException;
Mark Sleec98d0502006-09-06 02:42:25 +0000120
Mark Slee456b7a82006-10-25 20:53:37 +0000121 public abstract String readString() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000122
123}