Mark Slee | 7eb0d63 | 2007-03-01 00:00:27 +0000 | [diff] [blame] | 1 | // 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 Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 7 | package com.facebook.thrift.protocol; |
| 8 | |
| 9 | import com.facebook.thrift.TException; |
| 10 | import com.facebook.thrift.transport.TTransport; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 11 | |
| 12 | /** |
| 13 | * Binary protocol implementation for thrift. |
| 14 | * |
| 15 | * @author Mark Slee <mcslee@facebook.com> |
| 16 | */ |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 17 | public class TBinaryProtocol extends TProtocol { |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 18 | |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 19 | protected static final int VERSION_MASK = 0xffff0000; |
| 20 | protected static final int VERSION_1 = 0x80010000; |
| 21 | |
| 22 | protected boolean strictRead_ = false; |
| 23 | protected boolean strictWrite_ = true; |
| 24 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 25 | /** |
| 26 | * Factory |
| 27 | */ |
| 28 | public static class Factory implements TProtocolFactory { |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 29 | protected boolean strictRead_ = false; |
| 30 | protected boolean strictWrite_ = true; |
| 31 | |
| 32 | public Factory() { |
| 33 | this(false, false); |
| 34 | } |
| 35 | |
| 36 | public Factory(boolean strictRead, boolean strictWrite) { |
| 37 | strictRead_ = strictRead; |
| 38 | strictWrite_ = strictWrite; |
| 39 | } |
| 40 | |
Aditya Agarwal | 5a42958 | 2007-02-06 02:51:15 +0000 | [diff] [blame] | 41 | public TProtocol getProtocol(TTransport trans) { |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 42 | return new TBinaryProtocol(trans, strictRead_, strictWrite_); |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 43 | } |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 44 | } |
| 45 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 46 | /** |
| 47 | * Constructor |
| 48 | */ |
Aditya Agarwal | 5a42958 | 2007-02-06 02:51:15 +0000 | [diff] [blame] | 49 | public TBinaryProtocol(TTransport trans) { |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 50 | this(trans, false, false); |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 51 | } |
| 52 | |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 53 | public TBinaryProtocol(TTransport trans, boolean strictRead, boolean strictWrite) { |
| 54 | super(trans); |
| 55 | strictRead_ = strictRead; |
| 56 | strictWrite_ = strictWrite; |
| 57 | } |
| 58 | |
| 59 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 60 | public void writeMessageBegin(TMessage message) throws TException { |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 61 | if (strictWrite_) { |
| 62 | int version = VERSION_1 | message.type; |
| 63 | writeI32(version); |
| 64 | writeString(message.name); |
| 65 | writeI32(message.seqid); |
| 66 | } else { |
| 67 | writeString(message.name); |
| 68 | writeByte(message.type); |
| 69 | writeI32(message.seqid); |
| 70 | } |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 71 | } |
| 72 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 73 | public void writeMessageEnd() {} |
| 74 | |
| 75 | public void writeStructBegin(TStruct struct) {} |
| 76 | |
| 77 | public void writeStructEnd() {} |
| 78 | |
| 79 | public void writeFieldBegin(TField field) throws TException { |
| 80 | writeByte(field.type); |
| 81 | writeI16(field.id); |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 82 | } |
| 83 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 84 | public void writeFieldEnd() {} |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 85 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 86 | public void writeFieldStop() throws TException { |
| 87 | writeByte(TType.STOP); |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 88 | } |
| 89 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 90 | public void writeMapBegin(TMap map) throws TException { |
| 91 | writeByte(map.keyType); |
| 92 | writeByte(map.valueType); |
| 93 | writeI32(map.size); |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 94 | } |
| 95 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 96 | public void writeMapEnd() {} |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 97 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 98 | public void writeListBegin(TList list) throws TException { |
| 99 | writeByte(list.elemType); |
| 100 | writeI32(list.size); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 101 | } |
| 102 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 103 | public void writeListEnd() {} |
| 104 | |
| 105 | public void writeSetBegin(TSet set) throws TException { |
| 106 | writeByte(set.elemType); |
| 107 | writeI32(set.size); |
| 108 | } |
| 109 | |
| 110 | public void writeSetEnd() {} |
| 111 | |
| 112 | public void writeBool(boolean b) throws TException { |
| 113 | writeByte(b ? (byte)1 : (byte)0); |
| 114 | } |
| 115 | |
| 116 | private byte [] bout = new byte[1]; |
| 117 | public void writeByte(byte b) throws TException { |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 118 | bout[0] = b; |
Aditya Agarwal | 5a42958 | 2007-02-06 02:51:15 +0000 | [diff] [blame] | 119 | trans_.write(bout, 0, 1); |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 120 | } |
| 121 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 122 | private byte[] i16out = new byte[2]; |
| 123 | public void writeI16(short i16) throws TException { |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 124 | i16out[0] = (byte)(0xff & (i16 >> 8)); |
| 125 | i16out[1] = (byte)(0xff & (i16)); |
Aditya Agarwal | 5a42958 | 2007-02-06 02:51:15 +0000 | [diff] [blame] | 126 | trans_.write(i16out, 0, 2); |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 127 | } |
| 128 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 129 | private byte[] i32out = new byte[4]; |
| 130 | public void writeI32(int i32) throws TException { |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 131 | i32out[0] = (byte)(0xff & (i32 >> 24)); |
| 132 | i32out[1] = (byte)(0xff & (i32 >> 16)); |
| 133 | i32out[2] = (byte)(0xff & (i32 >> 8)); |
| 134 | i32out[3] = (byte)(0xff & (i32)); |
Aditya Agarwal | 5a42958 | 2007-02-06 02:51:15 +0000 | [diff] [blame] | 135 | trans_.write(i32out, 0, 4); |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 136 | } |
| 137 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 138 | private byte[] i64out = new byte[8]; |
| 139 | public void writeI64(long i64) throws TException { |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 140 | i64out[0] = (byte)(0xff & (i64 >> 56)); |
| 141 | i64out[1] = (byte)(0xff & (i64 >> 48)); |
| 142 | i64out[2] = (byte)(0xff & (i64 >> 40)); |
| 143 | i64out[3] = (byte)(0xff & (i64 >> 32)); |
| 144 | i64out[4] = (byte)(0xff & (i64 >> 24)); |
| 145 | i64out[5] = (byte)(0xff & (i64 >> 16)); |
| 146 | i64out[6] = (byte)(0xff & (i64 >> 8)); |
| 147 | i64out[7] = (byte)(0xff & (i64)); |
Aditya Agarwal | 5a42958 | 2007-02-06 02:51:15 +0000 | [diff] [blame] | 148 | trans_.write(i64out, 0, 8); |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 149 | } |
| 150 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 151 | public void writeDouble(double dub) throws TException { |
| 152 | writeI64(Double.doubleToLongBits(dub)); |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 153 | } |
| 154 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 155 | public void writeString(String str) throws TException { |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 156 | byte[] dat = str.getBytes(); |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 157 | writeI32(dat.length); |
Aditya Agarwal | 5a42958 | 2007-02-06 02:51:15 +0000 | [diff] [blame] | 158 | trans_.write(dat, 0, dat.length); |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 159 | } |
| 160 | |
Mark Slee | 8d725a2 | 2007-04-13 01:57:12 +0000 | [diff] [blame] | 161 | public void writeBinary(byte[] bin) throws TException { |
| 162 | writeI32(bin.length); |
| 163 | trans_.write(bin, 0, bin.length); |
| 164 | } |
| 165 | |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 166 | /** |
| 167 | * Reading methods. |
| 168 | */ |
| 169 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 170 | public TMessage readMessageBegin() throws TException { |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 171 | TMessage message = new TMessage(); |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 172 | |
| 173 | int size = readI32(); |
| 174 | if (size < 0) { |
| 175 | int version = size & VERSION_MASK; |
| 176 | if (version != VERSION_1) { |
| 177 | throw new TProtocolException(TProtocolException.BAD_VERSION, "Bad version in readMessageBegin"); |
| 178 | } |
| 179 | message.type = (byte)(version & 0x000000ff); |
| 180 | message.name = readString(); |
| 181 | message.seqid = readI32(); |
| 182 | } else { |
| 183 | if (strictRead_) { |
| 184 | throw new TProtocolException(TProtocolException.BAD_VERSION, "Missing version in readMessageBegin, old client?"); |
| 185 | } |
| 186 | message.name = readStringBody(size); |
| 187 | message.type = readByte(); |
| 188 | message.seqid = readI32(); |
| 189 | } |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 190 | return message; |
| 191 | } |
| 192 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 193 | public void readMessageEnd() {} |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 194 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 195 | public TStruct readStructBegin() { |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 196 | return new TStruct(); |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 197 | } |
| 198 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 199 | public void readStructEnd() {} |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 200 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 201 | public TField readFieldBegin() throws TException { |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 202 | TField field = new TField(); |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 203 | field.type = readByte(); |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 204 | if (field.type != TType.STOP) { |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 205 | field.id = readI16(); |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 206 | } |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 207 | return field; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 208 | } |
| 209 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 210 | public void readFieldEnd() {} |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 211 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 212 | public TMap readMapBegin() throws TException { |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 213 | TMap map = new TMap(); |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 214 | map.keyType = readByte(); |
| 215 | map.valueType = readByte(); |
| 216 | map.size = readI32(); |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 217 | return map; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 218 | } |
| 219 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 220 | public void readMapEnd() {} |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 221 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 222 | public TList readListBegin() throws TException { |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 223 | TList list = new TList(); |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 224 | list.elemType = readByte(); |
| 225 | list.size = readI32(); |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 226 | return list; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 227 | } |
| 228 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 229 | public void readListEnd() {} |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 230 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 231 | public TSet readSetBegin() throws TException { |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 232 | TSet set = new TSet(); |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 233 | set.elemType = readByte(); |
| 234 | set.size = readI32(); |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 235 | return set; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 236 | } |
| 237 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 238 | public void readSetEnd() {} |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 239 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 240 | public boolean readBool() throws TException { |
| 241 | return (readByte() == 1); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 242 | } |
| 243 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 244 | private byte[] bin = new byte[1]; |
| 245 | public byte readByte() throws TException { |
Aditya Agarwal | 5a42958 | 2007-02-06 02:51:15 +0000 | [diff] [blame] | 246 | trans_.readAll(bin, 0, 1); |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 247 | return bin[0]; |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 248 | } |
| 249 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 250 | private byte[] i16rd = new byte[2]; |
| 251 | public short readI16() throws TException { |
Aditya Agarwal | 5a42958 | 2007-02-06 02:51:15 +0000 | [diff] [blame] | 252 | trans_.readAll(i16rd, 0, 2); |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 253 | return |
| 254 | (short) |
| 255 | (((i16rd[0] & 0xff) << 8) | |
| 256 | ((i16rd[1] & 0xff))); |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 257 | } |
| 258 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 259 | private byte[] i32rd = new byte[4]; |
| 260 | public int readI32() throws TException { |
Aditya Agarwal | 5a42958 | 2007-02-06 02:51:15 +0000 | [diff] [blame] | 261 | trans_.readAll(i32rd, 0, 4); |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 262 | return |
| 263 | ((i32rd[0] & 0xff) << 24) | |
| 264 | ((i32rd[1] & 0xff) << 16) | |
| 265 | ((i32rd[2] & 0xff) << 8) | |
| 266 | ((i32rd[3] & 0xff)); |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 267 | } |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 268 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 269 | private byte[] i64rd = new byte[8]; |
| 270 | public long readI64() throws TException { |
Aditya Agarwal | 5a42958 | 2007-02-06 02:51:15 +0000 | [diff] [blame] | 271 | trans_.readAll(i64rd, 0, 8); |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 272 | return |
| 273 | ((long)(i64rd[0] & 0xff) << 56) | |
| 274 | ((long)(i64rd[1] & 0xff) << 48) | |
| 275 | ((long)(i64rd[2] & 0xff) << 40) | |
| 276 | ((long)(i64rd[3] & 0xff) << 32) | |
| 277 | ((long)(i64rd[4] & 0xff) << 24) | |
| 278 | ((long)(i64rd[5] & 0xff) << 16) | |
| 279 | ((long)(i64rd[6] & 0xff) << 8) | |
| 280 | ((long)(i64rd[7] & 0xff)); |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 281 | } |
| 282 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 283 | public double readDouble() throws TException { |
| 284 | return Double.longBitsToDouble(readI64()); |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 285 | } |
| 286 | |
Mark Slee | 456b7a8 | 2006-10-25 20:53:37 +0000 | [diff] [blame] | 287 | public String readString() throws TException { |
| 288 | int size = readI32(); |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 289 | return readStringBody(size); |
| 290 | } |
| 291 | |
| 292 | public String readStringBody(int size) throws TException { |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 293 | byte[] buf = new byte[size]; |
Aditya Agarwal | 5a42958 | 2007-02-06 02:51:15 +0000 | [diff] [blame] | 294 | trans_.readAll(buf, 0, size); |
Mark Slee | 530fd66 | 2006-08-09 00:05:18 +0000 | [diff] [blame] | 295 | return new String(buf); |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 296 | } |
Mark Slee | 8d725a2 | 2007-04-13 01:57:12 +0000 | [diff] [blame] | 297 | |
| 298 | public byte[] readBinary() throws TException { |
| 299 | int size = readI32(); |
| 300 | byte[] buf = new byte[size]; |
| 301 | trans_.readAll(buf, 0, size); |
| 302 | return buf; |
| 303 | } |
| 304 | |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 305 | } |