FileDocCategorySizeDatePackage
MultipartMessage.javaAPI DocphoneME MR2 API (J2ME)12075Wed May 02 18:00:44 BST 2007com.sun.tck.wma

MultipartMessage

public interface MultipartMessage implements Message
An interface representing a multipart message. This is a subinterface of Message which contains methods to add and get MessageParts. The interface also allows to specify the subject of the message. The basic methods for manipulating the address portion of the message are inherited from Message. Additionally, this interface defines methods for adding and removing addresses to/from the "to", "cc" or "bcc" fields. Furthermore it offers methods to get and set special header fields of the message. The contents of the MultipartMessage are assembled during the invocation of the MessageConnection.send() method. The contents of each MessagePart are copied before the send message returns. Changes to the MessagePart contents after send must not appear in the transmitted message.
since
WMA 2.0

Fields Summary
Constructors Summary
Methods Summary
public booleanaddAddress(java.lang.String type, java.lang.String address)
Adds an address to the multipart message.

param
type the adress type ("to", "cc" or "bcc") as a String. Each message can have none or multiple "to", "cc" and "bcc" addresses. Eash address is added separately. The method is not case sensitive. The implementation of MessageConnection.send() makes sure that the "from" address is set correctly.
param
address the address as a String
return
true if it was possible to add the address, else false
throws
java.lang.IllegalArgumentException if type is none of "to", "cc", or "bcc" or if address is not valid.
see
#setAddress(String)

public voidaddMessagePart(MessagePart part)
Attaches a MessagePart to the multipart message.

param
part MessagePart to add
throws
java.lang.IllegalArgumentException if the Content-ID of the MessagePart conflicts with a Content-ID of a MessagePart already contained in this MultiPartMessage. The Content-IDs must be unique within a MultipartMessage.
throws
NullPointerException if the parameter is null
throws
SizeExceededException if it's not possible to attach the MessagePart.

public java.lang.StringgetAddress()
Returns the "from" address associated with this message, e.g. address of the sender. If the message is a newly created message, e.g. not a received one, then the first "to" address is returned. Returns null if the "from" or "to" address for the message, dependent on the case, are not set. Note: This design allows sending responses to a received message easily by reusing the same Message object and just replacing the payload. The address field can normally be kept untouched (unless the used messaging protocol requires some special handling of the address).

return
the "from" or "to" address of this message, or null if the address that is expected as a result of this method is not set
see
#setAddress(String)

public java.lang.String[]getAddresses(java.lang.String type)
Gets the addresses of the multipart message of the specified type (e.g. "to", "cc", "bcc" or "from") as String. The method is not case sensitive.

param
type the type of address list to return
return
the addresses as a String array or null if this value is not present.

public java.lang.StringgetHeader(java.lang.String headerField)
Gets the content of the specific header field of the multipart message.

param
headerField the name of the header field as a String
return
the content of the specified header field as a String or null of the specified header field is not present.
throws
SecurityException if the access to specified header field is restricted
throws
IllegalArgumentException if headerField is unknown
see
Appendix D for known headerFields
see
#setHeader

public MessagePartgetMessagePart(java.lang.String contentID)
This method returns a MessagePart from the message that matches the content-id passed as a parameter.

param
contentID the content-id for the MessagePart to be returned
return
MessagePart that matches the provided content-id or null if there is no MessagePart in this message with the provided content-id
throws
NullPointerException if the parameter is null

public MessagePart[]getMessageParts()
Returns an array of all MessageParts of this message.

return
array of MessageParts, or null if no MessageParts are available

public java.lang.StringgetStartContentId()
Returns the contentId of the start MessagePart. The start MessagePart is set in setStartContentId(String)

return
the content-id of the start MessagePart or null if the start MessagePart is not set.
see
#setStartContentId(String)

public java.lang.StringgetSubject()
Gets the subject of the multipart message.

return
the message subject as a String or null if this value is not present.
see
#setSubject

public booleanremoveAddress(java.lang.String type, java.lang.String address)
Removes an address from the multipart message.

param
type the address type ("to", "cc", "bcc", or "from") as a String
param
address the address as a String
return
true if it was possible to delete the address, else false
throws
NullPointerException is type is null
throws
java.lang.IllegalArgumentException if type is none of "to", "cc", "bcc", or "from"

public voidremoveAddresses()
Removes all addresses of types "to", "cc", "bcc" from the multipart message.

see
#setAddress(String)
see
#addAddress(String, String)

public voidremoveAddresses(java.lang.String type)
Removes all addresses of the specified type from the multipart message.

param
type the address type ("to", "cc", "bcc", or "from") as a String
throws
NullPointerException if type is null
throws
java.lang.IllegalArgumentException if type is none of "to", "cc", "bcc", or "from"

public booleanremoveMessagePart(MessagePart part)
Removes a MessagePart from the multipart message.

param
part MessagePart to delete
return
true if it was possible to remove the MessagePart, else false
throws
NullPointerException if the parameter is null

public booleanremoveMessagePartId(java.lang.String contentID)
Removes a MessagePart with the specific contentID from the multipart message.

param
contentID identifies which MessagePart must be deleted.
return
true if it was possible to remove the MessagePart, else false
throws
NullPointerException if the parameter is null

public booleanremoveMessagePartLocation(java.lang.String contentLocation)
Removes MessageParts with the specific content location from the multipart message. All MessageParts with the specified contentLocation are removed.

param
contentLocation content location (file name) of the MessagePart
return
true if it was possible to remove the MessagePart, else false
throws
NullPointerException if the parameter is null

public voidsetAddress(java.lang.String addr)
Sets the "to" address associated with this message. It works the same way as addAddress("to", addr). The address may be set to null.

param
addr address for the message
see
#getAddress()
see
#addAddress(String, String)

public voidsetHeader(java.lang.String headerField, java.lang.String headerValue)
Sets the specified header of the multipart message. The header value can be null.

param
headerField the name of the header field as a String
param
headerValue the value of the header as a String
throws
java.lang.IllegalArgumentException if headerField is unknown, or if headerValue is not correct (depends on headerField!)
throws
NullPointerException if headerField is null
throws
SecurityException if the access to specified header field is restricted
see
#getHeader(String)
see
Appendix D

public voidsetStartContentId(java.lang.String contentId)
Sets the Content-ID of the start MessagePart of a multipart related message. The Content-ID may be set to null. The StartContentId is set for the MessagePart that is used to reference the other MessageParts of the MultipartMessage for presentation or processing purposes.

param
contentId as a String
throws
java.lang.IllegalArgumentException if contentId is none of the added MessagePart objects matches the contentId
see
#getStartContentId()

public voidsetSubject(java.lang.String subject)
Sets the Subject of the multipart message. This value can be null.

param
subject the message subject as a String
see
#getSubject()