Package eu.mihosoft.devcom
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 TypeMethodDescriptiondefault <V> Optional<V>
getValueByName
(String name, T data) Returns a value contained in the data by name, e.g., a packet entry.boolean
Determines whether the specified data is a reply to the command.readData
(InputStream is) Reads data from the specified input stream.void
writeData
(T data, OutputStream os) Writes data to the specified input stream.
-
Method Details
-
readData
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
Writes data to the specified input stream.- Parameters:
os
- output stream for writing the data- Throws:
IOException
- if an I/O error occurs
-
isReply
Determines whether the specified data is a reply to the command.- Parameters:
cmd
- the commandreplyData
- potential reply packet- Returns:
true
if the data is a reply to the command;false otherwise
-
getValueByName
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 accessdata
- data to access- Returns:
- the optional value by name (value might not exits)
-