]>
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 java.nio.ByteBuffer; | |
23 | ||
24 | import org.apache.thrift.TException; | |
25 | import org.apache.thrift.scheme.IScheme; | |
26 | import org.apache.thrift.scheme.StandardScheme; | |
27 | import org.apache.thrift.transport.TTransport; | |
28 | ||
29 | /** | |
30 | * Protocol interface definition. | |
31 | * | |
32 | */ | |
33 | public abstract class TProtocol { | |
34 | ||
35 | /** | |
36 | * Prevent direct instantiation | |
37 | */ | |
38 | @SuppressWarnings("unused") | |
39 | private TProtocol() {} | |
40 | ||
41 | /** | |
42 | * Transport | |
43 | */ | |
44 | protected TTransport trans_; | |
45 | ||
46 | /** | |
47 | * Constructor | |
48 | */ | |
49 | protected TProtocol(TTransport trans) { | |
50 | trans_ = trans; | |
51 | } | |
52 | ||
53 | /** | |
54 | * Transport accessor | |
55 | */ | |
56 | public TTransport getTransport() { | |
57 | return trans_; | |
58 | } | |
59 | ||
60 | /** | |
61 | * Writing methods. | |
62 | */ | |
63 | ||
64 | public abstract void writeMessageBegin(TMessage message) throws TException; | |
65 | ||
66 | public abstract void writeMessageEnd() throws TException; | |
67 | ||
68 | public abstract void writeStructBegin(TStruct struct) throws TException; | |
69 | ||
70 | public abstract void writeStructEnd() throws TException; | |
71 | ||
72 | public abstract void writeFieldBegin(TField field) throws TException; | |
73 | ||
74 | public abstract void writeFieldEnd() throws TException; | |
75 | ||
76 | public abstract void writeFieldStop() throws TException; | |
77 | ||
78 | public abstract void writeMapBegin(TMap map) throws TException; | |
79 | ||
80 | public abstract void writeMapEnd() throws TException; | |
81 | ||
82 | public abstract void writeListBegin(TList list) throws TException; | |
83 | ||
84 | public abstract void writeListEnd() throws TException; | |
85 | ||
86 | public abstract void writeSetBegin(TSet set) throws TException; | |
87 | ||
88 | public abstract void writeSetEnd() throws TException; | |
89 | ||
90 | public abstract void writeBool(boolean b) throws TException; | |
91 | ||
92 | public abstract void writeByte(byte b) throws TException; | |
93 | ||
94 | public abstract void writeI16(short i16) throws TException; | |
95 | ||
96 | public abstract void writeI32(int i32) throws TException; | |
97 | ||
98 | public abstract void writeI64(long i64) throws TException; | |
99 | ||
100 | public abstract void writeDouble(double dub) throws TException; | |
101 | ||
102 | public abstract void writeString(String str) throws TException; | |
103 | ||
104 | public abstract void writeBinary(ByteBuffer buf) throws TException; | |
105 | ||
106 | /** | |
107 | * Reading methods. | |
108 | */ | |
109 | ||
110 | public abstract TMessage readMessageBegin() throws TException; | |
111 | ||
112 | public abstract void readMessageEnd() throws TException; | |
113 | ||
114 | public abstract TStruct readStructBegin() throws TException; | |
115 | ||
116 | public abstract void readStructEnd() throws TException; | |
117 | ||
118 | public abstract TField readFieldBegin() throws TException; | |
119 | ||
120 | public abstract void readFieldEnd() throws TException; | |
121 | ||
122 | public abstract TMap readMapBegin() throws TException; | |
123 | ||
124 | public abstract void readMapEnd() throws TException; | |
125 | ||
126 | public abstract TList readListBegin() throws TException; | |
127 | ||
128 | public abstract void readListEnd() throws TException; | |
129 | ||
130 | public abstract TSet readSetBegin() throws TException; | |
131 | ||
132 | public abstract void readSetEnd() throws TException; | |
133 | ||
134 | public abstract boolean readBool() throws TException; | |
135 | ||
136 | public abstract byte readByte() throws TException; | |
137 | ||
138 | public abstract short readI16() throws TException; | |
139 | ||
140 | public abstract int readI32() throws TException; | |
141 | ||
142 | public abstract long readI64() throws TException; | |
143 | ||
144 | public abstract double readDouble() throws TException; | |
145 | ||
146 | public abstract String readString() throws TException; | |
147 | ||
148 | public abstract ByteBuffer readBinary() throws TException; | |
149 | ||
150 | /** | |
151 | * Reset any internal state back to a blank slate. This method only needs to | |
152 | * be implemented for stateful protocols. | |
153 | */ | |
154 | public void reset() {} | |
155 | ||
156 | /** | |
157 | * Scheme accessor | |
158 | */ | |
159 | public Class<? extends IScheme> getScheme() { | |
160 | return StandardScheme.class; | |
161 | } | |
162 | } |