Class FrameReader<T extends FrameHeaderReader>

  • Type Parameters:
    T - Header type.
    Direct Known Subclasses:
    DataFrameReader, SaslNegotiationFrameReader

    public abstract class FrameReader<T extends FrameHeaderReader>
    extends java.lang.Object
    Read frames from a transport. Each frame has a header and a payload. A header will indicate the size of the payload and other informations about how to decode payload. Implementations should subclass it by providing a header reader implementation.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected FrameReader​(T header)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Reset the state of the reader so that it can be reused to read a new frame.
      T getHeader()  
      int getHeaderSize()  
      byte[] getPayload()  
      int getPayloadSize()  
      boolean isComplete()  
      boolean read​(TTransport transport)
      (Nonblocking) Read available bytes out of the transport without blocking to wait for incoming data.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FrameReader

        protected FrameReader​(T header)
    • Method Detail

      • getHeader

        public T getHeader()
        Returns:
        header of the frame
      • getHeaderSize

        public int getHeaderSize()
        Returns:
        number of bytes of the header
      • getPayload

        public byte[] getPayload()
        Returns:
        byte array of the payload
      • getPayloadSize

        public int getPayloadSize()
        Returns:
        size of the payload
      • isComplete

        public boolean isComplete()
        Returns:
        true if the reader has fully read a frame
      • clear

        public void clear()
        Reset the state of the reader so that it can be reused to read a new frame.