public class BusMessage extends Object implements BrokerMessage
BrokerMessage.BrokerMessageTypes
Modifier and Type | Field and Description |
---|---|
String |
brokerName |
Constructor and Description |
---|
BusMessage() |
BusMessage(MessageType type,
Object content,
AbstractBus creator)
Constructor - a message of particular type with particular content
|
BusMessage(String message,
AbstractBus creator)
Constructor - parses the string passed as a parameter and creates a
Message object.
|
Modifier and Type | Method and Description |
---|---|
void |
addReceiver(PeerCard pc) |
void |
addReceivers(PeerCard[] receivers) |
static BusMessage |
createP2PReply(String messageIDInReplyTo,
PeerCard receiver,
Object content,
AbstractBus creator)
Create a reply message to the message with the given ID, with the content
and receiver passed as a parameter.
|
BusMessage |
createReply(Object content)
Create reply message to this message, with the content passed as a
parameter.
|
static String |
createUniqueID()
generates a globally unique ID, based on a counter and some string that
represents this JVM
|
static Object |
deserializeAsContent(String s) |
Object |
getContent() |
String |
getContentAsString() |
String |
getID() |
long |
getIDAsLong() |
String |
getInReplyTo()
Returns the ID of the message this message replies to.
|
BrokerMessage.BrokerMessageTypes |
getMType() |
PeerCard[] |
getReceivers() |
PeerCard |
getSender() |
MessageType |
getType() |
boolean |
hasReceiver(PeerCard receiver) |
String |
marshall(BrokerMessage message) |
boolean |
receiverResidesOnDifferentPeer() |
boolean |
senderResidesOnDifferentPeer() |
boolean |
sentBySamePeerAs(PeerCard peer) |
static void |
setMessageContentSerializer(MessageContentSerializer mcs) |
void |
setReceiver(PeerCard receiver)
If the given peer is not null, removes any existing receiver and adds the
given peer as the only receiver.
|
void |
setReceivers(List<PeerCard> receivers) |
void |
setSender(PeerCard sender) |
static void |
setThisPeer(PeerCard peer) |
void |
setType(MessageType newType) |
String |
toString()
Serialize the message as string.
|
static String |
trySerializationAsContent(Object o)
A safe wrapping for calling contentSerializer.serialize(o).
|
public String brokerName
public BusMessage()
public BusMessage(MessageType type, Object content, AbstractBus creator)
type
- content
- Content of the message, typically a Resource
.public BusMessage(String message, AbstractBus creator)
message
- the string to parse (the serialization of a message object).public static String createUniqueID()
public static void setMessageContentSerializer(MessageContentSerializer mcs)
public static void setThisPeer(PeerCard peer)
public static String trySerializationAsContent(Object o)
o
- - Object to serializepublic void addReceiver(PeerCard pc)
public void addReceivers(PeerCard[] receivers)
public BusMessage createReply(Object content)
content
- the content of the created reply, typically a Resource
.public static BusMessage createP2PReply(String messageIDInReplyTo, PeerCard receiver, Object content, AbstractBus creator)
messageIDInReplyTo
- ID of the message to which the returned message is a reply to.receiver
- the receiving peer.content
- Content of the message, typically a Resource
.BusMessage
, or null if the parameters are invalid.public Object getContent()
public String getContentAsString()
public String getID()
public long getIDAsLong()
public String getInReplyTo()
public MessageType getType()
MessageType
public void setType(MessageType newType)
public boolean receiverResidesOnDifferentPeer()
public boolean senderResidesOnDifferentPeer()
public boolean sentBySamePeerAs(PeerCard peer)
public void setReceiver(PeerCard receiver)
receiver
- public String toString()
toString
in interface BrokerMessage
toString
in class Object
public String marshall(BrokerMessage message)
public BrokerMessage.BrokerMessageTypes getMType()
getMType
in interface BrokerMessage
public PeerCard[] getReceivers()
getReceivers
in interface BrokerMessage
public boolean hasReceiver(PeerCard receiver)
public PeerCard getSender()
public void setSender(PeerCard sender)
Copyright © 2015 universAAL Consortium. All Rights Reserved.