public abstract class TextBodyMailPart extends MailPart implements ComposedMailPart
TextBodyMailPart
- Designed to keep a mail's (text) body while offering a suitable implementation of MailPart
ComposedMailPart.ComposedPartType
NO_ENCLOSED_PARTS
Constructor and Description |
---|
TextBodyMailPart(java.lang.String mailBody)
Constructs a new
TextBodyMailPart
The body part is supposed to be HTML content which is ought to be converted to appropriate MIME type on transport. |
Modifier and Type | Method and Description |
---|---|
void |
append(java.lang.String html)
Appends specified HTML text to this part.
|
void |
appendPlainText(java.lang.String text)
Appends specified plain text to this part.
|
abstract TextBodyMailPart |
copy()
Gets a copy of this
TextBodyMailPart . |
java.lang.Object |
getContent()
Returns the part's content as a Java object dependent on underlying implementation.
|
javax.activation.DataHandler |
getDataHandler()
Returns an appropriate
DataHandler for this mail part. |
int |
getEnclosedCount()
Gets the number of enclosed mail parts.
|
MailPart |
getEnclosedMailPart(int index)
Gets the mail part located at given index.
|
java.lang.String |
getHTML()
Gets this part's HTML text.
|
java.io.InputStream |
getInputStream()
Returns an input stream for this part.
|
java.lang.String |
getPlainText()
Gets this part's optional plain text.
|
ComposedMailPart.ComposedPartType |
getType() |
void |
loadContent()
Ensures that the part's content is loaded, thus this part is independent of the original.
|
void |
prepareForCaching()
Prepares this mail part to be put into cache; meaning to release all kept resources
|
void |
setPlainText(java.lang.String text)
Sets this part's optional plain text.
|
void |
setText(java.lang.String mailBody)
Sets this part's text.
|
addHeader, addHeaders, clone, containsContentDisposition, containsContentId, containsContentType, containsFileName, containsHeader, containsHeaders, containsMsgref, containsSequenceId, containsSize, getContentDisposition, getContentId, getContentType, getFileName, getFirstHeader, getHeader, getHeader, getHeader, getHeaders, getHeadersIterator, getHeadersSize, getMatchingHeaders, getMsgref, getNonMatchingHeaders, getSequenceId, getSize, getSource, getSourceBytes, hasEnclosedParts, hasHeaders, removeContentDisposition, removeContentId, removeContentType, removeFileName, removeHeader, removeHeaders, removeMsgref, removeSequenceId, removeSize, setContentDisposition, setContentDisposition, setContentId, setContentType, setContentType, setFileName, setHeader, setMsgref, setSequenceId, setSize, writeTo
public TextBodyMailPart(java.lang.String mailBody)
TextBodyMailPart
The body part is supposed to be HTML content which is ought to be converted to appropriate MIME type on transport.
mailBody
- The mail body as HTML contentpublic abstract TextBodyMailPart copy() throws com.openexchange.exception.OXException
TextBodyMailPart
.com.openexchange.exception.OXException
- If creating a copy failspublic void setText(java.lang.String mailBody)
The body part is supposed to be HTML content which is ought to be converted to appropriate MIME type on transport.
mailBody
- The mail body as HTML contentpublic void append(java.lang.String html)
html
- The HTML text to appendpublic void setPlainText(java.lang.String text)
text
- The mail body as plain textpublic java.lang.String getPlainText()
null
public java.lang.String getHTML()
null
public void appendPlainText(java.lang.String text)
text
- The plain text to appendpublic java.lang.Object getContent() throws com.openexchange.exception.OXException
MailPart
multipart/*
getContent
in class MailPart
null
if not applicablecom.openexchange.exception.OXException
- If content cannot be returned as a Java objectpublic javax.activation.DataHandler getDataHandler() throws com.openexchange.exception.OXException
MailPart
DataHandler
for this mail part. multipart/*
getDataHandler
in class MailPart
DataHandler
or null
if not applicablecom.openexchange.exception.OXException
- If an appropriate DataHandler
cannot be returnedpublic int getEnclosedCount() throws com.openexchange.exception.OXException
MailPart
multipart/*
getEnclosedCount
in class MailPart
MailPart.NO_ENCLOSED_PARTS
if not applicablecom.openexchange.exception.OXException
MailPart.NO_ENCLOSED_PARTS
public MailPart getEnclosedMailPart(int index) throws com.openexchange.exception.OXException
MailPart
multipart/*
getEnclosedMailPart
in class MailPart
index
- The index of desired mail part or null
if not applicablecom.openexchange.exception.OXException
public java.io.InputStream getInputStream() throws com.openexchange.exception.OXException
MailPart
multipart/*
getInputStream
in class MailPart
null
if not applicablecom.openexchange.exception.OXException
- If no input stream could be returnedpublic void loadContent()
MailPart
This method is intended for mailing systems that read the contents stepwise on demand. If dealing with such a mail part with its underlying connection closed, the part's content is no more accessible. Otherwise this method may be implemented with an empty body.
Moreover the loaded content is no more discarded when MailPart.prepareForCaching()
is invoked.
loadContent
in class MailPart
public void prepareForCaching()
MailPart
prepareForCaching
in class MailPart
public ComposedMailPart.ComposedPartType getType()
getType
in interface ComposedMailPart
ComposedMailPart.ComposedPartType
enumeration type