Class KQMLmsg

java.lang.Object
  |
  +--KQMLmsg

public class KQMLmsg
extends java.lang.Object


Constructor Summary
KQMLmsg()
          Empty 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
 int 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.lang.String getContentFieldValue(java.lang.String field, java.lang.String defaultIfEmpty)
          Access method to get a field specified as a parameter from the content field of the KQML-message.
 java.lang.String getContentFieldValue(java.lang.String field, java.lang.String defaultIfEmpty, boolean returnNull)
          Access method to get a field specified as a parameter from the content field of the KQML-message.
 java.util.Hashtable getHashContent()
          Gets the KQML Message Content as a hashtable.
 java.util.Hashtable getKQML()
          Access method to get the whole KQML-message as a Hashtable.
 java.lang.String getKQMLString()
          Get the KQML message as a string.
 java.lang.String getValue(java.lang.String field)
          Access method to get the a field specified as a parameter from the KQML-message.
 java.lang.String getValue(java.lang.String field, java.lang.String defaultIfEmpty)
          Access method to get the a field specified as a parameter from the KQML-message.
 java.lang.String getValue(java.lang.String field, java.lang.String defaultIfEmpty, boolean returnNull)
          Provides functionality for the other two getValue functions.
 java.lang.String toString()
          Returns the object as a valid KQML String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KQMLmsg

public KQMLmsg()
Empty 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

addFieldValuePair

public int 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.
Returns:
0 if all went well, -1 for unknown field, -2 for error in content 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. If the content param is null then the old value of the content field will be kept.

Parameters:
content - The new content to be added to the KQML-message.
Returns:
A String representation of the new KQML-message.

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.

getValue

public java.lang.String getValue(java.lang.String field,
                                 java.lang.String defaultIfEmpty)
Access method to get the a field specified as a parameter from the KQML-message.

Parameters:
field - The name of the field.
defaultIfEmpty - The default value of the field.
Returns:
Value of the field as a String.

getValue

public java.lang.String getValue(java.lang.String field,
                                 java.lang.String defaultIfEmpty,
                                 boolean returnNull)
Provides functionality for the other two getValue functions.

Parameters:
field - The name of field
defaultIfEmpty - The default value of the given field.
returnNull - Wether it should return an empty String or the default given.
Returns:
The field value, or if the field is empty, the default if returnNull is false.

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.

getHashContent

public java.util.Hashtable getHashContent()
Gets the KQML Message Content as a hashtable.

Returns:
The Hashtable with the key value pairs separated and the values stripped of their delimiters.

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.

getContentFieldValue

public java.lang.String getContentFieldValue(java.lang.String field,
                                             java.lang.String defaultIfEmpty)
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.
defaultIfEmpty - The default value of the field.
Returns:
Value of the field as a String.

getContentFieldValue

public java.lang.String getContentFieldValue(java.lang.String field,
                                             java.lang.String defaultIfEmpty,
                                             boolean returnNull)
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.
defaultIfEmpty - The default value of the field.
returnNull - Return the default given or an empty string.
Returns:
Value of the field as a String.

getKQMLString

public java.lang.String getKQMLString()
Get the KQML message as a string. Uses the toString() function. Should probably just use the toString method directly.


toString

public java.lang.String toString()
Returns the object as a valid KQML String.

Overrides:
toString in class java.lang.Object