Class TTextProtocol
public final class TTextProtocol extends TProtocol
For an example, see: tests/resources/com/twitter/common/thrift/text/TTextProtocol_TestData.txt
which is a text encoding of the thrift message defined in:
src/main/thrift/com/twitter/common/thrift/text/TTextProtocolTest.thrift
Whitespace (including newlines) is not significant.
No comments are allowed in the json.
Messages must be formatted as a JSON object with a field 'method' containing
the message name, 'type' containing the message type as an uppercase string
corresponding to TMessageType, 'args' containing a JSON object with
the actual arguments, and an optional 'seqid' field containing the sequence
id. If 'seqid' is not provided, it will be treated as 0. 'args' should use
the argument names as defined in the service definition.
Example:
{
"method": "GetItem",
"type": "CALL",
"args": {
"id": 1,
"fetchAll": true
},
"seqid": 100
}
TODO(Alex Roetter): write a wrapper that allows us to read in a file of many structs (perhaps stored in a JsonArray), passing each struct to this class for parsing.
See thrift's @see org.apache.thrift.protocol.TJSONProtocol for another example an implementation of the @see TProtocol interface. This class is based on that.
TODO(Alex Roetter): Also add a new TEXT_PROTOCOL field to ThriftCodec
TODO: Support map enum keys specified as strings.
TODO: Support string values for enums that have been typedef'd.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description TTextProtocol(TTransport trans)Create a parser which can read from trans, and create the output writer that can write to a TTransport. -
Method Summary
-
Constructor Details
-
TTextProtocol
Create a parser which can read from trans, and create the output writer that can write to a TTransport.
-
-
Method Details
-
getScheme
-
reset
public void reset() -
writeMessageBegin
I believe these two messages are called for a thrift service interface. We don't plan on storing any text objects of that type on disk.- Specified by:
writeMessageBeginin classTProtocol- Throws:
TException
-
writeMessageEnd
- Specified by:
writeMessageEndin classTProtocol- Throws:
TException
-
writeStructBegin
- Specified by:
writeStructBeginin classTProtocol- Throws:
TException
-
writeStructEnd
- Specified by:
writeStructEndin classTProtocol- Throws:
TException
-
writeFieldBegin
- Specified by:
writeFieldBeginin classTProtocol- Throws:
TException
-
writeFieldEnd
- Specified by:
writeFieldEndin classTProtocol- Throws:
TException
-
writeFieldStop
- Specified by:
writeFieldStopin classTProtocol- Throws:
TException
-
writeMapBegin
- Specified by:
writeMapBeginin classTProtocol- Throws:
TException
-
writeMapEnd
- Specified by:
writeMapEndin classTProtocol- Throws:
TException
-
writeListBegin
- Specified by:
writeListBeginin classTProtocol- Throws:
TException
-
writeListEnd
- Specified by:
writeListEndin classTProtocol- Throws:
TException
-
writeSetBegin
- Specified by:
writeSetBeginin classTProtocol- Throws:
TException
-
writeSetEnd
- Specified by:
writeSetEndin classTProtocol- Throws:
TException
-
writeBool
- Specified by:
writeBoolin classTProtocol- Throws:
TException
-
writeByte
- Specified by:
writeBytein classTProtocol- Throws:
TException
-
writeI16
- Specified by:
writeI16in classTProtocol- Throws:
TException
-
writeI32
- Specified by:
writeI32in classTProtocol- Throws:
TException
-
writeI64
- Specified by:
writeI64in classTProtocol- Throws:
TException
-
writeDouble
- Specified by:
writeDoublein classTProtocol- Throws:
TException
-
writeString
- Specified by:
writeStringin classTProtocol- Throws:
TException
-
writeBinary
- Specified by:
writeBinaryin classTProtocol- Throws:
TException
-
readMessageBegin
- Specified by:
readMessageBeginin classTProtocol- Throws:
TException
-
readMessageEnd
- Specified by:
readMessageEndin classTProtocol- Throws:
TException
-
readStructBegin
- Specified by:
readStructBeginin classTProtocol- Throws:
TException
-
readStructEnd
- Specified by:
readStructEndin classTProtocol- Throws:
TException
-
readFieldBegin
- Specified by:
readFieldBeginin classTProtocol- Throws:
TException
-
readFieldEnd
- Specified by:
readFieldEndin classTProtocol- Throws:
TException
-
readMapBegin
- Specified by:
readMapBeginin classTProtocol- Throws:
TException
-
readMapEnd
- Specified by:
readMapEndin classTProtocol- Throws:
TException
-
readListBegin
- Specified by:
readListBeginin classTProtocol- Throws:
TException
-
readListEnd
- Specified by:
readListEndin classTProtocol- Throws:
TException
-
readSetBegin
- Specified by:
readSetBeginin classTProtocol- Throws:
TException
-
readSetEnd
- Specified by:
readSetEndin classTProtocol- Throws:
TException
-
readBool
- Specified by:
readBoolin classTProtocol- Throws:
TException
-
readByte
- Specified by:
readBytein classTProtocol- Throws:
TException
-
readI16
- Specified by:
readI16in classTProtocol- Throws:
TException
-
readI32
- Specified by:
readI32in classTProtocol- Throws:
TException
-
readI64
- Specified by:
readI64in classTProtocol- Throws:
TException
-
readDouble
- Specified by:
readDoublein classTProtocol- Throws:
TException
-
readString
- Specified by:
readStringin classTProtocol- Throws:
TException
-
readBinary
- Specified by:
readBinaryin classTProtocol- Throws:
TException
-