gumbo.net.msg
Class MessageHead

java.lang.Object
  |
  +--gumbo.net.msg.MessageHead
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AsciiMessageHead

public class MessageHead
extends java.lang.Object
implements java.io.Serializable

Class containing the message head, which is standard for all message types. A message head can be initialized either upon construction, for subsequent writing to a stream, or when read from a stream.

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

Field Summary
protected  java.lang.String _bodyVersion
           
protected  java.lang.String _headVersion
           
protected  java.lang.String _messageType
           
protected  long _sourceTime
           
protected  long _targetTime
           
static java.lang.String HEAD_VERSION
          Head version: Version of constructed message heads.
 
Constructor Summary
MessageHead()
          Constructs a head that is empty except for the head version.
MessageHead(java.lang.String messageType, java.lang.String bodyVersion)
          Constructs a head that is empty except for the head version, message type, and body version.
 
Method Summary
protected  void afterHeadRead()
          Called just after the message head is read.
protected  void beforeHeadWrite()
          Called just before the message head is written.
 java.lang.String getBodyVersion()
          Gets the version for the message body data format.
 java.lang.String getHeadVersion()
          Gets the version for the message head data format.
 java.lang.String getMessageType()
          Gets the type of this message, which is its fully qualified java class name.
 long getSourceTime()
          Gets the time at which the source started writing the message head, expressed in milliseconds since January 1, 1970, 0:00:00 GMT.
 long getTargetTime()
          Gets the time at which the target finished reading the message head, expressed in milliseconds since January 1, 1970, 0:00:00 GMT.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HEAD_VERSION

public static final java.lang.String HEAD_VERSION
Head version: Version of constructed message heads.

See Also:
Constant Field Values

_targetTime

protected transient long _targetTime

_headVersion

protected java.lang.String _headVersion

_messageType

protected java.lang.String _messageType

_sourceTime

protected long _sourceTime

_bodyVersion

protected java.lang.String _bodyVersion
Constructor Detail

MessageHead

public MessageHead()
Constructs a head that is empty except for the head version. Note that this no-parameter constructor is needed for object serialization.


MessageHead

public MessageHead(java.lang.String messageType,
                   java.lang.String bodyVersion)
Constructs a head that is empty except for the head version, message type, and body version.

Parameters:
messageType - Fully qualified java class name of the message. Never null.
bodyVersion - Message body version. Never null.
Method Detail

getMessageType

public java.lang.String getMessageType()
Gets the type of this message, which is its fully qualified java class name. Null if not yet initialized.


getBodyVersion

public java.lang.String getBodyVersion()
Gets the version for the message body data format. Null if not yet initialized.


getHeadVersion

public java.lang.String getHeadVersion()
Gets the version for the message head data format. Set internally. Never null.


getSourceTime

public long getSourceTime()
Gets the time at which the source started writing the message head, expressed in milliseconds since January 1, 1970, 0:00:00 GMT. Set internally. -1 if not yet initialized.


getTargetTime

public long getTargetTime()
Gets the time at which the target finished reading the message head, expressed in milliseconds since January 1, 1970, 0:00:00 GMT. Set internally. -1 if not yet initialized.


afterHeadRead

protected void afterHeadRead()
Called just after the message head is read. Sets the target time.


beforeHeadWrite

protected void beforeHeadWrite()
Called just before the message head is written. Sets the source time.


toString

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