de.enough.polish.messaging
Class TextMessage

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

public class TextMessage
extends Object
implements Message

An interface representing a text message. An interface representing a text message. This is a subinterface of Message which contains methods to get and set the text payload. The setPayloadText 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.

Character Encoding Considerations

Text messages using this interface deal with Strings encoded in Java. The underlying implementation will convert the Strings into a suitable encoding for the messaging protocol in question. Different protocols recognize different character sets. To ensure that characters are transmitted correctly across the network, an application should use the character set(s) recognized by the protocol. If an application is unaware of the protocol, or uses a character set that the protocol does not recognize, then some characters might be transmitted incorrectly.



Field Summary
protected  String data
           
protected  String msisdn
           
protected  long timeStamp
           
 
Constructor Summary
protected TextMessage(String msisdn, String data)
           
 
Method Summary
 String getAddress()
          Returns the address associated with this message.
 String getPayloadText()
          Returns the message payload data as a String.
 Date getTimestamp()
          Returns the timestamp indicating when this message has been sent.
 void setAddress(String addr)
          Sets the address associated with this message, that is, the address returned by the getAddress method.
 void setPayloadText(String 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 String msisdn

data

protected String data

timeStamp

protected long timeStamp
Constructor Detail

TextMessage

protected TextMessage(String msisdn,
                      String data)
Method Detail

getPayloadText

public String getPayloadText()
Returns the message payload data as a String.

Returns:
the payload of this message, or null if the payload for the message is not set
See Also:
setPayloadText(java.lang.String)

setPayloadText

public void setPayloadText(String data)
Sets the payload data of this message. The payload data may be null.

Parameters:
data - - payload data as a String
See Also:
getPayloadText()

getAddress

public 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(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 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