Class KQMLmsg

java.lang.Object
  |
  +--KQMLmsg

class KQMLmsg
extends java.lang.Object

Project: DECAF
Class: KQMLmsg
Description: This class is meant to be a container class for a KQML-message.


Field Summary
protected  java.util.Hashtable content
           
protected  java.util.Hashtable kqml
           
protected  java.lang.String[] kqmlFields
           
 
Constructor Summary
KQMLmsg()
          Empty default constructor.
KQMLmsg(java.lang.String message)
          Constructor that creates a new KQML-message instance based on KQML-message string passed as parameter.
KQMLmsg(java.lang.String performative, java.lang.String sender, java.lang.String receiver, java.lang.String ontology, java.lang.String language, java.lang.String inReplyTo, java.lang.String replyWith, java.lang.String content)
          Constructor with the KQML-fields as parameters.
 
Method Summary
 void addFieldValuePair(java.lang.String field, java.lang.String value)
          Access method to add a new field into the KQML-message.
 java.lang.String constructSendString(java.lang.String content)
          This method is used for exchanging the sender and receiver field values.
 java.lang.String getContentFieldValue(java.lang.String field)
          Access method to get a field specified as a parameter from the content field of the KQML-message.
 java.util.Hashtable getHashContent()
          Access method to get the whole content of the KQML-message as a Hashtable.
 java.util.Hashtable getKQML()
          Access method to get the whole KQML-message as a Hashtable.
 java.lang.String getKQMLString()
          Access method to get the string representation of the KQML-message.
 java.lang.String getValue(java.lang.String field)
          Access method to get the a field specified as a parameter from the KQML-message.
protected  void initKQMLFields()
          This method is for the KQMLmsg-classes' own use.
protected  java.util.Hashtable parseKQML(java.lang.String message)
          This method is for the KQMLmsg-classes' own use.
 java.lang.String toString()
          Makes it possible to print out the KQML-message as a String.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

kqml

protected java.util.Hashtable kqml

content

protected java.util.Hashtable content

kqmlFields

protected java.lang.String[] kqmlFields
Constructor Detail

KQMLmsg

public KQMLmsg()
Empty default constructor.

KQMLmsg

public KQMLmsg(java.lang.String performative,
               java.lang.String sender,
               java.lang.String receiver,
               java.lang.String ontology,
               java.lang.String language,
               java.lang.String inReplyTo,
               java.lang.String replyWith,
               java.lang.String content)
Constructor with the KQML-fields as parameters.
Parameters:
performative - Performative in KQML-message
sender - Sender in KQML-message
receiver - Receiver in KQML-message
ontology - Ontology in KQML-message
language - Language in KQML-message
inReplyTo - In-reply-to in KQML-message
replyWith - Reply-with in KQML-message
content - Content in KQML-message

KQMLmsg

public KQMLmsg(java.lang.String message)
Constructor that creates a new KQML-message instance based on KQML-message string passed as parameter.
Parameters:
message - A String representation of the KQML-message.
Method Detail

getValue

public java.lang.String getValue(java.lang.String field)
Access method to get the a field specified as a parameter from the KQML-message.
Parameters:
field - The name of the field.
Returns:
Value of the field as a String.

getContentFieldValue

public java.lang.String getContentFieldValue(java.lang.String field)
Access method to get a field specified as a parameter from the content field of the KQML-message.
Parameters:
field - The name of the field.
Returns:
Value of the field as a String.

getHashContent

public java.util.Hashtable getHashContent()
Access method to get the whole content of the KQML-message as a Hashtable.
Returns:
A Hashtable containing the field names as keys.

getKQMLString

public java.lang.String getKQMLString()
Access method to get the string representation of the KQML-message.
Returns:
A String representing the KQML-message.

getKQML

public java.util.Hashtable getKQML()
Access method to get the whole KQML-message as a Hashtable.
Returns:
A Hashtable containing the field names as keys.

addFieldValuePair

public void addFieldValuePair(java.lang.String field,
                              java.lang.String value)
Access method to add a new field into the KQML-message.
Parameters:
field - The field name.
value - The value of the field.

constructSendString

public java.lang.String constructSendString(java.lang.String content)
This method is used for exchanging the sender and receiver field values. It also adds the content field passed as parameter to the KQML-message.
Parameters:
content - The new content to be added to the KQML-message.
Returns:
A String representation of the new KQML-message.

toString

public java.lang.String toString()
Makes it possible to print out the KQML-message as a String.
Overrides:
toString in class java.lang.Object
Returns:
A String representing the KQML-message.

initKQMLFields

protected void initKQMLFields()
This method is for the KQMLmsg-classes' own use. It initializes the KQML-fields of the class.

parseKQML

protected java.util.Hashtable parseKQML(java.lang.String message)
This method is for the KQMLmsg-classes' own use. It parses a String representing a KQML-message and constructs a internal Hashtable for the KQMLmsg-class.
Parameters:
message - A String representation of the KQML-message.
Returns:
A Hashtable that contains the field names as keys.