public abstract class Message<T extends java.lang.Enum<T>> extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
protected abstract void |
doRead(java.io.DataInputStream stream,
int version)
Subclasses should implement this method to read the data this message
object contains.
|
T |
getType() |
int |
getVersion() |
void |
read(java.io.DataInputStream stream)
Reads the message version and than calls
doRead . |
void |
write(java.io.DataOutputStream stream)
Writes the message type and version to the stream.
|
public int getVersion()
public void write(java.io.DataOutputStream stream) throws java.io.IOException, NewerMessageVersionException
stream
- java.io.IOException
NewerMessageVersionException
public void read(java.io.DataInputStream stream) throws java.io.IOException, NewerMessageVersionException
doRead
. The message type id
not read because it must be read before to decide which message object to create.stream
- the stream to read the data fromjava.io.IOException
NewerMessageVersionException
- if a version newer than the version
of this class is readprotected abstract void doRead(java.io.DataInputStream stream, int version) throws java.io.IOException
stream
- the stream to read the data fromversion
- the version which was read (smaller or equal to the
version of this class)java.io.IOException