Class TProtocol

    • Field Detail

      • skippedBytes

        protected byte[] skippedBytes
    • Constructor Detail

      • TProtocol

        protected TProtocol​(TTransport trans)
        Constructor
    • Method Detail

      • getTransport

        public TTransport getTransport()
        Transport accessor
      • getMinSerializedSize

        public abstract int getMinSerializedSize​(byte type)
                                          throws TException
        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
      • readMessage

        public final <T> T readMessage​(TProtocol.ReadCallback<TMessage,​T> callback)
                                throws TException
        read a message by delegating to a callback, handles begin and end automatically.
        Type Parameters:
        T - result message type
        Parameters:
        callback - callback for actual reading
        Returns:
        the message read
        Throws:
        TException - when any sub-operation failed
      • readStruct

        public final <T> T readStruct​(TProtocol.ReadCallback<TStruct,​T> callback)
                               throws TException
        read a struct by delegating to a callback, handles begin and end automatically.
        Type Parameters:
        T - result struct type
        Parameters:
        callback - callback for actual reading
        Returns:
        the struct read
        Throws:
        TException - when any sub-operation failed
      • readField

        public final <T> boolean readField​(TProtocol.ReadCallback<TField,​T> callback)
                                    throws java.lang.Exception
        read a field by delegating to a callback, handles begin and end automatically, and returns whether the stop 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:
        java.lang.Exception - when any sub-operation failed
      • readMap

        public final <T extends java.util.Map<?,​?>> T readMap​(TProtocol.ReadCallback<TMap,​T> callback)
                                                             throws TException
        read a Map of elements by delegating to the callback, handles begin and end automatically.
        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> java.util.Map<K,​V> readMap​(TProtocol.ReadMapEntryCallback<K,​V> callback,
                                                                  java.util.function.IntFunction<java.util.Map<K,​V>> mapCreator)
                                                           throws TException
        read a Map of elements by delegating key and value reading to the callback, handles begin and end automatically, with a specialized map creator given the size hint.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        callback - callback for reading keys and values, calls to TProtocol.ReadMapEntryCallback.getKey() and TProtocol.ReadMapEntryCallback.getValue() will be in alternating orders, i.e. k1, v1, k2, v2, .., k_n, v_n
        mapCreator - map creator given the size hint
        Returns:
        the map read
        Throws:
        TException - when any sub-operation fails
      • readList

        public final <T extends java.util.List<?>> T readList​(TProtocol.ReadCallback<TList,​T> callback)
                                                       throws TException
        read a List by delegating to the callback, handles begin and end automatically.
        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

        public final <T> java.util.List<T> readList​(TProtocol.ReadCollectionCallback<T> callback)
                                             throws TException
        read a List by delegating element reading to the callback, handles begin and end automatically.
        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> java.util.List<T> readList​(TProtocol.ReadCollectionCallback<T> callback,
                                                    java.util.function.IntFunction<java.util.List<T>> listCreator)
                                             throws TException
        read a List by delegating element reading to the callback, handles begin and end automatically, with a specialized list creator given the size hint.
        Type Parameters:
        T - element type
        Parameters:
        callback - callback for reading one element
        listCreator - list creator given size hint
        Returns:
        list of elements read
        Throws:
        TException - when any sub-operation fails
      • readSet

        public final <T extends java.util.Set<?>> T readSet​(TProtocol.ReadCallback<TSet,​T> callback)
                                                     throws TException
        read a Set of elements by delegating to the callback, handles begin and end automatically
        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

        public final <T> java.util.Set<T> readSet​(TProtocol.ReadCollectionCallback<T> callback)
                                           throws TException
        read a Set of elements by delegating element reading to the callback, handles begin and end 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> java.util.Set<T> readSet​(TProtocol.ReadCollectionCallback<T> callback,
                                                  java.util.function.IntFunction<java.util.Set<T>> setCreator)
                                           throws TException
        read a Set of elements by delegating element reading to the callback, handles begin and end automatically, with a specialized set creator given the size hint.
        Type Parameters:
        T - element type
        Parameters:
        callback - callback for reading one elment
        setCreator - 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

        public java.lang.Class<? extends IScheme> getScheme()
        Scheme accessor
      • skipBool

        protected void skipBool()
                         throws TException
        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