public class MessageTemplate extends java.lang.Object implements Serializable
receive()
operations.
This class provide one method for each attribute of an ACLMessage,
that can be combined using the logic operators to create more complex
patterns.
A user can also create an application-specific pattern.
In this case he has to implement the MatchExpression interface,
writing the application specific match()
method.
Then an instance of that class can be used as parameter of the MessageTemplate
constructor to define the application specific MessageTemaplate.Agent.receive(MessageTemplate mt)
,
Serialized FormModifier and Type | Class and Description |
---|---|
static interface |
MessageTemplate.MatchExpression
This interface must be overriden in order to define an application
specific MessageTemplate.
|
Constructor and Description |
---|
MessageTemplate(MessageTemplate.MatchExpression e)
Public constructor to use when the user needs to define
an application specific pattern.
|
Modifier and Type | Method and Description |
---|---|
static MessageTemplate |
and(MessageTemplate op1,
MessageTemplate op2)
Logical and between two
MessageTemplate
objects. |
boolean |
match(ACLMessage msg)
Matches an ACL message against this
MessageTemplate
object. |
static MessageTemplate |
MatchAll()
This Factory Method returns a message template that
matches any message.
|
static MessageTemplate |
MatchContent(java.lang.String value)
This Factory Method returns a message template that
matches any message with a given
:content slot. |
static MessageTemplate |
MatchConversationId(java.lang.String value)
This Factory Method returns a message template that
matches any message with a given
:conversation-id slot. |
static MessageTemplate |
MatchCustom(ACLMessage msg,
boolean matchPerformative)
This Factory Method returns a message template that
matches ACL messages against a given one, passed as
parameter.
|
static MessageTemplate |
MatchEncoding(java.lang.String value)
This Factory Method returns a message template that
matches any message with a given
:encoding slot. |
static MessageTemplate |
MatchInReplyTo(java.lang.String value)
This Factory Method returns a message template that
matches any message with a given
:in-reply-to slot. |
static MessageTemplate |
MatchLanguage(java.lang.String value)
This Factory Method returns a message template that
matches any message with a given
:language slot. |
static MessageTemplate |
MatchOntology(java.lang.String value)
This Factory Method returns a message template that
matches any message with a given
:ontology slot. |
static MessageTemplate |
MatchPerformative(int value)
This Factory Method returns a message template that
matches any message with a given performative.
|
static MessageTemplate |
MatchProtocol(java.lang.String value)
This Factory Method returns a message template that
matches any message with a given
:protocol slot. |
static MessageTemplate |
MatchReceiver(AID[] values)
This Factory Method returns a message template that
matches any message with a given
:receiver slot. |
static MessageTemplate |
MatchReplyByDate(java.util.Date value)
This Factory Method returns a message template that
matches any message with a given
:reply-by slot. |
static MessageTemplate |
MatchReplyTo(AID[] values)
This Factory Method returns a message template that
matches any message with a given
:reply-to slot. |
static MessageTemplate |
MatchReplyWith(java.lang.String value)
This Factory Method returns a message template that
matches any message with a given
:reply-with slot. |
static MessageTemplate |
MatchSender(AID value)
This Factory Method returns a message template that
matches any message with a given
:sender slot. |
static MessageTemplate |
MatchTopic(AID topic)
This Factory Method returns a message template that
matches any message about a given topic.
|
static MessageTemplate |
not(MessageTemplate op)
Logical not of a
MessageTemplate object. |
static MessageTemplate |
or(MessageTemplate op1,
MessageTemplate op2)
Logical or between two
MessageTemplate
objects. |
java.lang.String |
toString()
Retrieve a string representation of this message template.
|
public MessageTemplate(MessageTemplate.MatchExpression e)
public static MessageTemplate MatchAll()
MessageTemplate
matching any given
value.public static MessageTemplate MatchSender(AID value)
:sender
slot.value
- The value the message slot will be matched against.MessageTemplate
matching the given
value.public static MessageTemplate MatchReceiver(AID[] values)
:receiver
slot.values
- An array of Agent IDs against which the
value of the message slot will be matched.MessageTemplate
matching the given
value.public static MessageTemplate MatchTopic(AID topic)
topic
- An AID representing the topic to be matchedMessageTemplate
matching messages about the given topicpublic static MessageTemplate MatchContent(java.lang.String value)
:content
slot.value
- The value the message slot will be matched against.MessageTemplate
matching the given
value.public static MessageTemplate MatchReplyWith(java.lang.String value)
:reply-with
slot.value
- The value the message slot will be matched against.MessageTemplate
matching the given
value.public static MessageTemplate MatchInReplyTo(java.lang.String value)
:in-reply-to
slot.value
- The value the message slot will be matched against.MessageTemplate
matching the given
value.public static MessageTemplate MatchReplyTo(AID[] values)
:reply-to
slot.values
- An array of Agent IDs against which the
value of the message slot will be matched.MessageTemplate
matching the given
value.public static MessageTemplate MatchLanguage(java.lang.String value)
:language
slot.value
- The value the message slot will be matched against.MessageTemplate
matching the given
value.public static MessageTemplate MatchEncoding(java.lang.String value)
:encoding
slot.value
- The value the message slot will be matched against.MessageTemplate
matching the given
value.public static MessageTemplate MatchOntology(java.lang.String value)
:ontology
slot.value
- The value the message slot will be matched against.MessageTemplate
matching the given
value.public static MessageTemplate MatchReplyByDate(java.util.Date value)
:reply-by
slot.value
- The Date
the message slot will be matched against.MessageTemplate
matching the given
value.public static MessageTemplate MatchProtocol(java.lang.String value)
:protocol
slot.value
- The value the message slot will be matched against.MessageTemplate
matching the given
value.public static MessageTemplate MatchConversationId(java.lang.String value)
:conversation-id
slot.value
- The value the message slot will be matched against.MessageTemplate
matching the given
value.public static MessageTemplate MatchPerformative(int value)
value
- The value the message slot will be matched against.MessageTenplate
matching the given
value.public static MessageTemplate MatchCustom(ACLMessage msg, boolean matchPerformative)
ACLMessage
has a non
null
slot, subsequent messages must have the same
slot value in that slot to have a match.
When the given ACLMessage
has a null
slot, subsequent messages can have any value for that slot and
still match the template.
In short, a null
value for a slot means don't
care.msg
- The ACLMessage
used to build a custom
message template.matchPerformative
- a bool
value. When
true
, the performative of the msg
will
be considered as a part of the template (i.e. the message
template will match only ACL messages with the same performativa
as msg
).
When msg
is ignored and
the resulting message template will not consider it when matching
messages.MessageTemplate
, matching the given
message according to the above algorithm.public static MessageTemplate and(MessageTemplate op1, MessageTemplate op2)
MessageTemplate
objects. This method creates a new message template that is
matched by those ACL messages matching both
message templates given as operands.op1
- The first and operand.op2
- The second and operand.MessageTemplate
object.or(MessageTemplate op1, MessageTemplate op2)
public static MessageTemplate or(MessageTemplate op1, MessageTemplate op2)
MessageTemplate
objects. This method creates a new message template that is
matched by those ACL messages matching any of the
two message templates given as operands.op1
- The first or operand.op2
- The second or operand.MessageTemplate
object.and(MessageTemplate op1, MessageTemplate op2)
public static MessageTemplate not(MessageTemplate op)
MessageTemplate
object. This
method creates a new message template that is matched by those
ACL messages not matching the message template
given as operand.op
- The not operand.MessageTemplate
object.public boolean match(ACLMessage msg)
MessageTemplate
object.msg
- The ACLMessage
to check for matching.true
if the ACL message matches this
template, false
otherwise.public java.lang.String toString()
toString
in class java.lang.Object