private void readJSONObjectStart() throws TException { context_.read(); readJSONSyntaxChar(LBRACE); pushContext(new JSONPairContext()); }
private void readJSONArrayStart() throws TException { context_.read(); readJSONSyntaxChar(LBRACKET); pushContext(new JSONListContext()); }
public TList readListBegin() throws TException { TList list = new TList(readByte(), readI32()); checkContainerReadLength(list.size); return list; }
/** * Read a map header off the wire. If the size is zero, skip reading the key * and value type. This means that 0-length maps will yield TMaps without the * "correct" types. */ public TMap readMapBegin() throws TException { int size = readVarint32(); checkContainerReadLength(size); byte keyAndValueType = size == 0 ? 0 : readByte(); return new TMap(getTType((byte)(keyAndValueType >> 4)), getTType((byte)(keyAndValueType & 0xf)), size); }
public TSet readSetBegin() throws TException { TSet set = new TSet(readByte(), readI32()); checkContainerReadLength(set.size); return set; }
public TMap readMapBegin() throws TException { TMap map = new TMap(readByte(), readByte(), readI32()); checkContainerReadLength(map.size); return map; }
public void writeMapBegin(TMap map) throws TException { assertContextIsNotMapKey(MAP); writeContext_.write(); trans_.write(LBRACE); pushWriteContext(new MapContext()); // No metadata! }
public void writeListBegin(TList list) throws TException { assertContextIsNotMapKey(LIST); writeContext_.write(); trans_.write(LBRACKET); pushWriteContext(new ListContext()); // No metadata! }
/** * Read a set header off the wire. If the set size is 0-14, the size will * be packed into the element type header. If it's a longer set, the 4 MSB * of the element type header will be 0xF, and a varint will follow with the * true size. */ public TSet readSetBegin() throws TException { return new TSet(readListBegin()); }
private void writeJSONArrayStart() throws TException { context_.write(); trans_.write(LBRACKET); pushContext(new JSONListContext()); }
protected void readJSONSyntaxChar(byte[] b) throws TException { byte ch = reader_.read(); if (ch != b[0]) { throw new TProtocolException(TProtocolException.INVALID_DATA, "Unexpected character:" + (char)ch); } }
/** * Used to make sure that we are not encountering a map whose keys are containers */ protected void assertContextIsNotMapKey(String invalidKeyType) throws CollectionMapKeyException { if (writeContext_.isMapKey()) { throw new CollectionMapKeyException("Cannot serialize a map with keys that are of type " + invalidKeyType); } }
public TList readListBegin() throws TException { TList list = new TList(readByte(), readI32()); checkContainerReadLength(list.size); return list; }
/** * Read a map header off the wire. If the size is zero, skip reading the key * and value type. This means that 0-length maps will yield TMaps without the * "correct" types. */ public TMap readMapBegin() throws TException { int size = readVarint32(); checkContainerReadLength(size); byte keyAndValueType = size == 0 ? 0 : readByte(); return new TMap(getTType((byte)(keyAndValueType >> 4)), getTType((byte)(keyAndValueType & 0xf)), size); }
public TSet readSetBegin() throws TException { TSet set = new TSet(readByte(), readI32()); checkContainerReadLength(set.size); return set; }
private void readJSONObjectStart() throws TException { context_.read(); readJSONSyntaxChar(LBRACE); pushContext(new JSONPairContext()); }
private void readJSONArrayStart() throws TException { context_.read(); readJSONSyntaxChar(LBRACKET); pushContext(new JSONListContext()); }
protected void readJSONSyntaxChar(byte[] b) throws TException { byte ch = reader_.read(); if (ch != b[0]) { throw new TProtocolException(TProtocolException.INVALID_DATA, "Unexpected character:" + (char)ch); } }
/** * Used to make sure that we are not encountering a map whose keys are containers */ protected void assertContextIsNotMapKey(String invalidKeyType) throws CollectionMapKeyException { if (writeContext_.isMapKey()) { throw new CollectionMapKeyException("Cannot serialize a map with keys that are of type " + invalidKeyType); } }