gumbo.net.msg.ascii
Class AsciiMessageHead

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

public class AsciiMessageHead
extends MessageHead

Subclass of MessageHead containing all aspects of ASCII transport of a message head.

When a message is received via ASCII transport its type is unknown until the head is read. Once the head is read, a message object of the type specified by the head can be created (using the factory method in the AsciiMessage class), and the rest of the message, i.e. the body (parameters and data), can then be read from the stream by that message object.

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

Field Summary
 
Fields inherited from class gumbo.net.msg.MessageHead
_bodyVersion, _headVersion, _messageType, _sourceTime, _targetTime, HEAD_VERSION
 
Constructor Summary
AsciiMessageHead(AsciiMessageReader reader)
          Constructs a head and initializes its contents by reading a complete message head unit from a message reader.
AsciiMessageHead(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
 AsciiMessageReader getAsciiReader()
          Gets the message reader for this head.
 AsciiMessageWriter getAsciiWriter()
          Gets the message writer for this head.
 void readAsciiHead(AsciiMessageReader reader)
          Sets the reader and reads this head as a complete message head unit from a message reader.
 void writeAsciiHead(AsciiMessageWriter writer, java.lang.String bodyVersion)
          Sets the writer and writes this head as a complete message head unit to a message writer.
 
Methods inherited from class gumbo.net.msg.MessageHead
afterHeadRead, beforeHeadWrite, getBodyVersion, getHeadVersion, getMessageType, getSourceTime, getTargetTime, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AsciiMessageHead

public AsciiMessageHead(AsciiMessageReader reader)
                 throws java.io.IOException,
                        MessageIOException
Constructs a head and initializes its contents by reading a complete message head unit from a message reader. Blocks until the head is read.

Throws:
MessageIOException - Reader not at message head, or bad message head format.
java.io.IOException

AsciiMessageHead

public AsciiMessageHead(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

readAsciiHead

public void readAsciiHead(AsciiMessageReader reader)
                   throws java.io.IOException,
                          MessageIOException
Sets the reader and reads this head as a complete message head unit from a message reader. Blocks until the head is read.

Throws:
MessageIOException - Reader not at message head, or bad message head format.
java.io.IOException

writeAsciiHead

public void writeAsciiHead(AsciiMessageWriter writer,
                           java.lang.String bodyVersion)
                    throws java.io.IOException,
                           MessageIOException
Sets the writer and writes this head as a complete message head unit to a message writer. Blocks until the head is written.

Parameters:
writer - The message writer. Never null.
bodyVersion - The version of the message body data. Never null.
Throws:
java.io.IOException - No writer.
MessageIOException - Writer not at message head.

getAsciiReader

public AsciiMessageReader getAsciiReader()
Gets the message reader for this head.

Returns:
The message reader used to read this head. Null if none (i.e. the head was initialized, not read).

getAsciiWriter

public AsciiMessageWriter getAsciiWriter()
Gets the message writer for this head.

Returns:
The message writer last used to write the head. Null if none (i.e. the head has not yet been written).