]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | /* |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, | |
13 | * software distributed under the License is distributed on an | |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
15 | * KIND, either express or implied. See the License for the | |
16 | * specific language governing permissions and limitations | |
17 | * under the License. | |
18 | */ | |
19 | ||
20 | package org.apache.thrift.protocol; | |
21 | ||
22 | import org.apache.thrift.TException; | |
23 | ||
24 | import java.nio.ByteBuffer; | |
25 | ||
26 | /** | |
27 | * <code>TProtocolDecorator</code> forwards all requests to an enclosed | |
28 | * <code>TProtocol</code> instance, providing a way to author concise | |
29 | * concrete decorator subclasses. While it has no abstract methods, it | |
30 | * is marked abstract as a reminder that by itself, it does not modify | |
31 | * the behaviour of the enclosed <code>TProtocol</code>. | |
32 | * | |
33 | * <p>See p.175 of Design Patterns (by Gamma et al.)</p> | |
34 | * | |
35 | * @see org.apache.thrift.protocol.TMultiplexedProtocol | |
36 | */ | |
37 | public abstract class TProtocolDecorator extends TProtocol { | |
38 | ||
39 | private final TProtocol concreteProtocol; | |
40 | ||
41 | /** | |
42 | * Encloses the specified protocol. | |
43 | * @param protocol All operations will be forward to this protocol. Must be non-null. | |
44 | */ | |
45 | public TProtocolDecorator(TProtocol protocol) { | |
46 | super(protocol.getTransport()); | |
47 | concreteProtocol = protocol; | |
48 | } | |
49 | ||
50 | public void writeMessageBegin(TMessage tMessage) throws TException { | |
51 | concreteProtocol.writeMessageBegin(tMessage); | |
52 | } | |
53 | ||
54 | public void writeMessageEnd() throws TException { | |
55 | concreteProtocol.writeMessageEnd(); | |
56 | } | |
57 | ||
58 | public void writeStructBegin(TStruct tStruct) throws TException { | |
59 | concreteProtocol.writeStructBegin(tStruct); | |
60 | } | |
61 | ||
62 | public void writeStructEnd() throws TException { | |
63 | concreteProtocol.writeStructEnd(); | |
64 | } | |
65 | ||
66 | public void writeFieldBegin(TField tField) throws TException { | |
67 | concreteProtocol.writeFieldBegin(tField); | |
68 | } | |
69 | ||
70 | public void writeFieldEnd() throws TException { | |
71 | concreteProtocol.writeFieldEnd(); | |
72 | } | |
73 | ||
74 | public void writeFieldStop() throws TException { | |
75 | concreteProtocol.writeFieldStop(); | |
76 | } | |
77 | ||
78 | public void writeMapBegin(TMap tMap) throws TException { | |
79 | concreteProtocol.writeMapBegin(tMap); | |
80 | } | |
81 | ||
82 | public void writeMapEnd() throws TException { | |
83 | concreteProtocol.writeMapEnd(); | |
84 | } | |
85 | ||
86 | public void writeListBegin(TList tList) throws TException { | |
87 | concreteProtocol.writeListBegin(tList); | |
88 | } | |
89 | ||
90 | public void writeListEnd() throws TException { | |
91 | concreteProtocol.writeListEnd(); | |
92 | } | |
93 | ||
94 | public void writeSetBegin(TSet tSet) throws TException { | |
95 | concreteProtocol.writeSetBegin(tSet); | |
96 | } | |
97 | ||
98 | public void writeSetEnd() throws TException { | |
99 | concreteProtocol.writeSetEnd(); | |
100 | } | |
101 | ||
102 | public void writeBool(boolean b) throws TException { | |
103 | concreteProtocol.writeBool(b); | |
104 | } | |
105 | ||
106 | public void writeByte(byte b) throws TException { | |
107 | concreteProtocol.writeByte(b); | |
108 | } | |
109 | ||
110 | public void writeI16(short i) throws TException { | |
111 | concreteProtocol.writeI16(i); | |
112 | } | |
113 | ||
114 | public void writeI32(int i) throws TException { | |
115 | concreteProtocol.writeI32(i); | |
116 | } | |
117 | ||
118 | public void writeI64(long l) throws TException { | |
119 | concreteProtocol.writeI64(l); | |
120 | } | |
121 | ||
122 | public void writeDouble(double v) throws TException { | |
123 | concreteProtocol.writeDouble(v); | |
124 | } | |
125 | ||
126 | public void writeString(String s) throws TException { | |
127 | concreteProtocol.writeString(s); | |
128 | } | |
129 | ||
130 | public void writeBinary(ByteBuffer buf) throws TException { | |
131 | concreteProtocol.writeBinary(buf); | |
132 | } | |
133 | ||
134 | public TMessage readMessageBegin() throws TException { | |
135 | return concreteProtocol.readMessageBegin(); | |
136 | } | |
137 | ||
138 | public void readMessageEnd() throws TException { | |
139 | concreteProtocol.readMessageEnd(); | |
140 | } | |
141 | ||
142 | public TStruct readStructBegin() throws TException { | |
143 | return concreteProtocol.readStructBegin(); | |
144 | } | |
145 | ||
146 | public void readStructEnd() throws TException { | |
147 | concreteProtocol.readStructEnd(); | |
148 | } | |
149 | ||
150 | public TField readFieldBegin() throws TException { | |
151 | return concreteProtocol.readFieldBegin(); | |
152 | } | |
153 | ||
154 | public void readFieldEnd() throws TException { | |
155 | concreteProtocol.readFieldEnd(); | |
156 | } | |
157 | ||
158 | public TMap readMapBegin() throws TException { | |
159 | return concreteProtocol.readMapBegin(); | |
160 | } | |
161 | ||
162 | public void readMapEnd() throws TException { | |
163 | concreteProtocol.readMapEnd(); | |
164 | } | |
165 | ||
166 | public TList readListBegin() throws TException { | |
167 | return concreteProtocol.readListBegin(); | |
168 | } | |
169 | ||
170 | public void readListEnd() throws TException { | |
171 | concreteProtocol.readListEnd(); | |
172 | } | |
173 | ||
174 | public TSet readSetBegin() throws TException { | |
175 | return concreteProtocol.readSetBegin(); | |
176 | } | |
177 | ||
178 | public void readSetEnd() throws TException { | |
179 | concreteProtocol.readSetEnd(); | |
180 | } | |
181 | ||
182 | public boolean readBool() throws TException { | |
183 | return concreteProtocol.readBool(); | |
184 | } | |
185 | ||
186 | public byte readByte() throws TException { | |
187 | return concreteProtocol.readByte(); | |
188 | } | |
189 | ||
190 | public short readI16() throws TException { | |
191 | return concreteProtocol.readI16(); | |
192 | } | |
193 | ||
194 | public int readI32() throws TException { | |
195 | return concreteProtocol.readI32(); | |
196 | } | |
197 | ||
198 | public long readI64() throws TException { | |
199 | return concreteProtocol.readI64(); | |
200 | } | |
201 | ||
202 | public double readDouble() throws TException { | |
203 | return concreteProtocol.readDouble(); | |
204 | } | |
205 | ||
206 | public String readString() throws TException { | |
207 | return concreteProtocol.readString(); | |
208 | } | |
209 | ||
210 | public ByteBuffer readBinary() throws TException { | |
211 | return concreteProtocol.readBinary(); | |
212 | } | |
213 | } |