fipaos.agent.conversation.lightweight
Class LightweightConversationImpl


public class LightweightConversationImpl
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.

todo protocol enforcement

Inner Class Summary
 (package private) classLightweightConversationImpl.MessageDetails
          Class to contain information about a message

Field Summary
 final static intAGENT_ACTION_REQ
          Conversation requires Agent interaction
 final static intCONVERSATION_END
          Conversation has ended
 final static intNO_AGENT_ACTION_REQ
          Conversation requires no Agent interaction
 final static intWAIT_BEFORE_END
          Wait for response before ending conversation

Constructor Summary
LightweightConversationImpl()
          This consctructor creates a new LightweightConversationImpl object.
LightweightConversationImpl(String protocol, AgentID agent_id)
           

Method Summary
 (package private) voidaddMessage(Message message)
          This method is for the ConversationManager to add messages into the Conversation.
 synchronized Objectclone()
          Clone method to make duplicates of this Conversation object
 (package private) synchronized LightweightConversationImplcloneAndResetUpdate()
          Creates a copy of this Conversation object, and sets the update state to false
 fipaos.ont.fipa.ACLgetACL(int index)
          Pass-back the latest message in this conversation.
 java.lang.StringgetConversationID()
          Returns the conversation id for this conversation.
 fipaos.ont.fipa.fipaman.EnvelopegetEnvelope(int index)
          Get the Envelope of a message received.
 fipaos.ont.fipa.ACLgetFilledInACL()
          Method to produce a filled in ACL - e.g.
 intgetLatestMessageIndex()
          Pass back the index of the latest message in the conversation.
 java.util.ListgetNextMessages()
          Method to discover what types of messages can be sent next.
 java.util.ListgetNextPerformatives()
          Method to discover what performatives are allowed next in the protocol.
 java.lang.StringgetObjectID()
          Gets the conversation ID of the conversation.
 java.lang.StringgetProtocol()
          Method to get the protocol this Conversation is following.
 java.lang.StringgetSender(int index)
          Gets the sender of the message at the specified index.
 fipaos.ont.fipa.fipaman.AgentIDgetSenderAID(int index)
          Gets the sender of the message at the specified index
 intgetState()
          Method to retrieve the state of the conversation (e.g.
 longgetTimeOut()
          Method to get the time at which the last message will time out
 longgetTimeStamp(int index)
          Method to retrieve the time stamp of a given message
 (package private) synchronized booleanisUpdated()
          Checks if the conversation has been updated.
 (package private) synchronized voidremoveReferences()
          Sets all references to null to aid garbage collection - ONLY USE WHEN OBJECT HAS BEEN FINISHED WITH!
 (package private) synchronized voidresetUpdate()
          Resets the update flag to false.
 (package private) voidsetConversationID(String conv_id)
          Sets the conversation ID of the Conversation - should only be called directly after creation of a Conversation object from the ConversationManagerImpl

Field Detail

AGENT_ACTION_REQ

public final static int AGENT_ACTION_REQ
Conversation requires Agent interaction

CONVERSATION_END

public final static int CONVERSATION_END
Conversation has ended

NO_AGENT_ACTION_REQ

public final static int NO_AGENT_ACTION_REQ
Conversation requires no Agent interaction

WAIT_BEFORE_END

public final static 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(String protocol, AgentID agent_id)
Method Detail

addMessage

void addMessage(Message message)
throws fipaos.agent.conversation.InvalidConversationIDException
This method is for the ConversationManager to add messages into the Conversation.
Parameters:
message - message to be added
Throws:
InvalidConversationIDException - if the message has a conversation id not belonging to this conversation

clone

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

cloneAndResetUpdate

synchronized LightweightConversationImpl cloneAndResetUpdate()
Creates a copy of this Conversation object, and sets the update state to false
Returns: A copy of the current Conversation, with update state set to false

getACL

public fipaos.ont.fipa.ACL getACL(int index)
Pass-back the latest message in this conversation.
Parameters:
index - index of the message in the message list
Returns: the ACL message of the given index

getConversationID

public java.lang.String getConversationID()
Returns the conversation id for this conversation.
Returns: the current conversation id

getEnvelope

public fipaos.ont.fipa.fipaman.Envelope getEnvelope(int index)
Get the Envelope of a message received.
Parameters:
index - index of the message the envelope belongs to
Returns: the envelope of the message

getFilledInACL

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

getLatestMessageIndex

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

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.
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.
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.
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.
Returns: the protocol

getSender

public java.lang.String getSender(int index)
Gets the sender of the message at the specified index.
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

getSenderAID

public fipaos.ont.fipa.fipaman.AgentID getSenderAID(int index)
Gets the sender of the message at the specified index
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)
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
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
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

isUpdated

synchronized boolean isUpdated()
Checks if the conversation has been updated.
Returns: True if the conversation has been updated

removeReferences

synchronized void removeReferences()
Sets all references to null to aid garbage collection - ONLY USE WHEN OBJECT HAS BEEN FINISHED WITH!

resetUpdate

synchronized void resetUpdate()
Resets the update flag to false.

setConversationID

void setConversationID(String conv_id)
Sets the conversation ID of the Conversation - should only be called directly after creation of a Conversation object from the ConversationManagerImpl
Parameters:
conv_id - The Conversation ID that this Conversation object should use

Association Links

to Class fipaos.ont.fipa.fipaman.AgentID

Agent-id of the Agent to whom this belongs

to Class java.lang.String

Agent-name of the Agent to whom this Conversation object belongs

to Class java.lang.String

Conversation ID of this Conversation

to Class java.util.List

Contains the list of MessageDetails

to Class fipaos.ont.fipa.fipaman.AgentID

Other Agent in the conversations'

to Class java.lang.String

Name of the protocol this conversation is following

to Class java.lang.Object

Helps to indicate if this is a deserialised object