fipaos.ont.fipa.fipaman
Class Envelope

java.lang.Object
  |
  +--fipaos.ont.fipa.fipaman.Envelope
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class Envelope
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

This class provides a representation of the FIPA99/2000 envelope (implements XC00067C)

In conformance with the FIPA99/2000 specification slots cannot be overwriten, just overridden.

See Also:
Serialized Form

Constructor Summary
Envelope()
          Default constructor - creates an empty envelope
Envelope(ACL msg)
          Creates an Envelope based upon the given ACL object
Envelope(Envelope env)
          Deprecated. Please use clone() instead
 
Method Summary
 void addMessageListener(MessageListener ml)
          Add a MessageListener to this
 java.lang.Object clone()
           
 java.lang.Object cloneSlot(java.lang.Object slot)
          Attempt to clone a value that has been inserted into a slot
 java.lang.String getACLRepresentation()
          Gets the ACL representation associated with this envelope
 java.lang.String getComments()
          Gets the comments associated with this Envelope
 UTCTime getDate()
          Gets the creating date of this Envelope
 java.util.List getEncrypted()
          Gets details of the encryption used on the content of the envelope
 int getErrorCode()
          Get the internal error condition for this envelope
 java.util.List getIntendedReceiver()
          Gets the intended receivers for the message
 java.util.List getMessageListeners()
          Get list of MessageListeners
 java.lang.String getPayloadEncoding()
          Gets the payload encoding associated with this Envelope
 int getPayloadLength()
          Gets the payload length associated with this Envelope
 Received getReceived()
          Gets details of when the message was received by an entity
 java.util.List getReceivers()
          Gets a List of the recipients' AID's
 AgentID getSender()
          Gets the sender of the message
 java.lang.Object getSlotValue(java.lang.String slot)
          Generic method for retreiving the value assigned to a slot within the envelope
 Envelope getSubEnvelope(int x)
          Gets a particular sub-envelope
 java.util.List getSubEnvelopes()
          Returns a list of the sub-envelopes composing this
 TransportBehaviour getTransportBehaviour()
          Gets the TransportBehviour parameter
 java.util.List getTransportsTried()
          Returns the transports that have been tried whilst attempting to send this message
 java.util.List getUnknownURLsTried()
          Returns the URL's that have been tried, but an MTP implementation hasn't been found
 java.util.Set getUserSlots()
          Returns a list of the names of non-standard slots contained within this Envelope
 boolean getViaACC()
          Indicates if this should be routed via the ACC
static void main(java.lang.String[] args)
          Test-harness
 void newSubEnvelope()
          Indicates that a new sub-envelope should be started (i.e.
 void removeMessageListener(MessageListener ml)
          Remove a MessageListener from this
 void setACLRepresentation(java.lang.String type)
          Sets the ACL representation of this Envelope
 void setComments(java.lang.String comments)
          Sets the comments associated with this envelope
 void setDate(UTCTime utc)
          Sets the date of creation for this envelope
 void setEncrypted(java.util.List enc)
          Sets details of the encryption used on the content of the envelope
 void setErrorCode(int code)
          Set the internal error condition for this envelope
 void setIntendedReceiver(java.util.List aids)
          Sets the intended receivers for the message
 void setPayloadEncoding(java.lang.String encoding)
          Sets the payload encoding associated with this envelope
 void setPayloadLength(int length)
          Sets the payload length associated with this envelope
 void setReceived(Received received)
          Sets details of when the message was received by an entity
 void setReceivers(java.util.List aids)
          Sets the list of receivers for the message
 void setSender(AgentID aid)
          Sets the sender of the message
 void setSlotValue(java.lang.String slot, java.lang.Object value)
          Generic method for adding a value to a slot within the envelope
 void setTransportBehaviour(TransportBehaviour behaviour)
          Sets the TransportBehviour parameter
 void setViaACC(boolean value)
          Sets the flag that indicates if the message this encapsulates should be routed via the ACC
 java.lang.String toString()
          Overrides default toString() method - displays contents of Envelope
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Envelope

public Envelope()
Default constructor - creates an empty envelope

Envelope

public Envelope(Envelope env)
Deprecated. Please use clone() instead

Creates a copy of the given Envelope object
Parameters:
env - Envelope to duplicate

Envelope

public Envelope(ACL msg)
Creates an Envelope based upon the given ACL object
Parameters:
msg - ACL to base the Envelope on
Method Detail

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

cloneSlot

public java.lang.Object cloneSlot(java.lang.Object slot)
Attempt to clone a value that has been inserted into a slot

addMessageListener

public void addMessageListener(MessageListener ml)
Add a MessageListener to this

removeMessageListener

public void removeMessageListener(MessageListener ml)
Remove a MessageListener from this

getMessageListeners

public java.util.List getMessageListeners()
Get list of MessageListeners

newSubEnvelope

public void newSubEnvelope()
Indicates that a new sub-envelope should be started (i.e. when the Envelope is received by a new ACC)

getSubEnvelopes

public java.util.List getSubEnvelopes()
Returns a list of the sub-envelopes composing this
Returns:
A List of Envelope objects

getSubEnvelope

public Envelope getSubEnvelope(int x)
Gets a particular sub-envelope
Parameters:
x - The sub-envelope number to get
Returns:
A sub-envelope of this

setACLRepresentation

public void setACLRepresentation(java.lang.String type)
Sets the ACL representation of this Envelope
Parameters:
type - The type of the ACL representation (i.e. RDF)

getACLRepresentation

public java.lang.String getACLRepresentation()
Gets the ACL representation associated with this envelope
Returns:
ACL encoding

setComments

public void setComments(java.lang.String comments)
Sets the comments associated with this envelope
Parameters:
comments - Comment to add

getComments

public java.lang.String getComments()
Gets the comments associated with this Envelope
Returns:
The comments

setPayloadEncoding

public void setPayloadEncoding(java.lang.String encoding)
Sets the payload encoding associated with this envelope

getPayloadEncoding

public java.lang.String getPayloadEncoding()
Gets the payload encoding associated with this Envelope

setPayloadLength

public void setPayloadLength(int length)
Sets the payload length associated with this envelope
Parameters:
length - of payload (or -1 for none)

getPayloadLength

public int getPayloadLength()
Gets the payload length associated with this Envelope
Returns:
The length, or -1 if this hasn't been set

setDate

public void setDate(UTCTime utc)
Sets the date of creation for this envelope
Parameters:
utc - The UTCTime representing the creation time of the envelope

getDate

public UTCTime getDate()
Gets the creating date of this Envelope
Returns:
UTCTime representing the creation time

setEncrypted

public void setEncrypted(java.util.List enc)
Sets details of the encryption used on the content of the envelope
Parameters:
enc - Details of encryption applied

getEncrypted

public java.util.List getEncrypted()
Gets details of the encryption used on the content of the envelope
Returns:
Details of the encryption used

setReceived

public void setReceived(Received received)
Sets details of when the message was received by an entity
Parameters:
received - Description of the time & entity

getReceived

public Received getReceived()
Gets details of when the message was received by an entity
Returns:
Details of when & what entity received the message last

setSender

public void setSender(AgentID aid)
Sets the sender of the message
Parameters:
aid - The AID belonging to the sending Agent

getSender

public AgentID getSender()
Gets the sender of the message
Returns:
The AID of the sending Agent

setReceivers

public void setReceivers(java.util.List aids)
Sets the list of receivers for the message
Parameters:
aids - A List of AgentID's belonging to the recipients of the message

getReceivers

public java.util.List getReceivers()
Gets a List of the recipients' AID's
Returns:
List of the recipients' AID's

setIntendedReceiver

public void setIntendedReceiver(java.util.List aids)
Sets the intended receivers for the message
Parameters:
aids - A List of AgentID's

getIntendedReceiver

public java.util.List getIntendedReceiver()
Gets the intended receivers for the message
Returns:
AgentID belonging to the intended recipient of the message

setTransportBehaviour

public void setTransportBehaviour(TransportBehaviour behaviour)
Sets the TransportBehviour parameter
Parameters:
behaviour - A description of the behaviour to use

getTransportBehaviour

public TransportBehaviour getTransportBehaviour()
Gets the TransportBehviour parameter
Returns:
A description of the transport level behaviour

setErrorCode

public void setErrorCode(int code)

Set the internal error condition for this envelope

N.B. This is not part of the FIPA specification, but servers as a mechanism for "tagging" messages with "exception" codes at the transport layer

Parameters:
code -  

getErrorCode

public int getErrorCode()
Get the internal error condition for this envelope

N.B. This is not part of the FIPA specification, but servers as a mechanism for "tagging" messages with "exception" codes at the transport layer

Returns:
 

setViaACC

public void setViaACC(boolean value)
Sets the flag that indicates if the message this encapsulates should be routed via the ACC
Parameters:
value - If true, indicates this message should be routed via the ACC

getViaACC

public boolean getViaACC()
Indicates if this should be routed via the ACC
Returns:
If true, this should be routed via the ACC

getTransportsTried

public java.util.List getTransportsTried()
Returns the transports that have been tried whilst attempting to send this message
Returns:
A List of transports tried (by protocol)

getUnknownURLsTried

public java.util.List getUnknownURLsTried()
Returns the URL's that have been tried, but an MTP implementation hasn't been found
Returns:
A List of transports tried (by protocol)

setSlotValue

public void setSlotValue(java.lang.String slot,
                         java.lang.Object value)
Generic method for adding a value to a slot within the envelope
Parameters:
slot - Slot name
value - Value

getSlotValue

public java.lang.Object getSlotValue(java.lang.String slot)
Generic method for retreiving the value assigned to a slot within the envelope
Parameters:
slot - Slot name
Returns:
Most recent value associated with a slot

getUserSlots

public java.util.Set getUserSlots()
Returns a list of the names of non-standard slots contained within this Envelope
Returns:
A Set of user-defined slot names

toString

public java.lang.String toString()
Overrides default toString() method - displays contents of Envelope
Overrides:
toString in class java.lang.Object
Returns:
Stringified representation of this

main

public static void main(java.lang.String[] args)
Test-harness