de.enough.polish.messaging
Class BinaryMessage

java.lang.Object
  extended by de.enough.polish.messaging.BinaryMessage
All Implemented Interfaces:
Message

public class BinaryMessage
extends java.lang.Object
implements Message

An interface representing a binary message. An interface representing a binary message. This is a subinterface of Message which contains methods to get and set the binary data payload. The setPayloadData() method sets the value of the payload in the data container without any checking whether the value is valid in any way. Methods for manipulating the address portion of the message are inherited from Message.

Object instances implementing this interface are just containers for the data that is passed in.



Field Summary
protected  byte[] data
           
protected  java.lang.String msisdn
           
protected  long timeStamp
           
 
Constructor Summary
protected BinaryMessage(java.lang.String msisdn, byte[] data)
           
 
Method Summary
 java.lang.String getAddress()
          Returns the address associated with this message.
 byte[] getPayloadData()
          Returns the message payload data as an array of bytes.
 java.util.Date getTimestamp()
          Returns the timestamp indicating when this message has been sent.
 void setAddress(java.lang.String addr)
          Sets the address associated with this message, that is, the address returned by the getAddress method.
 void setPayloadData(byte[] data)
          Sets the payload data of this message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

msisdn

protected java.lang.String msisdn

data

protected byte[] data

timeStamp

protected long timeStamp
Constructor Detail

BinaryMessage

protected BinaryMessage(java.lang.String msisdn,
                        byte[] data)
Method Detail

getPayloadData

public byte[] getPayloadData()
Returns the message payload data as an array of bytes.

Returns null, if the payload for the message is not set.

The returned byte array is a reference to the byte array of this message and the same reference is returned for all calls to this method made before the next call to setPayloadData.

Returns:
the payload data of this message or null if the data has not been set
See Also:
setPayloadData(byte[])

setPayloadData

public void setPayloadData(byte[] data)
Sets the payload data of this message. The payload may be set to null.

Setting the payload using this method only sets the reference to the byte array. Changes made to the contents of the byte array subsequently affect the contents of this BinaryMessage object. Therefore, applications should not reuse this byte array before the message is sent and the MessageConnection.send method returns.

Parameters:
data - - payload data as a byte array
See Also:
getPayloadData()

getAddress

public java.lang.String getAddress()
Description copied from interface: Message
Returns the address associated with this message.

If this is a message to be sent, then this address is the recipient's address.

If this is a message that has been received, then this address is the sender's address.

Returns null, if the address for the message is not set.

Note: This design allows responses to be sent to a received message by reusing the same Message object and just replacing the payload. The address field can normally be kept untouched (unless the messaging protocol requires some special handling of the address).

The returned address uses the same URL string syntax that Connector.open() uses to obtain this MessageConnection.

Specified by:
getAddress in interface Message
Returns:
the address of this message, or null if the address is not set
See Also:
Message.setAddress(String)

setAddress

public void setAddress(java.lang.String addr)
Description copied from interface: Message
Sets the address associated with this message, that is, the address returned by the getAddress method. The address may be set to null.

The address MUST use the same URL string syntax that Connector.open() uses to obtain this MessageConnection.

Specified by:
setAddress in interface Message
Parameters:
addr - - address for the message
See Also:
Message.getAddress()

getTimestamp

public java.util.Date getTimestamp()
Description copied from interface: Message
Returns the timestamp indicating when this message has been sent.

Specified by:
getTimestamp in interface Message
Returns:
Date indicating the timestamp in the message or null if the timestamp is not set or if the time information is not available in the underlying protocol message