javax.wireless.messaging
Interface MultipartMessage

All Superinterfaces:
Message

public interface MultipartMessage
extends 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. Additional 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 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:
JDE 4.3.0

Method Summary
 boolean addAddress(String type, String address)
          Adds an address to the multipart message.
 void addMessagePart(MessagePart part)
          Attaches a MessagePart to the multipart message
 String getAddress()
          Returns the “from” address associated with this message, e.g. address of the sender.
 String[] getAddresses(String type)
          Gets the addresses of the multipart message of the specified type.
 String getHeader(String headerField)
          Gets the content of the specific header field of the multipart message.
 MessagePart getMessagePart(String contentID)
          This method returns a MessagePart from the message that matches the content-id passed as a parameter
 MessagePart[] getMessageParts()
          Returns an array of all MessageParts of this message
 String getStartContentId()
          Returns the contentId of the start MessagePart.
 String getSubject()
          Gets the subject of the multipart message.
 boolean removeAddress(String type, String address)
          Removes an address from the multipart message.
 void removeAddresses()
          Removes all addresses of types “to”, “cc”, and bcc“ from the multipart message.
 void removeAddresses(String type)
          Removes all addresses of the specified type from the multipart message.
 boolean removeMessagePart(MessagePart part)
          Removes a MessagePart from the multipart message
 boolean removeMessagePartId(String contentID)
          Removes a MessagePart with the specific contentID from the multipart message
 boolean removeMessagePartLocation(String contentLocation)
          Removes MessageParts with the specific content location from the multipart message.
 void setAddress(String addr)
          Sets the “to” address associated with this message.
 void setHeader(String headerField, String headerValue)
          Sets the specific header of the multipart message.
 void setStartContentId(String contentId)
          Sets the Content-ID of the start MessagePart of a multipart related message.
 void setSubject(String subject)
          Sets the Subject of the multipart message.
 
Methods inherited from interface javax.wireless.messaging.Message
getTimestamp
 

Method Detail

addAddress

public boolean addAddress(String type,
                          String address)
Adds an address to the multipart message.
Parameters:
type - the address type (“to”, “cc” or “bcc”) as a String. Each message can have none or multiple “to”, “cc” and “bcc” addresses. Each address is added separately. The type is not case sensitive. The implementation of MessageConnection.send() makes sure that the “from” address is set correctly.
address - the address as a String
Returns:
true if it was possible to add the address, else false
Throws:
IllegalArgumentException - - if type is none of “to”, “cc”, or “bcc” or if address is not valid.
Since:
JDE 4.3.0

addMessagePart

public void addMessagePart(MessagePart part)
                    throws SizeExceededException
Attaches a MessagePart to the multipart message
Parameters:
part - MessagePart to add
Throws:
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.
NullPointerException - - if the parameter is null
SizeExceededException - - if it’s not possible to attach the MessagePart.
Since:
JDE 4.3.0

getAddress

public String getAddress()
Returns the “from” address associated with this message, e.g. address of the sender. If 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” addresses 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).
Returns:
the “from” or “to” address of this message, or null if the address that is expected as a result of the method is not set
Since:
JDE 4.3.0

getAddresses

public String[] getAddresses(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.
Parameters:
type - “to”, “cc”, “bcc” or “from”
Returns:
the addresses as a String array or null if the address of the specified type is not present.
Since:
JDE 4.3.0

getHeader

public String getHeader(String headerField)
Gets the content of the specific header field of the multipart message.
Parameters:
headerField - the name of the header field as a String
Returns:
the content of the specified header field as a String or null if the specified header field is not present.
Throws:
SecurityException - - if the access to specified header field is restricted
IllegalArgumentException - - if headerField is unknown
Since:
JDE 4.3.0

getMessagePart

public MessagePart getMessagePart(String contentID)
This method returns a MessagePart from the message that matches the content-id passed as a parameter
Parameters:
contentID - the content-id for the MessagePart to be returned
Returns:
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
Since:
JDE 4.3.0

getMessageParts

public MessagePart[] getMessageParts()
Returns an array of all MessageParts of this message
Returns:
array of MessageParts, or null, if no MessageParts are available
Since:
JDE 4.3.0

getStartContentId

public String getStartContentId()
Returns the contentId of the start MessagePart. The start MessagePart is set in setStartContentId(String)
Returns:
the content-id of the start MessagePart or null if the start MessagePart is not set.
Since:
JDE 4.3.0

getSubject

public String getSubject()
Gets the subject of the multipart message.
Returns:
the message subject as a String or null if this value is not present.
Since:
JDE 4.3.0

removeAddress

public boolean removeAddress(String type,
                             String address)
Removes an address from the multipart message.
Parameters:
type - the address type (“to”, “cc”, or “bcc”) as a String.
address - the address as a String
Returns:
true if it was possible to delete the address, else false
Throws:
NullPointerException - - if type is null
IllegalArgumentException - - if type is none of “to”, “cc”, or “bcc”
Since:
JDE 4.3.0

removeAddresses

public void removeAddresses()
Removes all addresses of types “to”, “cc”, and bcc“ from the multipart message.
Since:
JDE 4.3.0

removeAddresses

public void removeAddresses(String type)
Removes all addresses of the specified type from the multipart message.
Parameters:
type - the address type (“to”, “cc”, or “bcc”) as a String.
Throws:
NullPointerException - - if type is null
IllegalArgumentException - - if type is none of “to”, “cc”, or “bcc”
Since:
JDE 4.3.0

removeMessagePart

public boolean removeMessagePart(MessagePart part)
Removes a MessagePart from the multipart message
Parameters:
part - MessagePart to delete
Returns:
true, if it was possible to remove the MessagePart, else false
Throws:
NullPointerException - - if the parameter is null
Since:
JDE 4.3.0

removeMessagePartId

public boolean removeMessagePartId(String contentID)
Removes a MessagePart with the specific contentID from the multipart message
Parameters:
contentID - identifiers which MessagePart must be deleted.
Returns:
true, if it was possible to remove the MessagePart, else false
Throws:
NullPointerException - - if the parameter is null
Since:
JDE 4.3.0

removeMessagePartLocation

public boolean removeMessagePartLocation(String contentLocation)
Removes MessageParts with the specific content location from the multipart message. All MessageParts with the specified contentLocation are removed
Parameters:
contentLocation - content location (file name) of the MessagePart
Returns:
true, if it was possible to remove the MessagePart, else false
Throws:
NullPointerException - - if the parameter is null
Since:
JDE 4.3.0

setAddress

public void setAddress(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.
Parameters:
addr - address for the message
Throws:
IllegalArgumentException - - if address is not valid.
Since:
JDE 4.3.0

setHeader

public void setHeader(String headerField,
                      String headerValue)
Sets the specific header of the multipart message. The header value can be null.
Parameters:
headerField - the name of the header field as a String
headerValue - the value of the header as a String
Throws:
IllegalArgumentException - - if headerField is unknown, or if headerValue is not correct (depends on headerField!)
NullPointerException - - if headerField is null
SecurityException - - if the access to specified header field is restricted
Since:
JDE 4.3.0

setStartContentId

public void setStartContentId(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.
Parameters:
contentId - as a String
Throws:
IllegalArgumentException - - if contentId is none of the added MessageParts objects matches the contentId
Since:
JDE 4.3.0

setSubject

public void setSubject(String subject)
Sets the Subject of the multipart message. This value can be null.
Parameters:
subject - the message subject as a String
Since:
JDE 4.3.0



Copyright 1999-2008 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.