Interface ProtocolDecoder


public interface ProtocolDecoder
Datagram stream decoder.

Objects implementing this interface are created by Protocol objects. They are used to decompose a stream into individual datagrams.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    decode(byte[] buf, int offset, int length)
    Decode data from the stream.
    byte[]
    Get the next datagram.
    boolean
    Check whether the decoder requires more input.
  • Method Details

    • inputRequired

      boolean inputRequired()
      Check whether the decoder requires more input.
      Returns:
      true if a datagram is ready to be retrieved using getNext(), false if no datagram is available and the caller should provide more input using decode(byte[], int, int)
    • decode

      void decode(byte[] buf, int offset, int length)
      Decode data from the stream. This method should be called after a call to inputRequired() returned true.
      Parameters:
      buf - a byte array containing data from the stream
      offset - the start offset in the data
      length - the number of bytes
    • getNext

      byte[] getNext()
      Get the next datagram. This method should only be called after a call to inputRequired() returned false. Otherwise the result is undefined.
      Returns:
      a byte array containing the datagram