fr.lifl.magique
Class Request

java.lang.Object
  extended byfr.lifl.magique.Request
All Implemented Interfaces:
java.lang.Cloneable, Message, java.io.Serializable

public class Request
extends java.lang.Object
implements java.lang.Cloneable, Message

Requests are the basic message object between agents. A request can be an order or a question if answer is required. It is composed of a text (a string) and possibly a vector of args for the request. Args must be serializable. Typically text is the name of a method (maybe with args) that will be invoked (or forwarded for invocation by someone else) by the recipient.

See Also:
Serializable, Agent, Serialized Form

Constructor Summary
Request()
          request with just a text : to transmit simple messages
Request(java.lang.String text)
          request with just a text : to transmit simple messages
Request(java.lang.String sender, boolean isQuestion, java.lang.String text)
          creates a request without args
Request(java.lang.String sender, boolean isQuestion, java.lang.String text, java.lang.Object[] params)
          creates a request wit args
 
Method Summary
 void addToPath(java.lang.String agentName)
          adds an agent to path (at the end)
 java.lang.Object clone()
          returns a lone of this request (with SAME name)
 java.lang.Object getAnswer()
           
 java.lang.String getAnswerer()
           
static int getCpt()
           
 boolean getIsQuestion()
           
 java.lang.String getName()
           
 java.lang.Object[] getParams()
           
 java.util.Vector getPath()
           
 int getPathLength()
           
 java.lang.String getSender()
           
 java.lang.String getSignature()
          returns the string that represents signature of the method defined by text and parameters classes
 java.lang.String getText()
           
 boolean isAnAnswer()
          true iff this request is an answer (request has already been treated and is back to sender)
 boolean isAnswerToMe(java.lang.String name)
          true iff this request is an answer to a request from name
 boolean isConcurrent()
           
 java.lang.String lastSender()
          returns the name of last agent who has forwarded the request
 void removeLastFromPath()
          removes last agent from path path
 void setAnswer(java.lang.Object answer, java.lang.String answerer)
          sets the answer
 void setConcurrent()
          sets concurrent to , request becomes a concurrent one
 java.lang.String toString()
          give a string representation of Request object
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Request

public Request()
request with just a text : to transmit simple messages


Request

public Request(java.lang.String text)
request with just a text : to transmit simple messages

Parameters:
text - : text of message

Request

public Request(java.lang.String sender,
               boolean isQuestion,
               java.lang.String text)
creates a request without args

Parameters:
sender - the sender of the request
isQuestion - true if it is a question false otherwise (order)
text - text of request

Request

public Request(java.lang.String sender,
               boolean isQuestion,
               java.lang.String text,
               java.lang.Object[] params)
creates a request wit args

Parameters:
sender - the sender of the request
isQuestion - true if it is a question false otherwise (order)
text - text of request
params - request args (lust be serializable)
Method Detail

clone

public java.lang.Object clone()
returns a lone of this request (with SAME name)

Returns:
a clone of this request

toString

public java.lang.String toString()
give a string representation of Request object

Returns:
string representation of Request object

getCpt

public static int getCpt()

getName

public java.lang.String getName()
Returns:
the request name

getText

public java.lang.String getText()
Returns:
request text (typically a method name)

getParams

public java.lang.Object[] getParams()
Returns:
request args

getSender

public java.lang.String getSender()
Returns:
request sender

getAnswerer

public java.lang.String getAnswerer()
Returns:
name of the answerer to request (typically method invoker)

getAnswer

public java.lang.Object getAnswer()
Returns:
the answer (null if none)

getIsQuestion

public boolean getIsQuestion()
Returns:
true if it is a question : an answer is required

isConcurrent

public boolean isConcurrent()
Returns:
true if it is a concurrent request

getPath

public java.util.Vector getPath()
Returns:
the path from sender to recipient through the agent net. This is used to return answer

getPathLength

public int getPathLength()
Returns:
the length of the path used to reach the answerer If answerer is the "sender", path is 1.

getSignature

public java.lang.String getSignature()
returns the string that represents signature of the method defined by text and parameters classes

Returns:
the string that represents the signature of the method defined by text and parameters classes

setConcurrent

public void setConcurrent()
sets concurrent to , request becomes a concurrent one


setAnswer

public void setAnswer(java.lang.Object answer,
                      java.lang.String answerer)
sets the answer

Parameters:
answer - answer value
answerer - answerer name
Returns:
no return value

isAnswerToMe

public boolean isAnswerToMe(java.lang.String name)
true iff this request is an answer to a request from name

Parameters:
name - the name to test
Returns:
true iff it is an answer to a request from name

isAnAnswer

public boolean isAnAnswer()
true iff this request is an answer (request has already been treated and is back to sender)

Returns:
true iff it is an answer

lastSender

public java.lang.String lastSender()
returns the name of last agent who has forwarded the request

Returns:
the name of last agent who has forwarded the request

addToPath

public void addToPath(java.lang.String agentName)
adds an agent to path (at the end)

Parameters:
agentName - the name of the agent to add to path
Returns:
no return value

removeLastFromPath

public void removeLastFromPath()
removes last agent from path path

Returns:
no return value