Package org.apache.thrift.protocol
Class TProtocol
java.lang.Object
org.apache.thrift.protocol.TProtocol
- All Implemented Interfaces:
TReadProtocol,TWriteProtocol
- Direct Known Subclasses:
TBinaryProtocol,TCompactProtocol,TJSONProtocol,TProtocolDecorator,TSimpleJSONProtocol
Protocol interface definition.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfacestatic interfacestatic interface -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckReadBytesAvailable(TList list) protected voidprotected voidabstract intgetMinSerializedSize(byte type) Return min serialized size in bytesScheme accessorTransport accessorfinal <T> booleanreadField(TProtocol.ReadCallback<TField, T> callback) read a field by delegating to a callback, handlesbeginandendautomatically, and returns whether thestop signalwas encountered.intfinal <T extends List<?>>
TreadList(TProtocol.ReadCallback<TList, T> callback) final <T> List<T>readList(TProtocol.ReadCollectionCallback<T> callback) final <T> List<T>readList(TProtocol.ReadCollectionCallback<T> callback, IntFunction<List<T>> listCreator) final <T extends Map<?,?>>
TreadMap(TProtocol.ReadCallback<TMap, T> callback) final <K,V> Map<K, V> readMap(TProtocol.ReadMapEntryCallback<K, V> callback) final <K,V> Map<K, V> readMap(TProtocol.ReadMapEntryCallback<K, V> callback, IntFunction<Map<K, V>> mapCreator) final <T> TreadMessage(TProtocol.ReadCallback<TMessage, T> callback) final <T extends Set<?>>
TreadSet(TProtocol.ReadCallback<TSet, T> callback) final <T> Set<T>readSet(TProtocol.ReadCollectionCallback<T> callback) final <T> Set<T>readSet(TProtocol.ReadCollectionCallback<T> callback, IntFunction<Set<T>> setCreator) final <T> TreadStruct(TProtocol.ReadCallback<TStruct, T> callback) voidreset()Reset any internal state back to a blank slate.voidskip(byte fieldType) voidskip(byte fieldType, int maxDepth) protected voidprotected voidskipBool()The default implementation of all skip() methods calls the corresponding read() method.protected voidskipByte()protected voidskipBytes(int numBytes) protected voidprotected voidskipI16()protected voidskipI32()protected voidskipI64()final voidwriteField(TField field, TProtocol.WriteCallback<Void> callback) final <T> voidwriteList(byte elementType, List<T> list, TProtocol.WriteCallback<T> callback) final <K,V> void writeMap(byte keyType, byte valueType, Map<K, V> map, TProtocol.WriteCallback<Map.Entry<K, V>> callback) final voidwriteMessage(TMessage message, TProtocol.WriteCallback<Void> callback) final <T> voidwriteSet(byte elementType, Set<T> set, TProtocol.WriteCallback<T> callback) final voidwriteStruct(TStruct struct, TProtocol.WriteCallback<Void> callback) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.thrift.protocol.TReadProtocol
readBinary, readBool, readByte, readDouble, readFieldBegin, readFieldEnd, readI16, readI32, readI64, readListBegin, readListEnd, readMapBegin, readMapEnd, readMessageBegin, readMessageEnd, readSetBegin, readSetEnd, readString, readStructBegin, readStructEnd, readUuidMethods inherited from interface org.apache.thrift.protocol.TWriteProtocol
writeBinary, writeBool, writeByte, writeDouble, writeFieldBegin, writeFieldEnd, writeFieldStop, writeI16, writeI32, writeI64, writeListBegin, writeListEnd, writeMapBegin, writeMapEnd, writeMessageBegin, writeMessageEnd, writeSetBegin, writeSetEnd, writeString, writeStructBegin, writeStructEnd, writeUuid
-
Field Details
-
trans_
Transport -
skippedBytes
protected byte[] skippedBytes
-
-
Constructor Details
-
TProtocol
Constructor
-
-
Method Details
-
getTransport
Transport accessor -
checkReadBytesAvailable
- Throws:
TException
-
checkReadBytesAvailable
- Throws:
TException
-
checkReadBytesAvailable
- Throws:
TException
-
getMinSerializedSize
Return min serialized size in bytes- 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
-
writeSet
public final <T> void writeSet(byte elementType, Set<T> set, TProtocol.WriteCallback<T> callback) throws TException - Throws:
TException
-
writeList
public final <T> void writeList(byte elementType, List<T> list, TProtocol.WriteCallback<T> callback) throws TException - Throws:
TException
-
writeMap
public final <K,V> void writeMap(byte keyType, byte valueType, Map<K, V> map, TProtocol.WriteCallback<Map.Entry<K, throws TExceptionV>> callback) - Throws:
TException
-
writeField
public final void writeField(TField field, TProtocol.WriteCallback<Void> callback) throws TException - Throws:
TException
-
writeStruct
public final void writeStruct(TStruct struct, TProtocol.WriteCallback<Void> callback) throws TException - Throws:
TException
-
writeMessage
public final void writeMessage(TMessage message, TProtocol.WriteCallback<Void> callback) throws TException - Throws:
TException
-
readMessage
- Type Parameters:
T- result message type- Parameters:
callback- callback for actual reading- Returns:
- the message read
- Throws:
TException- when any sub-operation failed
-
readStruct
- Type Parameters:
T- result struct type- Parameters:
callback- callback for actual reading- Returns:
- the struct read
- Throws:
TException- when any sub-operation failed
-
readField
read a field by delegating to a callback, handlesbeginandendautomatically, and returns whether thestop signalwas encountered. Because the value is not returned, you (the compiler generated code in most cases) are expected to set the field yourself within the callback.- Type Parameters:
T- result field type- Parameters:
callback- callback for reading a field- Returns:
- true if a stop signal was encountered, false otherwise
- Throws:
Exception- when any sub-operation failed
-
readMap
public final <T extends Map<?,?>> T readMap(TProtocol.ReadCallback<TMap, T> callback) throws TException- Type Parameters:
T- result map type- Parameters:
callback- callback for reading the map- Returns:
- the map read
- Throws:
TException- when any sub-operation fails
-
readMap
public final <K,V> Map<K,V> readMap(TProtocol.ReadMapEntryCallback<K, V> callback) throws TExceptionread aMapof elements by delegating key and value reading to the callback, handlesbeginandendautomatically.- Type Parameters:
K- key typeV- value type- Parameters:
callback- callback for reading keys and values, calls toTProtocol.ReadMapEntryCallback.getKey()andTProtocol.ReadMapEntryCallback.getValue()will be in alternating orders, i.e. k1, v1, k2, v2, .., k_n, v_n- Returns:
- the map read
- Throws:
TException- when any sub-operation fails
-
readMap
public final <K,V> Map<K,V> readMap(TProtocol.ReadMapEntryCallback<K, V> callback, IntFunction<Map<K, throws TExceptionV>> mapCreator) read aMapof elements by delegating key and value reading to the callback, handlesbeginandendautomatically, with a specialized map creator given the size hint.- Type Parameters:
K- key typeV- value type- Parameters:
callback- callback for reading keys and values, calls toTProtocol.ReadMapEntryCallback.getKey()andTProtocol.ReadMapEntryCallback.getValue()will be in alternating orders, i.e. k1, v1, k2, v2, .., k_n, v_nmapCreator- map creator given the size hint- Returns:
- the map read
- Throws:
TException- when any sub-operation fails
-
readList
public final <T extends List<?>> T readList(TProtocol.ReadCallback<TList, T> callback) throws TException- Type Parameters:
T- result list type- Parameters:
callback- callback for reading the list- Returns:
- the list read
- Throws:
TException- when any sub-operation fails
-
readList
- Type Parameters:
T- element type- Parameters:
callback- callback for reading one element- Returns:
- list of elements read
- Throws:
TException- when any sub-operation fails
-
readList
public final <T> List<T> readList(TProtocol.ReadCollectionCallback<T> callback, IntFunction<List<T>> listCreator) throws TException read aListby delegating element reading to the callback, handlesbeginandendautomatically, with a specialized list creator given the size hint.- Type Parameters:
T- element type- Parameters:
callback- callback for reading one elementlistCreator- list creator given size hint- Returns:
- list of elements read
- Throws:
TException- when any sub-operation fails
-
readSet
public final <T extends Set<?>> T readSet(TProtocol.ReadCallback<TSet, T> callback) throws TException- Type Parameters:
T- result set type- Parameters:
callback- callback for reading the set- Returns:
- the set read
- Throws:
TException- when any sub-operation fails
-
readSet
read aSetof elements by delegating element reading to the callback, handlesbeginandendautomatically- Type Parameters:
T- element type- Parameters:
callback- callback for reading one element- Returns:
- set of elements read
- Throws:
TException- when any sub-operation fails
-
readSet
public final <T> Set<T> readSet(TProtocol.ReadCollectionCallback<T> callback, IntFunction<Set<T>> setCreator) throws TException read aSetof elements by delegating element reading to the callback, handlesbeginandendautomatically, with a specialized set creator given the size hint.- Type Parameters:
T- element type- Parameters:
callback- callback for reading one elmentsetCreator- set creator given size hint- Returns:
- set of elements read
- Throws:
TException- when any sub-operation fails
-
reset
public void reset()Reset any internal state back to a blank slate. This method only needs to be implemented for stateful protocols. -
getScheme
Scheme accessor -
readFieldBeginData
- Throws:
TException
-
skip
- Throws:
TException
-
skip
- Throws:
TException
-
skipBool
The default implementation of all skip() methods calls the corresponding read() method. Protocols that derive from this class are strongly encouraged to provide a more efficient alternative.- Throws:
TException
-
skipByte
- Throws:
TException
-
skipI16
- Throws:
TException
-
skipI32
- Throws:
TException
-
skipI64
- Throws:
TException
-
skipDouble
- Throws:
TException
-
skipBinary
- Throws:
TException
-
skipBytes
- Throws:
TException
-