|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--fipaos.agent.conversation.standard.ConversationImpl
This class represents the notion of a Conversation which is comprised of several Message's, the order of which follow a certain protocol (e.g. FIPA-Request). The methods it provides allow retrieval of information about the conversation, as well as validation of the protocol the conversation is following. This class cannot be instantiated directly, the static method getConversation() should be used to obtain a Conversation instance which will follow the required protocol. Protocol definitions are defined in concrete sub-classes, which map from protocol name to class name as such:
The class name is relative to the package in which this object resides. The sub-class must also define a public static Object[] called __protocol which contains details of the protocol to be followed. The list should contain a list of tuples which follow this format:
{ String performative [, Object conv_state], Integer participant [, Object[] sub_nodes] }
The performative is the type of message recieved at that part of the protocol,
the conv_state is the conversation state when that performative is recieved (one of
NO_AGENT_ACTION_REQ or AGENT_ACTION_REQ, and if none is given CONVERSATION_END is assumed).
The
participant number identifies which participant in the conversation should be sending
that message (the numbers used should be consistent throughout the messages according
to the protocol requirements). The sub_nodes array can contain a list of the same
format to define what messages should be expected after the one defined by the current
list has been received (hence the whole protocol can be defined recursively).
Inner Class Summary | |
static class |
ConversationImpl.ConversationProtocol
Class to contain information about the protocol to be used. |
Field Summary | |
protected AgentID |
_agent_id
Agent-id of the Agent to whom this belongs |
protected java.lang.String |
_protocol
Name of the protocol this conversation is following |
protected ConversationImpl.ConversationProtocol |
_protocol_tree
Protocol that conversations of this type should follow (tree like structure for quick access) |
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 | |
protected |
ConversationImpl()
Generalised constructor |
Method Summary | |
void |
addMessage(Message msg)
Method to add a message to the conversation - sets conversation state to updated as well. |
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 |
static ConversationImpl |
getConversation(java.lang.String protocol,
AgentID agent_name)
Method to dynamically load a Conversation instance which follows the given protocol and belongs to the given Agent |
static ConversationImpl |
getConversation(java.lang.String protocol,
java.lang.String agent_name)
Method to dynamically load a Conversation instance which follows the given protocol and belongs to the given Agent |
java.lang.String |
getConversationID()
Gets the conversation ID of the conversation |
Envelope |
getEnvelope(int index)
Get the Envelope of the latest message received |
ACL |
getFilledInACL()
Method to produce a filled in ACL - e.g. |
int |
getLatestMessageIndex()
Pass back the index of the latest message in the conversation |
ACLMessage |
getMessage(int index)
Deprecated. The ACLMessage object is no longer supported - please use the getACL() and getEnvelope() methods instead |
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()
Method to get unique identifier of this DatabaseObject |
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 |
static void |
main(java.lang.String[] args)
Used for testing. |
static void |
testAddMessages(ConversationImpl conv,
java.lang.String[] data,
boolean cont)
|
static void |
testAddMessages(java.lang.String protocol,
java.lang.String[] data,
boolean cont)
|
static ConversationImpl |
testPopulate(ACLMessage acl,
java.lang.String protocol)
Returns a Conversation object populated with the passed ACLMessage. |
java.lang.String |
toString()
Overrides default toString() |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int CONVERSATION_END
public static final int NO_AGENT_ACTION_REQ
public static final int AGENT_ACTION_REQ
public static final int WAIT_BEFORE_END
protected ConversationImpl.ConversationProtocol _protocol_tree
protected AgentID _agent_id
protected java.lang.String _protocol
Constructor Detail |
protected ConversationImpl()
Method Detail |
public static ConversationImpl getConversation(java.lang.String protocol, java.lang.String agent_name) throws UnknownProtocolException, ParserException
protocol
- FIPA protocol name, null for generic NoProtocol conversation
objectagent_name
- AgentID of the Agent on the local machine who is involved
in this conversationUnknownProtocolException
- Thrown if a Conversation class cannot be
loaded for the given classpublic static ConversationImpl getConversation(java.lang.String protocol, AgentID agent_name) throws UnknownProtocolException
protocol
- FIPA protocol name, null for generic NoProtocol conversation
objectagent_name
- AgentID of the Agent on the local machine who is involved
in this conversationUnknownProtocolException
- Thrown if a Conversation class cannot be
loaded for the given classpublic int getLatestMessageIndex()
getLatestMessageIndex
in interface Conversation
public ACL getACL(int index)
getACL
in interface Conversation
public Envelope getEnvelope(int index)
getEnvelope
in interface Conversation
public ACLMessage getMessage(int index)
index
- The index of the message to retrievepublic java.lang.String getSender(int index)
getSender
in interface Conversation
index
- The index of the message to retrievepublic AgentID getSenderAID(int index)
getSenderAID
in interface Conversation
index
- The index of the message to retrievepublic long getTimeStamp(int index)
getTimeStamp
in interface Conversation
index
- The index of the message for which to retrieve the timestamppublic long getTimeOut()
getTimeOut
in interface Conversation
public java.util.List getNextPerformatives()
getNextPerformatives
in interface Conversation
public java.util.List getNextMessages()
getNextMessages
in interface Conversation
public ACL getFilledInACL()
getFilledInACL
in interface Conversation
public java.lang.String getProtocol()
getProtocol
in interface Conversation
public java.lang.String getConversationID()
getConversationID
in interface Conversation
public int getState()
getState
in interface Conversation
public java.lang.String getObjectID()
getObjectID
in interface DatabaseObject
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Object clone()
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- Thrown if the object cannot be clonedpublic void addMessage(Message msg) throws ProtocolErrorException, InvalidConversationIDException, ConversationFinishedException
mess
- The Message to be addedProtocolErrorException
- Thrown when the message to be added
doesn't follow the correct protocolInvalidConversationIDException
- Thrown when the conversation ID
of the ACLMessage is different
to that of the conversationConversationFinishedException
- Thrown when the conversation has been finishedpublic static void testAddMessages(java.lang.String protocol, java.lang.String[] data, boolean cont) throws java.lang.Throwable
public static void testAddMessages(ConversationImpl conv, java.lang.String[] data, boolean cont)
public static ConversationImpl testPopulate(ACLMessage acl, java.lang.String protocol)
acl
- The ACLMessage to populate the Conversation with.protocol
- A String identifying the protocol object to create.public static void main(java.lang.String[] args) throws java.lang.Throwable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |