uk.ac.rdg.resc.jstyx.messages
Class TversionMessage

java.lang.Object
  extended by uk.ac.rdg.resc.jstyx.messages.StyxMessage
      extended by uk.ac.rdg.resc.jstyx.messages.TversionMessage

public class TversionMessage
extends StyxMessage

Message sent to negotiate the protocol version and maximum message size of a Styx Connection

Author:
Jon Blower $Revision: 507 $ $Date: 2005-12-01 08:21:56 +0000 (Thu, 01 Dec 2005) $ $Log$ Revision 1.5 2005/12/01 08:21:56 jonblower Fixed javadoc comments Revision 1.4 2005/03/15 09:01:48 jonblower Message type now stored as short, not int Revision 1.3 2005/03/11 14:02:16 jonblower Merged MINA-Test_20059309 into main line of development Revision 1.2.2.1 2005/03/10 11:50:59 jonblower Changed to fit with MINA framework Revision 1.1 2005/03/09 16:58:42 jonblower Changes to MINA-related classes Revision 1.2 2005/02/24 07:44:44 jonblower Added getFriendlyString() Revision 1.1.1.1 2005/02/16 18:58:29 jonblower Initial import

Field Summary
 
Fields inherited from class uk.ac.rdg.resc.jstyx.messages.StyxMessage
buf, length, lock, name, tag, type
 
Constructor Summary
TversionMessage()
          Default constructor, sets version to "9P2000" and maximum message size to 8216 (so that 8192 bytes can be read or written with a Tread/Twrite)
TversionMessage(int length, short type, int tag)
          Creates a new TversionMessage.
TversionMessage(long maxMessageSize)
          Creates a new TversionMessage, with the supplied maximum message size.
TversionMessage(long maxMessageSize, java.lang.String protocolVersion)
          Creates a new TversionMessage, with the supplied maximum message size and version string.
 
Method Summary
protected  void decodeBody(StyxBuffer styxBuf)
          Called when a complete message has arrived; signals that we are ready to interpret the raw bytes in the buffer and turn them into meaningful information.
protected  void encodeBody(StyxBuffer styxBuf)
          Encode the body of the message into bytes in the underlying buffer
protected  java.lang.String getElements()
           
 long getMaxMessageSize()
           
 java.lang.String getVersion()
           
 void setMaxMessageSize(long maxMessageSize)
           
 void setVersion(java.lang.String version)
           
 java.lang.String toFriendlyString()
           
 
Methods inherited from class uk.ac.rdg.resc.jstyx.messages.StyxMessage
createStyxMessage, dispose, encode, getBuffer, getFid, getLength, getName, getTag, getType, readBytesFrom, setTag, toString, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TversionMessage

public TversionMessage(int length,
                       short type,
                       int tag)
Creates a new TversionMessage. This constructor will be called by the StyxMessage.createStyxMessage() method

Parameters:
length - The total length of the message (including all header info)
type - The type of the message (a number between 100 and 127)
tag - The tag that identifies this message

TversionMessage

public TversionMessage()
Default constructor, sets version to "9P2000" and maximum message size to 8216 (so that 8192 bytes can be read or written with a Tread/Twrite)


TversionMessage

public TversionMessage(long maxMessageSize)
Creates a new TversionMessage, with the supplied maximum message size. Sets the version to "9P2000"

Parameters:
maxMessageSize - The requested maximum size of a message that will be sent on this connection by either party

TversionMessage

public TversionMessage(long maxMessageSize,
                       java.lang.String protocolVersion)
Creates a new TversionMessage, with the supplied maximum message size and version string. Note that the version string should always be "9P2000"; this constructor is used mainly for debugging.

Parameters:
maxMessageSize - The requested maximum size of a message that will be sent on this connection by either party
protocolVersion - The version string (Should always be "9P2000")
Method Detail

decodeBody

protected final void decodeBody(StyxBuffer styxBuf)
Description copied from class: StyxMessage
Called when a complete message has arrived; signals that we are ready to interpret the raw bytes in the buffer and turn them into meaningful information. Subclasses should make sure that the buffer is no longer needed once this method has finished, as the underlying buffer will be reused.

Specified by:
decodeBody in class StyxMessage

encodeBody

protected final void encodeBody(StyxBuffer styxBuf)
Description copied from class: StyxMessage
Encode the body of the message into bytes in the underlying buffer

Specified by:
encodeBody in class StyxMessage

getMaxMessageSize

public long getMaxMessageSize()
Returns:
The requested maximum size of a message that will be sent on this connection by either party

setMaxMessageSize

public void setMaxMessageSize(long maxMessageSize)
Parameters:
maxMessageSize - The requested maximum size of a message that will be sent on this connection by either party

getVersion

public java.lang.String getVersion()
Returns:
The version string (normally "9P2000")

setVersion

public void setVersion(java.lang.String version)
Parameters:
version - The version string (normally "9P2000")

getElements

protected java.lang.String getElements()
Specified by:
getElements in class StyxMessage
Returns:
the body elements of this message as a string

toFriendlyString

public java.lang.String toFriendlyString()
Overrides:
toFriendlyString in class StyxMessage
Returns:
a human-readable string that displays the contents of the message, without the header info. This default implementation simply calls this.getElements(): subclasses should override this behaviour


Copyright © 2004-2006 Reading e-Science Centre. All Rights Reserved.