com.openexchange.messaging
Interface MessagingPart

All Known Subinterfaces:
MessagingBodyPart, MessagingMessage, ParameterizedMessagingMessage, SimpleMessagePart
All Known Implementing Classes:
SimpleMessagingMessage, SMSMessagingMessage

public interface MessagingPart

MessagingPart - A message part.

Since:
Open-Xchange v6.16
Author:
Francisco Laguna, Thorben Betten

Field Summary
static java.lang.String ATTACHMENT
          The part should be presented as an attachment.
static java.lang.String INLINE
          The part should be presented inline.
 
Method Summary
 MessagingContent getContent()
          Gets the content.
 ContentType getContentType()
          Gets the Content-Type header of this part's content.
 java.lang.String getDisposition()
          Gets the disposition.
 java.lang.String getFileName()
          Get the filename associated with this part, if possible.
 MessagingHeader getFirstHeader(java.lang.String name)
          Gets the first header value associated with specified name or null if not present
 java.util.Collection<MessagingHeader> getHeader(java.lang.String name)
          Gets the header associated with specified name or null if not present
 java.util.Map<java.lang.String,java.util.Collection<MessagingHeader>> getHeaders()
          Gets the headers as an unmodifiable Map.
 java.lang.String getSectionId()
          Gets the section identifier.
 long getSize()
          Get the size of this part in bytes.
 void writeTo(java.io.OutputStream os)
          Writes this part's bytes to given output stream.
 

Field Detail

ATTACHMENT

static final java.lang.String ATTACHMENT
The part should be presented as an attachment.

See Also:
Constant Field Values

INLINE

static final java.lang.String INLINE
The part should be presented inline.

See Also:
Constant Field Values
Method Detail

getHeaders

java.util.Map<java.lang.String,java.util.Collection<MessagingHeader>> getHeaders()
                                                                                 throws MessagingException
Gets the headers as an unmodifiable Map.

Returns:
The headers as an unmodifiable Map.
Throws:
MessagingException - If headers cannot be returned

getHeader

java.util.Collection<MessagingHeader> getHeader(java.lang.String name)
                                                throws MessagingException
Gets the header associated with specified name or null if not present

Parameters:
name - The header name
Returns:
The header associated with specified name or null if not present
Throws:
MessagingException - If header cannot be returned

getFirstHeader

MessagingHeader getFirstHeader(java.lang.String name)
                               throws MessagingException
Gets the first header value associated with specified name or null if not present

Parameters:
name - The header name
Returns:
The first header value associated with specified name or null if not present
Throws:
MessagingException - If header cannot be returned

getDisposition

java.lang.String getDisposition()
                                throws MessagingException
Gets the disposition.

The disposition describes how the part should be presented (see RFC 2183). The return value should be compared case-insensitive. For example:

 String disposition = part.getDisposition();
 if (disposition == null || MessagingPart.ATTACHMENT.equalsIgnoreCase(disposition))
  // treat as attachment if not first part
 

Returns:
The disposition of this part, or null if unknown
Throws:
MessagingException - If disposition cannot be returned
See Also:
ATTACHMENT, INLINE

getContentType

ContentType getContentType()
                           throws MessagingException
Gets the Content-Type header of this part's content. null is returned if the Content-Type header could not be determined.

Returns:
The Content-Type header of this part
Throws:
MessagingException - If content type cannot be returned

getSize

long getSize()
             throws MessagingException
Get the size of this part in bytes. Return -1 if the size cannot be determined.

Returns:
The size of this part or -1
Throws:
MessagingException - If size cannot be returned

getFileName

java.lang.String getFileName()
                             throws MessagingException
Get the filename associated with this part, if possible.

Useful if this part represents an "attachment" that was loaded from a file. The filename will usually be a simple name, not including directory components.

Returns:
The filename to associate with this part
Throws:
MessagingException - If filename cannot be returned

getSectionId

java.lang.String getSectionId()
Gets the section identifier.

Returns:
The section identifier or null if top level

getContent

MessagingContent getContent()
                            throws MessagingException
Gets the content.

Returns:
The content
Throws:
MessagingException - If content cannot be returned

writeTo

void writeTo(java.io.OutputStream os)
             throws java.io.IOException,
                    MessagingException
Writes this part's bytes to given output stream. The bytes are typically an aggregation of the headers and appropriately encoded content bytes.

The bytes are typically used for transport.

Throws:
java.io.IOException - If an I/O error occurs
MessagingException - If an error occurs fetching the data to be written