FileDocCategorySizeDatePackage
MessageObject.javaAPI DocphoneME MR2 API (J2ME)5174Wed May 02 18:00:32 BST 2007com.sun.tck.wma

MessageObject

public abstract class MessageObject extends Object implements com.sun.tck.wma.Message
Implements a SMS message for the SMS message connection. This class contains methods for manipulating message objects and their contents. Messages can be composed of data and an address. MessageObject contains methods that can get and set the data and the address parts of a message separately. The data part can be either text or binary format. The address part has the format:

sms://[phone_number:][port_number]

and represents the address of a port that can accept or receive SMS messages.

MessageObjects are instantiated when they are received from the {@link com.sun.tck.wma.MessageConnection MessageConnection} or by using the {@link MessageConnection#newMessage(String type) MessageConnection.newMessage} message factory. Instances are freed when they are garbage-collected or when they go out of scope.

Fields Summary
protected String
msgType
High-level message type.
protected String
msgAddress
High-level message address.
protected long
sentAt
The time stamp for a message that was sent.
Constructors Summary
public MessageObject(String type, String address)
Creates a Message Object without a buffer.

param
type The message type: TEXT, BINARY or MULTIPART.
param
address The destination address of the message.

	msgType = type;
	msgAddress = address;
    
Methods Summary
public java.lang.StringgetAddress()
Gets the address from the message object as a String. If no address is found in the message, this method returns null. If the method is applied to an inbound message, the source address is returned. If it is applied to an outbound message, the destination address is returned.

The following code sample retrieves the address from a received message.

...
Message msg = conn.receive();
String addr = msg.getAddress();
...
...

return
The address in string form, or null if no address was set.
see
#setAddress

	return msgAddress;
    
public abstract java.util.DategetTimestamp()
Returns the timestamp indicating when this message has been sent.

return
Date indicating the timestamp in the message or null if the timestamp is not set.
see
#setTimeStamp

public abstract voidsetAddress(java.lang.String addr)
Sets the address part of the message object. The address is a String and must be in the format: protocol://phone_number:[port] The following code sample assigns an address to the Message object.
...
String addr = "protocol://+123456789";
Message msg = newMessage(MessageConnection.TEXT_MESSAGE);
msg.setAddress(addr);
...

param
addr The address of the target device.
throws
IllegalArgumentException if the address is not valid.
see
#getAddress

public voidsetAddress(com.sun.tck.wma.Message reference)
(May be deleted) Set message address, copying the address from another message.

param
reference the message who's address will be copied as the new target address for this message.
exception
IllegalArgumentException if the address is not valid
see
#getAddress

	setAddress(reference.getAddress());
    
public voidsetTimeStamp(long timestamp)
Sets the timestamp for inbound SMS messages.

param
timestamp the date indicating the timestamp in the message
see
#getTimeStamp

	sentAt = timestamp;