Interface DataFormat<T>

Type Parameters:
T - data type (e.g. String or binary packet)

public interface DataFormat<T>
Data format for device communication.
  • Method Summary

    Modifier and Type
    Method
    Description
    default <V> Optional<V>
    getValueByName(String name, T data)
    Returns a value contained in the data by name, e.g., a packet entry.
    boolean
    isReply(Command<T> cmd, T replyData)
    Determines whether the specified data is a reply to the command.
    Reads data from the specified input stream.
    void
    Writes data to the specified input stream.
  • Method Details

    • readData

      T readData(InputStream is) throws IOException
      Reads data from the specified input stream.
      Parameters:
      is - input stream for reading the data
      Returns:
      data that has been read from the specified input stream
      Throws:
      IOException - if an I/O error occurs
    • writeData

      void writeData(T data, OutputStream os) throws IOException
      Writes data to the specified input stream.
      Parameters:
      os - output stream for writing the data
      Throws:
      IOException - if an I/O error occurs
    • isReply

      boolean isReply(Command<T> cmd, T replyData)
      Determines whether the specified data is a reply to the command.
      Parameters:
      cmd - the command
      replyData - potential reply packet
      Returns:
      true if the data is a reply to the command; false otherwise
    • getValueByName

      default <V> Optional<V> getValueByName(String name, T data)
      Returns a value contained in the data by name, e.g., a packet entry.
      Type Parameters:
      V - data type of the value, e.g., Integer or Boolean.
      Parameters:
      name - of the value to access
      data - data to access
      Returns:
      the optional value by name (value might not exits)