sds.data
Class Message

java.lang.Object
  extended by sds.data.Message
All Implemented Interfaces:
java.io.Serializable

public final class Message
extends java.lang.Object
implements java.io.Serializable

Information sent to and received by distant servers. This information is to be encapsulated within a top-level envelope

Author:
ncottin
See Also:
Serialized Form

Constructor Summary
Message()
           Creates an empty message.
Message(Message other)
           Duplicates an existing message.
 
Method Summary
 Message createResponse()
           Generates a pre-initialized response to this message.
static Message createResponse(Message request)
           Generates a pre-initialized response to a given message.
 java.lang.Object getData()
           Gets the message content
 Reference getIssuer()
           Gets the message issuer
 java.lang.Integer getTag()
           Gets the current message tag
 TransactionInfo getTransactionInfo()
           Gets the information related with transactions (requests / responses track identifiers)
 boolean isInitialized()
           Makes sure this message can be sent
 boolean isTransactional()
           Checks whether this message encloses transactional information
 void setData(java.lang.Object data)
           Initializes the message content
 void setIssuer(Reference issuer)
           Assigns the message issuer reference
 void setTag(java.lang.Integer tag)
           Initializes the tag of this message
 void setTransactionInfo(TransactionInfo transactionInfo)
           Updates the transactional information of this message (mainly based on a previous received message in case of a response)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Message

public Message()

Creates an empty message. This constructor should not be used to create a response to an exiting (request) message

See Also:
createResponse()

Message

public Message(Message other)

Duplicates an existing message. As all fields but data are duplicated, this constructor should not be used to create a response to an exiting (request) message

Parameters:
other - The source message to duplicate. The current message is left empty in case the other message is null
See Also:
createResponse()
Method Detail

createResponse

public Message createResponse()

Generates a pre-initialized response to this message. This newly created message basically encloses default (duplicated) transactional information

Returns:
A non-null and uninitialized message but duplicated transactional information (if set in the current message)
See Also:
TransactionInfo.createResponse()

createResponse

public static Message createResponse(Message request)

Generates a pre-initialized response to a given message. The newly created message basically encloses default (duplicated) transactional information

Parameters:
request - The request message to respond to
Returns:
A non-null and uninitialized message but duplicated transactional information (if set in the current message)
See Also:
createResponse()

getIssuer

public Reference getIssuer()

Gets the message issuer

Returns:
The message issuer (sender) reference. This reference may be null if the message is not initialized

setIssuer

public void setIssuer(Reference issuer)

Assigns the message issuer reference

Parameters:
issuer - The issuer reference. The message cannot be sent until this reference is provided

getTransactionInfo

public TransactionInfo getTransactionInfo()

Gets the information related with transactions (requests / responses track identifiers)

Returns:
The transactional information or null if not such information is provided

setTransactionInfo

public void setTransactionInfo(TransactionInfo transactionInfo)

Updates the transactional information of this message (mainly based on a previous received message in case of a response)

Parameters:
transactionInfo - The transactional information or null if no transaction information applies to this message
See Also:
createResponse()

getTag

public java.lang.Integer getTag()

Gets the current message tag

Returns:
Any value, including null if this message has no assigned tag

setTag

public void setTag(java.lang.Integer tag)

Initializes the tag of this message

Parameters:
tag - Any value. A null tag leads isInitialized() to return false

getData

public java.lang.Object getData()

Gets the message content

Returns:
The message main content

setData

public void setData(java.lang.Object data)

Initializes the message content

Parameters:
data - The message content

isInitialized

public boolean isInitialized()

Makes sure this message can be sent

Returns:
True only if this message encloses a tag value and the reference to the sender

isTransactional

public boolean isTransactional()

Checks whether this message encloses transactional information

Returns:
True only if this message transactional information is not null and initialized