| java.lang.Object com.sun.tck.wma.sms.MessageObject
All known Subclasses: com.sun.tck.wma.mms.MultipartObject, com.sun.tck.wma.sms.TextObject, com.sun.tck.wma.sms.BinaryObject,
MessageObject | public class MessageObject implements Message(Code) | | A message for a message connection, composed of an address and data. There
are get and set methods for manipulating the address and data components of
the message. The data part can be the text, binary or multipart format. The
address part assumes this format:
protocol://[phone_number:][port_number/ID]
and represents the address of a port/ID that can accept or receive messages.
MessageObject s are instantiated when they are received from the
com.sun.tck.wma.MessageConnection MessageConnection or by using the
MessageConnection.newMessage(String type)MessageConnection.newMessage message factory. Instances are freed when they
are garbage-collected or when they go out of scope.
|
Field Summary | |
protected String | msgAddress High-level message address. | protected String | msgType High-level message type. | protected long | sentAt The time stamp, indicating when the message was sent. |
Method Summary | |
public String | getAddress() Gets the address from the message object as a String . | public Date | getTimestamp() Returns the timestamp indicating when this message has been sent. | public String | getType() Gets the message type. | public void | setAddress(String address) Sets the address part of the message object. | public void | setTimeStamp(long timestamp) Sets the timestamp for inbound SMS messages. | public void | setType(String type) Sets the message type. |
msgAddress | protected String msgAddress(Code) | | High-level message address.
|
msgType | protected String msgType(Code) | | High-level message type.
|
sentAt | protected long sentAt(Code) | | The time stamp, indicating when the message was sent.
|
MessageObject | public MessageObject(String type, String address)(Code) | | Creates a Message object without a buffer.
Parameters: type - The message type: TEXT, BINARY or MULTIPART. Parameters: address - The destination address of the message. |
getAddress | public String getAddress()(Code) | | 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();
...
...
The address in string form, or null if no address was set. See Also: MessageObject.setAddress |
getTimestamp | public Date getTimestamp()(Code) | | Returns the timestamp indicating when this message has been sent.
Date indicating the time stamp in the message ornull if the time stamp was not set. See Also: MessageObject.setTimeStamp |
getType | public String getType()(Code) | | Gets the message type.
The current message type or null if no message typehas been set. |
setAddress | public void setAddress(String address)(Code) | | 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);
...
Parameters: address - The address of the target device. throws: IllegalArgumentException - if the address is not valid. See Also: MessageObject.getAddress |
setTimeStamp | public void setTimeStamp(long timestamp)(Code) | | Sets the timestamp for inbound SMS messages.
Parameters: timestamp - The time stamp in the message. See Also: MessageObject.getTimeStamp |
setType | public void setType(String type)(Code) | | Sets the message type.
Parameters: type - The message type: TEXT, BINARY or MULTIPART. exception: IllegalArgumentException - if the type is not valid. |
|
|