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

MessageConnection

public interface MessageConnection
A connection handler for generic message receiving and sending.

Fields Summary
public static final String
TEXT_MESSAGE
Constant designating a message type for text messages, i.e. value = "text". When this constant is used for the newMessage() methods type parameter, the new Message object will implement the TextMessage interface.
public static final String
BINARY_MESSAGE
Constant designating a message type for binary messages, i.e. value = "binary". When this constant is used for the newMessage() methods type parameter, the new Message object will implement the BinaryMessage interface.
public static final String
MULTIPART_MESSAGE
Constant designating a message type for multipart MIME messages, i.e. value = "multipart". When this constant is used for the newMessage() methods type parameter, the new Message object will implement the MultipartMessage interface.
Constructors Summary
Methods Summary
public voidclose()
Close the connection.

throws
java.io.IOException if an I/O error occurs

public MessagenewMessage(java.lang.String type)
Constructs a new message object of a specified type.

param
type the type of message to create.
throws
java.lang.IllegalArgumentException if the message type isn't BINARY_MESSAGE or TEXT_MESSAGE
return
a newly constructed message object of a given type

public MessagenewMessage(java.lang.String type, java.lang.String address)
Constructs a new message object of a specified type initialized with the specified destination address.

param
type the type of message to create.
param
address the new message's destination address
return
a newly constructed message object of a given type
throws
java.lang.IllegalArgumentException if the message type isn't BINARY_MESSAGE or TEXT_MESSAGE
see
#newMessage(String type)

public Messagereceive()
Receives a message.

If there are no Messages for this MessageConnection waiting, this method will block until a message for this Connection is received, or the MessageConnection is closed.

return
a received message represented by the Message object
throws
java.io.IOException if an error occurs while receiving a message
throws
java.io.InterruptedIOException if the connection is closed during the receive operation
throws
java.lang.SecurityException if the application doesn't have permission for receiving messages on the given port
see
#send(Message)

public voidsend(Message msg)
Sends a message.

param
msg the message to be sent
throws
java.io.IOException network failure has occured, or the message couldn't be sent due to other reasons
throws
java.lang.IllegalArgumentException if the message contains invalid information or is incomplete, or the payload exceeds the maximal length allowed by the given messaging protocol.
throws
java.io.InterruptedIOException if the connection is closed during the send operation, or if a timeout occurs while sending the message
throws
java.lang.NullPointerException if msg is null
throws
java.lang.SecurityException if the application doesn't have permission for sending the message
see
#receive()