gumbo.net.msg
Class Message

java.lang.Object
  |
  +--gumbo.net.msg.Message
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AsciiMessage, TestClientAgent.MsgGraphOpenRequest, TestClientAgent.MsgListOpenRequest, TestClientAgent.MsgTreeOpenRequest, gumbo.visualize.data.TestServerAgent.MsgGraphModel, TestServerAgent.MsgSetClientDataCommand

public abstract class Message
extends java.lang.Object
implements java.io.Serializable

Abstract base class for messages conforming to the Gumbo client-server message protocol. Messages transferred as an object serialize this whole object, which includes the head and any message-specific transferrable (non-static, non-transient) body data. Messages transferred as ASCII must subclass AsciiMessage.

Subclasses must implement message-specific abstract methods (e.g. getBodyVersion()), and should provide message-specific accessors for the message body contents (parameters and data).

See the javadoc for individual messages for details concerning message parameters, data, and usage.

Version:
$Revision: 1.7 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.
See Also:
Serialized Form

Constructor Summary
Message()
          Constructs an empty message with a default head, using defaultHead().
 
Method Summary
protected  void beforeBodyWrite()
          Called just before the message body is written.
protected  void defaultHead()
          Creates and sets the default head for this message.
abstract  java.lang.String getBodyVersion()
          Gets the version for the message body data format.
 MessageHead getHead()
          Gets the head for this message.
 java.lang.String getMessageType()
          Gets the type (fully qualified java class name) of this message.
protected  void setHead(MessageHead head)
          Sets the head for this message.
abstract  java.lang.String toBodyString()
          Creates a new string representing the contents of the message body for status messages.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Message

public Message()
Constructs an empty message with a default head, using defaultHead().

Method Detail

defaultHead

protected void defaultHead()
Creates and sets the default head for this message.


setHead

protected void setHead(MessageHead head)
                throws MessageDataException
Sets the head for this message.

Parameters:
head - Initialized message head. Never null.
Throws:
MessageDataException - Head uninitialized or mismatch between head data and implicit message type or body version.

getHead

public MessageHead getHead()
Gets the head for this message.

Returns:
The message head. Never null.

getMessageType

public java.lang.String getMessageType()
Gets the type (fully qualified java class name) of this message. Used for head creation and head-body verification.


getBodyVersion

public abstract java.lang.String getBodyVersion()
Gets the version for the message body data format. Used for head creation. Never null.


beforeBodyWrite

protected void beforeBodyWrite()
Called just before the message body is written. The default is to do nothing. Override as needed.


toBodyString

public abstract java.lang.String toBodyString()
Creates a new string representing the contents of the message body for status messages. Never null.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object