public TProtocol getProtocol(TTransport trans) { return new TBinaryProtocol(trans, stringLengthLimit_, containerLengthLimit_, strictRead_, strictWrite_); } }
public TMap readMapBegin() throws TException { TMap map = new TMap(readByte(), readByte(), readI32()); checkContainerReadLength(map.size); return map; }
/** * Reading methods. */ public TMessage readMessageBegin() throws TException { int size = readI32(); if (size < 0) { int version = size & VERSION_MASK; if (version != VERSION_1) { throw new TProtocolException(TProtocolException.BAD_VERSION, "Bad version in readMessageBegin"); } return new TMessage(readString(), (byte)(size & 0x000000ff), readI32()); } else { if (strictRead_) { throw new TProtocolException(TProtocolException.BAD_VERSION, "Missing version in readMessageBegin, old client?"); } return new TMessage(readStringBody(size), readByte(), readI32()); } }
public String readString() throws TException { int size = readI32(); checkStringReadLength(size); if (stringLengthLimit_ > 0 && size > stringLengthLimit_) { throw new TProtocolException(TProtocolException.SIZE_LIMIT, "String field exceeded string size limit"); } if (trans_.getBytesRemainingInBuffer() >= size) { try { String s = new String(trans_.getBuffer(), trans_.getBufferPosition(), size, "UTF-8"); trans_.consumeBuffer(size); return s; } catch (UnsupportedEncodingException e) { throw new TException("JVM DOES NOT SUPPORT UTF-8"); } } return readStringBody(size); }
public byte readByte() throws TException { if (trans_.getBytesRemainingInBuffer() >= 1) { byte b = trans_.getBuffer()[trans_.getBufferPosition()]; trans_.consumeBuffer(1); return b; } readAll(bin, 0, 1); return bin[0]; }
public double readDouble() throws TException { return Double.longBitsToDouble(readI64()); }
public boolean readBool() throws TException { return (readByte() == 1); }
public ByteBuffer readBinary() throws TException { int size = readI32(); if (stringLengthLimit_ > 0 && size > stringLengthLimit_) { throw new TProtocolException(TProtocolException.SIZE_LIMIT, "Binary field exceeded string size limit"); } if (trans_.getBytesRemainingInBuffer() >= size) { ByteBuffer bb = ByteBuffer.wrap(trans_.getBuffer(), trans_.getBufferPosition(), size); trans_.consumeBuffer(size); return bb; } byte[] buf = new byte[size]; trans_.readAll(buf, 0, size); return ByteBuffer.wrap(buf); }
/** * Reading methods. */ public TMessage readMessageBegin() throws TException { int size = readI32(); if (size < 0) { int version = size & VERSION_MASK; if (version != VERSION_1) { throw new TProtocolException(TProtocolException.BAD_VERSION, "Bad version in readMessageBegin"); } return new TMessage(readString(), (byte)(size & 0x000000ff), readI32()); } else { if (strictRead_) { throw new TProtocolException(TProtocolException.BAD_VERSION, "Missing version in readMessageBegin, old client?"); } return new TMessage(readStringBody(size), readByte(), readI32()); } }
public String readString() throws TException { int size = readI32(); checkStringReadLength(size); if (stringLengthLimit_ > 0 && size > stringLengthLimit_) { throw new TProtocolException(TProtocolException.SIZE_LIMIT, "String field exceeded string size limit"); } if (trans_.getBytesRemainingInBuffer() >= size) { try { String s = new String(trans_.getBuffer(), trans_.getBufferPosition(), size, "UTF-8"); trans_.consumeBuffer(size); return s; } catch (UnsupportedEncodingException e) { throw new TException("JVM DOES NOT SUPPORT UTF-8"); } } return readStringBody(size); }
public byte readByte() throws TException { if (trans_.getBytesRemainingInBuffer() >= 1) { byte b = trans_.getBuffer()[trans_.getBufferPosition()]; trans_.consumeBuffer(1); return b; } readAll(bin, 0, 1); return bin[0]; }
public double readDouble() throws TException { return Double.longBitsToDouble(readI64()); }
public boolean readBool() throws TException { return (readByte() == 1); }
public ByteBuffer readBinary() throws TException { int size = readI32(); if (stringLengthLimit_ > 0 && size > stringLengthLimit_) { throw new TProtocolException(TProtocolException.SIZE_LIMIT, "Binary field exceeded string size limit"); } if (trans_.getBytesRemainingInBuffer() >= size) { ByteBuffer bb = ByteBuffer.wrap(trans_.getBuffer(), trans_.getBufferPosition(), size); trans_.consumeBuffer(size); return bb; } byte[] buf = new byte[size]; trans_.readAll(buf, 0, size); return ByteBuffer.wrap(buf); }
public TList readListBegin() throws TException { TList list = new TList(readByte(), readI32()); checkContainerReadLength(list.size); return list; }
public short readI16() throws TException { byte[] buf = i16rd; int off = 0; if (trans_.getBytesRemainingInBuffer() >= 2) { buf = trans_.getBuffer(); off = trans_.getBufferPosition(); trans_.consumeBuffer(2); } else { readAll(i16rd, 0, 2); } return (short) (((buf[off] & 0xff) << 8) | ((buf[off+1] & 0xff))); }
public TProtocol getProtocol(TTransport trans) { return new TBinaryProtocol(trans, stringLengthLimit_, containerLengthLimit_, strictRead_, strictWrite_); } }
public TMap readMapBegin() throws TException { TMap map = new TMap(readByte(), readByte(), readI32()); checkContainerReadLength(map.size); return map; }