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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <V> java.util.Optional<V>getValueByName(java.lang.String name, T data)Returns a value contained in the data by name, e.g., a packet entry.booleanisReply(Command<T> cmd, T replyData)Determines whether the specified data is a reply to the command.TreadData(java.io.InputStream is)Reads data from the specified input stream.voidwriteData(T data, java.io.OutputStream os)Writes data to the specified input stream.
-
-
-
Method Detail
-
readData
T readData(java.io.InputStream is) throws java.io.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:
java.io.IOException- if an I/O error occurs
-
writeData
void writeData(T data, java.io.OutputStream os) throws java.io.IOException
Writes data to the specified input stream.- Parameters:
os- output stream for writing the data- Throws:
java.io.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 commandreplyData- potential reply packet- Returns:
trueif the data is a reply to the command;false otherwise
-
getValueByName
default <V> java.util.Optional<V> getValueByName(java.lang.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 accessdata- data to access- Returns:
- the optional value by name (value might not exits)
-
-