fipaos.agent.conversation.lightweight
Class LightweightConversationImpl

java.lang.Object
  |
  +--fipaos.agent.conversation.lightweight.LightweightConversationImpl
All Implemented Interfaces:
java.lang.Cloneable, Conversation, DatabaseObject, java.io.Serializable

public class LightweightConversationImpl
extends java.lang.Object
implements Conversation

This class is an lighter alternative implementation to the heavy ConversationImpl. Functionality is also more limited, protocols are not enforced, although there is intention for doing this in the future. All use that depends on the protocol enforcing missing will be working as a side effect only.

See Also:
Serialized Form

Field Summary
protected  AgentID _agent_id
          Agent-id of the Agent to whom this belongs
protected  java.lang.String _agent_name
          Agent-name of the Agent to whom this Conversation object belongs
protected  java.lang.String _protocol
          Name of the protocol this conversation is following
static int AGENT_ACTION_REQ
          Conversation requires Agent interaction
static int CONVERSATION_END
          Conversation has ended
static int NO_AGENT_ACTION_REQ
          Conversation requires no Agent interaction
static int WAIT_BEFORE_END
          Wait for response before ending conversation
 
Constructor Summary
LightweightConversationImpl()
          This consctructor creates a new LightweightConversationImpl object.
LightweightConversationImpl(java.lang.String protocol, AgentID agent_id)
           
 
Method Summary
 java.lang.Object clone()
          Clone method to make duplicates of this Conversation object
 ACL getACL(int index)
          Pass-back the latest message in this conversation.
 java.lang.String getConversationID()
          Returns the conversation id for this conversation.
 Envelope getEnvelope(int index)
          Get the Envelope of a message received.
 ACL getFilledInACL()
          Method to produce a filled in ACL - e.g.
 ACLMessage getFilledInMessage()
          Deprecated. The ACL object should be used in favour of the ACLMessage object, hence the getFilledInACL() should be used in preference to this
 int getLatestMessageIndex()
          Pass back the index of the latest message in the conversation.
 java.util.List getNextMessages()
          Method to discover what types of messages can be sent next.
 java.util.List getNextPerformatives()
          Method to discover what performatives are allowed next in the protocol.
 java.lang.String getObjectID()
          Gets the conversation ID of the conversation.
 java.lang.String getProtocol()
          Method to get the protocol this Conversation is following.
 java.lang.String getSender(int index)
          Gets the sender of the message at the specified index.
 AgentID getSenderAID(int index)
          Gets the sender of the message at the specified index
 int getState()
          Method to retrieve the state of the conversation (e.g.
 long getTimeOut()
          Method to get the time at which the last message will time out
 long getTimeStamp(int index)
          Method to retrieve the time stamp of a given message
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_agent_id

protected AgentID _agent_id
Agent-id of the Agent to whom this belongs

_agent_name

protected java.lang.String _agent_name
Agent-name of the Agent to whom this Conversation object belongs

_protocol

protected java.lang.String _protocol
Name of the protocol this conversation is following

AGENT_ACTION_REQ

public static final int AGENT_ACTION_REQ
Conversation requires Agent interaction

CONVERSATION_END

public static final int CONVERSATION_END
Conversation has ended

NO_AGENT_ACTION_REQ

public static final int NO_AGENT_ACTION_REQ
Conversation requires no Agent interaction

WAIT_BEFORE_END

public static final int WAIT_BEFORE_END
Wait for response before ending conversation
Constructor Detail

LightweightConversationImpl

public LightweightConversationImpl()
This consctructor creates a new LightweightConversationImpl object.

LightweightConversationImpl

public LightweightConversationImpl(java.lang.String protocol,
                                   AgentID agent_id)
Method Detail

getLatestMessageIndex

public int getLatestMessageIndex()
Pass back the index of the latest message in the conversation.
Specified by:
getLatestMessageIndex in interface Conversation
Returns:
Index of the latest message, or -1 if there are no messages in this conversation

getACL

public ACL getACL(int index)
Pass-back the latest message in this conversation.
Specified by:
getACL in interface Conversation
Parameters:
index - index of the message in the message list
Returns:
the ACL message of the given index

getEnvelope

public Envelope getEnvelope(int index)
Get the Envelope of a message received.
Specified by:
getEnvelope in interface Conversation
Parameters:
index - index of the message the envelope belongs to
Returns:
the envelope of the message

getSender

public java.lang.String getSender(int index)
Gets the sender of the message at the specified index.
Specified by:
getSender in interface Conversation
Parameters:
index - The index of the message to retrieve
Returns:
The name of the sender of the message at the given index, or null if no such message exists

getConversationID

public java.lang.String getConversationID()
Returns the conversation id for this conversation.
Specified by:
getConversationID in interface Conversation
Returns:
the current conversation id

getFilledInACL

public ACL getFilledInACL()
Method to produce a filled in ACL - e.g. sender, conversation ID and protocol fields will be set appropriately for the conversation
Specified by:
getFilledInACL in interface Conversation
Returns:
The filled in ACL object

getFilledInMessage

public ACLMessage getFilledInMessage()
Deprecated. The ACL object should be used in favour of the ACLMessage object, hence the getFilledInACL() should be used in preference to this

Method to produce a filled in ACLMessage - e.g. sender, conversation ID and protocol fields will be set appropriately for the conversation
Returns:
The filled in ACLMessage object

getNextMessages

public java.util.List getNextMessages()
Method to discover what types of messages can be sent next. This returns null since protocols are not forced.
Specified by:
getNextMessages in interface Conversation
Returns:
A list of possible ACLMessage's which could be sent next, or return an empty list if none can

getNextPerformatives

public java.util.List getNextPerformatives()
Method to discover what performatives are allowed next in the protocol. This returns null since protocols are not forced.
Specified by:
getNextPerformatives in interface Conversation
Returns:
A list of performatives, or an empty list if no messages can be sent next

getObjectID

public java.lang.String getObjectID()
Gets the conversation ID of the conversation.
Specified by:
getObjectID in interface DatabaseObject
Returns:
The String representation of the Conversation's ID, or null if one has not been assigned

getProtocol

public java.lang.String getProtocol()
Method to get the protocol this Conversation is following.
Specified by:
getProtocol in interface Conversation
Returns:
the protocol

getSenderAID

public AgentID getSenderAID(int index)
Gets the sender of the message at the specified index
Specified by:
getSenderAID in interface Conversation
Parameters:
index - The index of the message to retrieve
Returns:
The id of the sender of the message at the given index, or null if no such message exists

getState

public int getState()
Method to retrieve the state of the conversation (e.g. does the conversation require agent input)
Specified by:
getState in interface Conversation
Returns:
One of NO_AGENT_ACTION_REQ, AGENT_ACTION_REQ or CONVERSATION_END

getTimeOut

public long getTimeOut()
Method to get the time at which the last message will time out
Specified by:
getTimeOut in interface Conversation
Returns:
The time the message will time out in milliseconds since 1/1/1970 0:00 GMT, or -1 if there is no timeout associated with the last message

getTimeStamp

public long getTimeStamp(int index)
Method to retrieve the time stamp of a given message
Specified by:
getTimeStamp in interface Conversation
Parameters:
index - The index of the message for which to retrieve the timestamp
Returns:
The time the message was added in milliseconds since 1/1/1970 0:00 GMT, or -1 if no such message exists

clone

public java.lang.Object clone()
Clone method to make duplicates of this Conversation object
Overrides:
clone in class java.lang.Object
Returns:
An independant copy of this Conversation object
Throws:
java.lang.CloneNotSupportedException - Thrown if the object cannot be cloned