public class ChatMessage extends Object
ChatMessage
is a simple class that is used to store one chat message that has been recieved by a ChatAgent
. It is usually used in a Vector
containing several messages, and the toString()
function is designed to be used in JList
s and other visual interfaces. Copyright: Copyright 2003-2014, Knowledge Science Group, University of Calgary. Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. The Knowledge Science Group makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.
ChatAgent
Modifier and Type | Field and Description |
---|---|
private URLDescriptor |
cd
Stores the
URLDescriptor of the cooperation domain that this message was sent through. |
private boolean |
directed
Determines whether this message was a "directed" message.
|
private String |
message
Stores the actual text of the chat message.
|
private Vector<URLDescriptor> |
recipients
Stores a
Vector containing the recipients (URLDescriptor s) of the message. |
private URLDescriptor |
sender
Stores the
URLDescriptor of the sender of the message. |
private boolean |
whisper
Determines whether this message was a "whisper".
|
Constructor and Description |
---|
ChatMessage(MLMessage message,
URLDescriptor cd)
Creates a new
ChatMessage from the given
MLMessage and the given cooperation domain. |
ChatMessage(String message,
URLDescriptor sender,
URLDescriptor cd)
Creates a new
ChatMessage that is not a "directed" message or
a "whisper" with the given message text, sender, and cooperation domain. |
Modifier and Type | Method and Description |
---|---|
URLDescriptor |
getCD()
Retrieves the cooperation domain of the chat message.
|
String |
getMessage()
Retrieves the actual text of the chat message.
|
Vector |
getRecipients()
Retrieves the list of recipients of the message, or
null if the message is not "directed". |
URLDescriptor |
getSender()
Retrieves the sender of the chat message as a
URLDescriptor . |
boolean |
isDirected()
Retrieves whether the message is "directed".
|
boolean |
isWhisper()
Retrieves whether the message is a "whisper".
|
void |
setCD(URLDescriptor cd)
Sets the cooperation domain of the chat message.
|
void |
setDirected(Vector<URLDescriptor> recipients)
Sets the message so that it is "directed" with the specified recipients.
|
void |
setMessage(String message)
Sets the actual text of the chat message.
|
void |
setRecipients(Vector<URLDescriptor> recipients)
Sets the list of recipients of the message.
|
void |
setSender(URLDescriptor sender)
Sets the sender of the chat message as a
URLDescriptor . |
void |
setWhisper(Vector<URLDescriptor> recipients)
Sets the message so that it is a "whisper" with the specified exclusive
recipients.
|
String |
toString()
Returns the chat message as a string suitable to use in a user interface.
|
void |
unsetDirected()
Sets the message so that it is not "directed".
|
void |
unsetWhisper()
Sets the message so that it is not a "whisper".
|
private String message
private URLDescriptor sender
URLDescriptor
of the sender of the message.private boolean directed
true
if the message was directed to one or more specified agents; false
otherwise.private boolean whisper
true
if the message was sent exclusivly to one or more specified agents; false
otherwise. This can only be true
if the message is "directed".private Vector<URLDescriptor> recipients
Vector
containing the recipients (URLDescriptor
s) of the message. This is null
if the message is not "directed".private URLDescriptor cd
URLDescriptor
of the cooperation domain that this message was sent through.public ChatMessage(String message, URLDescriptor sender, URLDescriptor cd)
ChatMessage
that is not a "directed" message or
a "whisper" with the given message text, sender, and cooperation domain.message
- The actual text of the chat message.sender
- The URLDescriptor
of the sender of the message.cd
- The URLDescriptor
of the cooperation domain that
this message was sent through.public ChatMessage(MLMessage message, URLDescriptor cd)
ChatMessage
from the given
MLMessage
and the given cooperation domain. The details of
the message are arll retrieved from the MLMessage
.message
- An MLMessage
containing both the actual text
of the message, the sender of the message, whether the message is a
"directed" message or a "whisper", and who the message was to if it was
"directed".cd
- The URLDescriptor
of the cooperation domain that
this message was sent through.public String getMessage()
public void setMessage(String message)
message
- The actual text of the chat message.public URLDescriptor getSender()
URLDescriptor
.URLDescriptor
.public void setSender(URLDescriptor sender)
URLDescriptor
.sender
- The sender of the chat message as a URLDescriptor
.public boolean isDirected()
true
if the message was directed to one or more specified agents; false
otherwise.true
if the message was directed to one or more specified agents; false
otherwise.public boolean isWhisper()
true
if the message was sent exclusivly to one or more specified agents; false
otherwise.true
if the message was sent exclusivly to one or more specified agents; false
otherwise.public void setDirected(Vector<URLDescriptor> recipients)
recipients
- A Vector
containing the recipients
(URLDescriptor
s) of the message.public void unsetDirected()
null
.public void setWhisper(Vector<URLDescriptor> recipients)
recipients
- A Vector
containing the exclusive
recipients (URLDescriptor
s) of the message.public void unsetWhisper()
public Vector getRecipients()
null
if the message is not "directed".Vector
containing the recipients (URLDescriptor
s) of the message, or null
if the message is not "directed".public void setRecipients(Vector<URLDescriptor> recipients)
recipients
- A Vector
containing the recipients (URLDescriptor
s) of the message.public URLDescriptor getCD()
public void setCD(URLDescriptor cd)
cd
- The cooperation domain of the chat message.public String toString()