Package org.apache.thrift.protocol
Class TSimpleJSONProtocol
java.lang.Object
org.apache.thrift.protocol.TProtocol
org.apache.thrift.protocol.TSimpleJSONProtocol
- All Implemented Interfaces:
TReadProtocol,TWriteProtocol
JSON protocol implementation for thrift.
This protocol is write-only and produces a simple output format suitable for parsing by scripting languages. It should not be confused with the full-featured TJSONProtocol.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classprotected static classstatic classFactoryprotected classprotected classprotected classNested classes/interfaces inherited from class org.apache.thrift.protocol.TProtocol
TProtocol.ReadCallback<T,R>, TProtocol.ReadCollectionCallback<R>, TProtocol.ReadMapEntryCallback<K, V>, TProtocol.WriteCallback<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final TSimpleJSONProtocol.Contextprotected TSimpleJSONProtocol.ContextCurrent context that we are inprotected Stack<TSimpleJSONProtocol.Context>Stack of nested contexts that we may be in.Fields inherited from class org.apache.thrift.protocol.TProtocol
skippedBytes, trans_ -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidassertContextIsNotMapKey(String invalidKeyType) Used to make sure that we are not encountering a map whose keys are containersintgetMinSerializedSize(byte type) Return the minimum number of bytes a type will consume on the wireprotected voidPop the last write context off the stackprotected voidPush a new write context onto the stack.booleanreadBool()bytereadByte()doublevoidshortreadI16()intreadI32()longreadI64()voidvoidReading methods.voidvoidreadStringBody(int size) voidreadUuid()protected voidReset the write context stack to its initial state.voidwriteBinary(ByteBuffer bin) voidwriteBool(boolean b) voidwriteByte(byte b) voidwriteDouble(double dub) voidwriteFieldBegin(TField field) voidvoidvoidwriteI16(short i16) voidwriteI32(int i32) voidwriteI64(long i64) voidwriteListBegin(TList list) voidvoidwriteMapBegin(TMap map) voidvoidwriteMessageBegin(TMessage message) voidvoidwriteSetBegin(TSet set) voidvoidwriteString(String str) voidwriteStructBegin(TStruct struct) voidvoidMethods inherited from class org.apache.thrift.protocol.TProtocol
checkReadBytesAvailable, checkReadBytesAvailable, checkReadBytesAvailable, getScheme, getTransport, readField, readFieldBeginData, readList, readList, readList, readMap, readMap, readMap, readMessage, readSet, readSet, readSet, readStruct, reset, skip, skip, skipBinary, skipBool, skipByte, skipBytes, skipDouble, skipI16, skipI32, skipI64, writeField, writeList, writeMap, writeMessage, writeSet, writeStruct
-
Field Details
-
BASE_CONTEXT
-
writeContextStack_
Stack of nested contexts that we may be in. -
writeContext_
Current context that we are in
-
-
Constructor Details
-
TSimpleJSONProtocol
Constructor
-
-
Method Details
-
pushWriteContext
Push a new write context onto the stack. -
popWriteContext
protected void popWriteContext()Pop the last write context off the stack -
resetWriteContext
protected void resetWriteContext()Reset the write context stack to its initial state. -
assertContextIsNotMapKey
protected void assertContextIsNotMapKey(String invalidKeyType) throws TSimpleJSONProtocol.CollectionMapKeyException Used to make sure that we are not encountering a map whose keys are containers -
writeMessageBegin
- Throws:
TException
-
writeMessageEnd
- Throws:
TException
-
writeStructBegin
- Throws:
TException
-
writeStructEnd
- Throws:
TException
-
writeFieldBegin
- Throws:
TException
-
writeFieldEnd
- Throws:
TException
-
writeFieldStop
- Throws:
TException
-
writeMapBegin
- Throws:
TException
-
writeMapEnd
- Throws:
TException
-
writeListBegin
- Throws:
TException
-
writeListEnd
- Throws:
TException
-
writeSetBegin
- Throws:
TException
-
writeSetEnd
- Throws:
TException
-
writeBool
- Throws:
TException
-
writeByte
- Throws:
TException
-
writeI16
- Throws:
TException
-
writeI32
- Throws:
TException
-
_writeStringData
- Throws:
TException
-
writeI64
- Throws:
TException
-
writeUuid
- Throws:
TException
-
writeDouble
- Throws:
TException
-
writeString
- Throws:
TException
-
writeBinary
- Throws:
TException
-
readMessageBegin
Reading methods.simplejson is not meant to be read back into thrift - see ThriftUsageJava - use JSON instead
- Throws:
TException
-
readMessageEnd
- Throws:
TException
-
readStructBegin
- Throws:
TException
-
readStructEnd
- Throws:
TException
-
readFieldBegin
- Throws:
TException
-
readFieldEnd
- Throws:
TException
-
readMapBegin
- Throws:
TException
-
readMapEnd
- Throws:
TException
-
readListBegin
- Throws:
TException
-
readListEnd
- Throws:
TException
-
readSetBegin
- Throws:
TException
-
readSetEnd
- Throws:
TException
-
readBool
- Throws:
TException
-
readByte
- Throws:
TException
-
readI16
- Throws:
TException
-
readI32
- Throws:
TException
-
readI64
- Throws:
TException
-
readUuid
- Throws:
TException
-
readDouble
- Throws:
TException
-
readString
- Throws:
TException
-
readStringBody
- Throws:
TException
-
readBinary
- Throws:
TException
-
getMinSerializedSize
Return the minimum number of bytes a type will consume on the wire- Specified by:
getMinSerializedSizein classTProtocol- Parameters:
type- Returns the minimum amount of bytes needed to store the smallest possible instance of TType.- Returns:
- min serialized size
- Throws:
TException- when error happens
-