Class AbstractNotificationMessage
java.lang.Object
uk.ac.manchester.spinnaker.messages.notification.AbstractNotificationMessage
- All Implemented Interfaces:
NotificationMessage
,SerializableMessage
- Direct Known Subclasses:
DatabaseConfirmation
,PauseStop
,StartResume
public abstract class AbstractNotificationMessage extends Object implements NotificationMessage
A base class for concrete notification messages.
- Author:
- Donal Fellows
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractNotificationMessage(ByteBuffer buffer)
AbstractNotificationMessage(NotificationMessageCode command)
-
Method Summary
Modifier and Type Method Description void
addToBuffer(ByteBuffer buffer)
Writes this message into the given buffer as a contiguous range of bytes.static NotificationMessage
build(ByteBuffer buffer)
Create a notification message instance from a buffer holding a received message.
-
Constructor Details
-
AbstractNotificationMessage
- Parameters:
buffer
- Where to read the command code from. The command code will be in the first two bytes; this constructor advances the buffer position.
-
AbstractNotificationMessage
- Parameters:
command
- The command code of the message.
-
-
Method Details
-
addToBuffer
Description copied from interface:SerializableMessage
Writes this message into the given buffer as a contiguous range of bytes. This is so that a message can be sent. Implementors may assume that the buffer has been configured to be little-endian and that its position is at the point where they should begin writing. Once it has finished, the position should be immediately after the last byte written by this method.Calling this method should not update the internal state of the message. It should be possible to add the message to multiple buffers without special precautions by the caller.
- Specified by:
addToBuffer
in interfaceSerializableMessage
- Parameters:
buffer
- The buffer to write into.
-
build
Create a notification message instance from a buffer holding a received message.- Parameters:
buffer
- The received message data buffer.- Returns:
- The parsed message.
- Throws:
UnsupportedOperationException
- If the message is not understood.
-