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 class
protected static class
static class
Factoryprotected class
protected class
protected class
Nested 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.Context
protected TSimpleJSONProtocol.Context
Current 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 TypeMethodDescriptionvoid
protected void
assertContextIsNotMapKey
(String invalidKeyType) Used to make sure that we are not encountering a map whose keys are containersint
getMinSerializedSize
(byte type) Return the minimum number of bytes a type will consume on the wireprotected void
Pop the last write context off the stackprotected void
Push a new write context onto the stack.boolean
readBool()
byte
readByte()
double
void
short
readI16()
int
readI32()
long
readI64()
void
void
Reading methods.void
void
readStringBody
(int size) void
readUuid()
protected void
Reset the write context stack to its initial state.void
writeBinary
(ByteBuffer bin) void
writeBool
(boolean b) void
writeByte
(byte b) void
writeDouble
(double dub) void
writeFieldBegin
(TField field) void
void
void
writeI16
(short i16) void
writeI32
(int i32) void
writeI64
(long i64) void
writeListBegin
(TList list) void
void
writeMapBegin
(TMap map) void
void
writeMessageBegin
(TMessage message) void
void
writeSetBegin
(TSet set) void
void
writeString
(String str) void
writeStructBegin
(TStruct struct) void
void
Methods 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:
getMinSerializedSize
in 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
-