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
Modifier and TypeClassDescriptionstatic interface
static interface
static interface
static interface
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkReadBytesAvailable
(TList list) protected void
protected void
abstract int
getMinSerializedSize
(byte type) Return min serialized size in bytesScheme accessorTransport accessorfinal <T> boolean
readField
(TProtocol.ReadCallback<TField, T> callback) read a field by delegating to a callback, handlesbegin
andend
automatically, and returns whether thestop signal
was encountered.int
final <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> T
readMessage
(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> T
readStruct
(TProtocol.ReadCallback<TStruct, T> callback) void
reset()
Reset any internal state back to a blank slate.void
skip
(byte fieldType) void
skip
(byte fieldType, int maxDepth) protected void
protected void
skipBool()
The default implementation of all skip() methods calls the corresponding read() method.protected void
skipByte()
protected void
skipBytes
(int numBytes) protected void
protected void
skipI16()
protected void
skipI32()
protected void
skipI64()
final void
writeField
(TField field, TProtocol.WriteCallback<Void> callback) final <T> void
writeList
(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 void
writeMessage
(TMessage message, TProtocol.WriteCallback<Void> callback) final <T> void
writeSet
(byte elementType, Set<T> set, TProtocol.WriteCallback<T> callback) final void
writeStruct
(TStruct struct, TProtocol.WriteCallback<Void> callback) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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, readUuid
Methods 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, handlesbegin
andend
automatically, and returns whether thestop signal
was 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 aMap
of elements by delegating key and value reading to the callback, handlesbegin
andend
automatically.- 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 aMap
of elements by delegating key and value reading to the callback, handlesbegin
andend
automatically, 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 aList
by delegating element reading to the callback, handlesbegin
andend
automatically, 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 aSet
of elements by delegating element reading to the callback, handlesbegin
andend
automatically- 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 aSet
of elements by delegating element reading to the callback, handlesbegin
andend
automatically, 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
-