blob: 23829cf7bc10bd77024cbe4eaf5c106cbbfc9bd9 [file] [log] [blame]
Mark Slee7eb0d632007-03-01 00:00:27 +00001// Copyright (c) 2006- Facebook
2// Distributed under the Thrift Software License
3//
4// See accompanying file LICENSE or visit the Thrift site at:
5// http://developers.facebook.com/thrift/
6
Mark Slee83c52a82006-06-07 06:51:18 +00007package com.facebook.thrift.protocol;
8
Mark Slee83c52a82006-06-07 06:51:18 +00009import com.facebook.thrift.TException;
10import com.facebook.thrift.transport.TTransport;
11
12/**
13 * Protocol interface definition.
14 *
15 * @author Mark Slee <mcslee@facebook.com>
16 */
Mark Slee456b7a82006-10-25 20:53:37 +000017public abstract class TProtocol {
18
19 /**
20 * Prevent direct instantiation
21 */
22 private TProtocol() {}
23
24 /**
Aditya Agarwal5a429582007-02-06 02:51:15 +000025 * Transport
Mark Slee456b7a82006-10-25 20:53:37 +000026 */
Aditya Agarwal5a429582007-02-06 02:51:15 +000027 protected TTransport trans_;
Mark Slee456b7a82006-10-25 20:53:37 +000028
29 /**
30 * Constructor
31 */
Aditya Agarwal5a429582007-02-06 02:51:15 +000032 protected TProtocol(TTransport trans) {
33 trans_ = trans;
Mark Slee456b7a82006-10-25 20:53:37 +000034 }
35
36 /**
Aditya Agarwal5a429582007-02-06 02:51:15 +000037 * Transport accessor
Mark Slee456b7a82006-10-25 20:53:37 +000038 */
Aditya Agarwal5a429582007-02-06 02:51:15 +000039 public TTransport getTransport() {
40 return trans_;
Mark Slee456b7a82006-10-25 20:53:37 +000041 }
Mark Slee83c52a82006-06-07 06:51:18 +000042
43 /**
44 * Writing methods.
45 */
46
Mark Slee456b7a82006-10-25 20:53:37 +000047 public abstract void writeMessageBegin(TMessage message) throws TException;
Mark Slee78f58e22006-09-02 04:17:07 +000048
Mark Slee456b7a82006-10-25 20:53:37 +000049 public abstract void writeMessageEnd() throws TException;
Mark Slee78f58e22006-09-02 04:17:07 +000050
Mark Slee456b7a82006-10-25 20:53:37 +000051 public abstract void writeStructBegin(TStruct struct) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000052
Mark Slee456b7a82006-10-25 20:53:37 +000053 public abstract void writeStructEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000054
Mark Slee456b7a82006-10-25 20:53:37 +000055 public abstract void writeFieldBegin(TField field) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000056
Mark Slee456b7a82006-10-25 20:53:37 +000057 public abstract void writeFieldEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000058
Mark Slee456b7a82006-10-25 20:53:37 +000059 public abstract void writeFieldStop() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000060
Mark Slee456b7a82006-10-25 20:53:37 +000061 public abstract void writeMapBegin(TMap map) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000062
Mark Slee456b7a82006-10-25 20:53:37 +000063 public abstract void writeMapEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000064
Mark Slee456b7a82006-10-25 20:53:37 +000065 public abstract void writeListBegin(TList list) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000066
Mark Slee456b7a82006-10-25 20:53:37 +000067 public abstract void writeListEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000068
Mark Slee456b7a82006-10-25 20:53:37 +000069 public abstract void writeSetBegin(TSet set) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000070
Mark Slee456b7a82006-10-25 20:53:37 +000071 public abstract void writeSetEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000072
Mark Slee456b7a82006-10-25 20:53:37 +000073 public abstract void writeBool(boolean b) throws TException;
Mark Slee78f58e22006-09-02 04:17:07 +000074
Mark Slee456b7a82006-10-25 20:53:37 +000075 public abstract void writeByte(byte b) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000076
Mark Slee456b7a82006-10-25 20:53:37 +000077 public abstract void writeI16(short i16) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000078
Mark Slee456b7a82006-10-25 20:53:37 +000079 public abstract void writeI32(int i32) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000080
Mark Slee456b7a82006-10-25 20:53:37 +000081 public abstract void writeI64(long i64) throws TException;
Mark Slee530fd662006-08-09 00:05:18 +000082
Mark Slee456b7a82006-10-25 20:53:37 +000083 public abstract void writeDouble(double dub) throws TException;
Mark Sleec98d0502006-09-06 02:42:25 +000084
Mark Slee456b7a82006-10-25 20:53:37 +000085 public abstract void writeString(String str) throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000086
87 /**
88 * Reading methods.
89 */
90
Mark Slee456b7a82006-10-25 20:53:37 +000091 public abstract TMessage readMessageBegin() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000092
Mark Slee456b7a82006-10-25 20:53:37 +000093 public abstract void readMessageEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +000094
Mark Slee456b7a82006-10-25 20:53:37 +000095 public abstract TStruct readStructBegin() throws TException;
Mark Slee78f58e22006-09-02 04:17:07 +000096
Mark Slee456b7a82006-10-25 20:53:37 +000097 public abstract void readStructEnd() throws TException;
Mark Slee78f58e22006-09-02 04:17:07 +000098
Mark Slee456b7a82006-10-25 20:53:37 +000099 public abstract TField readFieldBegin() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000100
Mark Slee456b7a82006-10-25 20:53:37 +0000101 public abstract void readFieldEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000102
Mark Slee456b7a82006-10-25 20:53:37 +0000103 public abstract TMap readMapBegin() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000104
Mark Slee456b7a82006-10-25 20:53:37 +0000105 public abstract void readMapEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000106
Mark Slee456b7a82006-10-25 20:53:37 +0000107 public abstract TList readListBegin() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000108
Mark Slee456b7a82006-10-25 20:53:37 +0000109 public abstract void readListEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000110
Mark Slee456b7a82006-10-25 20:53:37 +0000111 public abstract TSet readSetBegin() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000112
Mark Slee456b7a82006-10-25 20:53:37 +0000113 public abstract void readSetEnd() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000114
Mark Slee456b7a82006-10-25 20:53:37 +0000115 public abstract boolean readBool() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000116
Mark Slee456b7a82006-10-25 20:53:37 +0000117 public abstract byte readByte() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000118
Mark Slee456b7a82006-10-25 20:53:37 +0000119 public abstract short readI16() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000120
Mark Slee456b7a82006-10-25 20:53:37 +0000121 public abstract int readI32() throws TException;
Mark Slee78f58e22006-09-02 04:17:07 +0000122
Mark Slee456b7a82006-10-25 20:53:37 +0000123 public abstract long readI64() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000124
Mark Slee456b7a82006-10-25 20:53:37 +0000125 public abstract double readDouble() throws TException;
Mark Sleec98d0502006-09-06 02:42:25 +0000126
Mark Slee456b7a82006-10-25 20:53:37 +0000127 public abstract String readString() throws TException;
Mark Slee83c52a82006-06-07 06:51:18 +0000128
129}