1 /// Licensed to the Apache Software Foundation (ASF) under one
2 /// or more contributor license agreements. See the NOTICE file
3 /// distributed with this work for additional information
4 /// regarding copyright ownership. The ASF licenses this file
5 /// to you under the Apache License, Version 2.0 (the
6 /// "License"); you may not use this file except in compliance
7 /// with the License. You may obtain a copy of the License at
9 /// http://www.apache.org/licenses/LICENSE-2.0
11 /// Unless required by applicable law or agreed to in writing,
12 /// software distributed under the License is distributed on an
13 /// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 /// KIND, either express or implied. See the License for the
15 /// specific language governing permissions and limitations
16 /// under the License.
20 /// Forward all operations to the wrapped protocol. Used as a base class.
22 /// Adapted from the C# version.
23 class TProtocolDecorator extends TProtocol {
24 final TProtocol _protocol;
26 TProtocolDecorator(TProtocol protocol)
27 : _protocol = protocol,
28 super(protocol.transport);
32 void writeMessageBegin(TMessage message) {
33 _protocol.writeMessageBegin(message);
36 void writeMessageEnd() {
37 _protocol.writeMessageEnd();
40 void writeStructBegin(TStruct struct) {
41 _protocol.writeStructBegin(struct);
44 void writeStructEnd() {
45 _protocol.writeStructEnd();
48 void writeFieldBegin(TField field) {
49 _protocol.writeFieldBegin(field);
52 void writeFieldEnd() {
53 _protocol.writeFieldEnd();
56 void writeFieldStop() {
57 _protocol.writeFieldStop();
60 void writeMapBegin(TMap map) {
61 _protocol.writeMapBegin(map);
65 _protocol.writeMapEnd();
68 void writeListBegin(TList list) {
69 _protocol.writeListBegin(list);
73 _protocol.writeListEnd();
76 void writeSetBegin(TSet set) {
77 _protocol.writeSetBegin(set);
81 _protocol.writeSetEnd();
84 void writeBool(bool b) {
85 _protocol.writeBool(b);
88 void writeByte(int b) {
89 _protocol.writeByte(b);
92 void writeI16(int i16) {
93 _protocol.writeI16(i16);
96 void writeI32(int i32) {
97 _protocol.writeI32(i32);
100 void writeI64(int i64) {
101 _protocol.writeI64(i64);
104 void writeDouble(double d) {
105 _protocol.writeDouble(d);
108 void writeString(String str) {
109 _protocol.writeString(str);
112 void writeBinary(Uint8List bytes) {
113 _protocol.writeBinary(bytes);
117 TMessage readMessageBegin() => _protocol.readMessageBegin();
118 void readMessageEnd() => _protocol.readMessageEnd();
120 TStruct readStructBegin() => _protocol.readStructBegin();
121 void readStructEnd() => _protocol.readStructEnd();
123 TField readFieldBegin() => _protocol.readFieldBegin();
124 void readFieldEnd() => _protocol.readFieldEnd();
126 TMap readMapBegin() => _protocol.readMapBegin();
127 void readMapEnd() => _protocol.readMapEnd();
129 TList readListBegin() => _protocol.readListBegin();
130 void readListEnd() => _protocol.readListEnd();
132 TSet readSetBegin() => _protocol.readSetBegin();
133 void readSetEnd() => _protocol.readSetEnd();
135 bool readBool() => _protocol.readBool();
137 int readByte() => _protocol.readByte();
139 int readI16() => _protocol.readI16();
141 int readI32() => _protocol.readI32();
143 int readI64() => _protocol.readI64();
145 double readDouble() => _protocol.readDouble();
147 String readString() => _protocol.readString();
149 Uint8List readBinary() => _protocol.readBinary();