Class TTextProtocol
- java.lang.Object
-
- org.apache.thrift.protocol.TProtocol
-
- com.linecorp.armeria.common.thrift.text.TTextProtocol
-
public class TTextProtocol extends TProtocol
A simple text format for serializing/deserializing thrift messages. This format is inefficient in space.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTTextProtocol.FactoryFactory.
-
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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from class org.apache.thrift.protocol.TProtocol
getTransport
-
-
-
-
Constructor Detail
-
TTextProtocol
public TTextProtocol(TTransport trans)
Create a parser which can read from trans, and create the output writer that can write to a TTransport.
-
-
Method Detail
-
writeMessageBegin
public void writeMessageBegin(TMessage message) throws TException
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
public void writeMessageEnd() throws TException- Specified by:
writeMessageEndin classTProtocol- Throws:
TException
-
writeStructBegin
public void writeStructBegin(TStruct struct) throws TException
- Specified by:
writeStructBeginin classTProtocol- Throws:
TException
-
writeStructEnd
public void writeStructEnd() throws TException- Specified by:
writeStructEndin classTProtocol- Throws:
TException
-
writeFieldBegin
public void writeFieldBegin(TField field) throws TException
- Specified by:
writeFieldBeginin classTProtocol- Throws:
TException
-
writeFieldEnd
public void writeFieldEnd() throws TException- Specified by:
writeFieldEndin classTProtocol- Throws:
TException
-
writeFieldStop
public void writeFieldStop() throws TException- Specified by:
writeFieldStopin classTProtocol- Throws:
TException
-
writeMapBegin
public void writeMapBegin(TMap map) throws TException
- Specified by:
writeMapBeginin classTProtocol- Throws:
TException
-
writeMapEnd
public void writeMapEnd() throws TException- Specified by:
writeMapEndin classTProtocol- Throws:
TException
-
writeListBegin
public void writeListBegin(TList list) throws TException
- Specified by:
writeListBeginin classTProtocol- Throws:
TException
-
writeListEnd
public void writeListEnd() throws TException- Specified by:
writeListEndin classTProtocol- Throws:
TException
-
writeSetBegin
public void writeSetBegin(TSet set) throws TException
- Specified by:
writeSetBeginin classTProtocol- Throws:
TException
-
writeSetEnd
public void writeSetEnd() throws TException- Specified by:
writeSetEndin classTProtocol- Throws:
TException
-
writeBool
public void writeBool(boolean b) throws TException- Specified by:
writeBoolin classTProtocol- Throws:
TException
-
writeByte
public void writeByte(byte b) throws TException- Specified by:
writeBytein classTProtocol- Throws:
TException
-
writeI16
public void writeI16(short i16) throws TException- Specified by:
writeI16in classTProtocol- Throws:
TException
-
writeI32
public void writeI32(int i32) throws TException- Specified by:
writeI32in classTProtocol- Throws:
TException
-
writeI64
public void writeI64(long i64) throws TException- Specified by:
writeI64in classTProtocol- Throws:
TException
-
writeDouble
public void writeDouble(double dub) throws TException- Specified by:
writeDoublein classTProtocol- Throws:
TException
-
writeString
public void writeString(String str) throws TException
- Specified by:
writeStringin classTProtocol- Throws:
TException
-
writeBinary
public void writeBinary(ByteBuffer buf) throws TException
- Specified by:
writeBinaryin classTProtocol- Throws:
TException
-
readMessageBegin
public TMessage readMessageBegin() throws TException
- Specified by:
readMessageBeginin classTProtocol- Throws:
TException
-
readMessageEnd
public void readMessageEnd() throws TException- Specified by:
readMessageEndin classTProtocol- Throws:
TException
-
readStructBegin
public TStruct readStructBegin() throws TException
- Specified by:
readStructBeginin classTProtocol- Throws:
TException
-
readStructEnd
public void readStructEnd() throws TException- Specified by:
readStructEndin classTProtocol- Throws:
TException
-
readFieldBegin
public TField readFieldBegin() throws TException
- Specified by:
readFieldBeginin classTProtocol- Throws:
TException
-
readFieldEnd
public void readFieldEnd() throws TException- Specified by:
readFieldEndin classTProtocol- Throws:
TException
-
readMapBegin
public TMap readMapBegin() throws TException
- Specified by:
readMapBeginin classTProtocol- Throws:
TException
-
readMapEnd
public void readMapEnd() throws TException- Specified by:
readMapEndin classTProtocol- Throws:
TException
-
readListBegin
public TList readListBegin() throws TException
- Specified by:
readListBeginin classTProtocol- Throws:
TException
-
readListEnd
public void readListEnd() throws TException- Specified by:
readListEndin classTProtocol- Throws:
TException
-
readSetBegin
public TSet readSetBegin() throws TException
- Specified by:
readSetBeginin classTProtocol- Throws:
TException
-
readSetEnd
public void readSetEnd() throws TException- Specified by:
readSetEndin classTProtocol- Throws:
TException
-
readBool
public boolean readBool() throws TException- Specified by:
readBoolin classTProtocol- Throws:
TException
-
readByte
public byte readByte() throws TException- Specified by:
readBytein classTProtocol- Throws:
TException
-
readI16
public short readI16() throws TException- Specified by:
readI16in classTProtocol- Throws:
TException
-
readI32
public int readI32() throws TException- Specified by:
readI32in classTProtocol- Throws:
TException
-
readI64
public long readI64() throws TException- Specified by:
readI64in classTProtocol- Throws:
TException
-
readDouble
public double readDouble() throws TException- Specified by:
readDoublein classTProtocol- Throws:
TException
-
readString
public String readString() throws TException
- Specified by:
readStringin classTProtocol- Throws:
TException
-
readBinary
public ByteBuffer readBinary() throws TException
- Specified by:
readBinaryin classTProtocol- Throws:
TException
-
-