public class MimeMessageWrapper extends javax.mail.internet.MimeMessage implements Disposable
Modifier and Type | Field and Description |
---|---|
protected boolean |
bodyModified
This is false until we parse the message
|
protected boolean |
headersModified
This is false until we parse the message
|
protected boolean |
messageParsed
This is false until we parse the message
|
protected MimeMessageSource |
source
Can provide an input stream to the data
|
static String |
USE_MEMORY_COPY
System property which tells JAMES if it should copy a message in memory
or via a temporary file.
|
Constructor and Description |
---|
MimeMessageWrapper(javax.mail.internet.MimeMessage original) |
MimeMessageWrapper(MimeMessageSource source)
A constructor that instantiates a MimeMessageWrapper based on a
MimeMessageSource
|
MimeMessageWrapper(javax.mail.Session session,
MimeMessageSource source)
A constructor that instantiates a MimeMessageWrapper based on a
MimeMessageSource
|
Modifier and Type | Method and Description |
---|---|
void |
addHeader(String name,
String value) |
void |
addHeaderLine(String line) |
protected javax.mail.internet.InternetHeaders |
createInternetHeaders(InputStream is)
If we already parsed the headers then we simply return the updated ones.
|
void |
dispose()
Dispose the object
|
Enumeration |
getAllHeaderLines() |
Enumeration |
getAllHeaders() |
protected InputStream |
getContentStream() |
String[] |
getHeader(String name)
We override all the "headers" access methods to be sure that we loaded
the headers
|
String |
getHeader(String name,
String delimiter) |
int |
getLineCount()
Corrects JavaMail 1.1 version which always returns -1.
|
Enumeration |
getMatchingHeaderLines(String[] names) |
Enumeration |
getMatchingHeaders(String[] names) |
InputStream |
getMessageInputStream()
Return an
InputStream which holds the full content of the
message. |
long |
getMessageSize()
Returns size of message, ie headers and content
|
Enumeration |
getNonMatchingHeaderLines(String[] names) |
Enumeration |
getNonMatchingHeaders(String[] names) |
InputStream |
getRawInputStream() |
int |
getSize()
This is the MimeMessage implementation - this should return ONLY the
body, not the entire message (should not count headers).
|
String |
getSourceId()
Returns the source ID of the MimeMessageSource that is supplying this
with data.
|
boolean |
isBodyModified()
Get whether the body of the message has been modified
|
boolean |
isHeaderModified()
Get whether the header of the message has been modified
|
boolean |
isModified()
Get whether the message has been modified.
|
protected void |
loadHeaders()
Load the message headers from the internal source.
|
void |
loadMessage()
Load the complete MimeMessage from the internal source.
|
protected void |
parse(InputStream is) |
void |
removeHeader(String name) |
void |
setDataHandler(DataHandler arg0)
The message is changed when working with headers and when altering the
content.
|
void |
setHeader(String name,
String value) |
protected void |
updateMessageID()
Overrides default javamail behaviour by not altering the Message-ID by
default, see JAMES-875 and
JAMES-1010
|
void |
writeTo(OutputStream os)
Rewritten for optimization purposes
|
void |
writeTo(OutputStream headerOs,
OutputStream bodyOs)
Write
|
void |
writeTo(OutputStream headerOs,
OutputStream bodyOs,
String[] ignoreList) |
void |
writeTo(OutputStream headerOs,
OutputStream bodyOs,
String[] ignoreList,
boolean preLoad) |
void |
writeTo(OutputStream os,
String[] ignoreList)
Rewritten for optimization purposes
|
addFrom, addRecipients, addRecipients, createMimeMessage, getAllRecipients, getContent, getContentID, getContentLanguage, getContentMD5, getContentType, getDataHandler, getDescription, getDisposition, getEncoding, getFileName, getFlags, getFrom, getInputStream, getMessageID, getReceivedDate, getRecipients, getReplyTo, getSender, getSentDate, getSubject, isMimeType, isSet, reply, saveChanges, setContent, setContent, setContentID, setContentLanguage, setContentMD5, setDescription, setDescription, setDisposition, setFileName, setFlags, setFrom, setFrom, setRecipients, setRecipients, setReplyTo, setSender, setSentDate, setSubject, setSubject, setText, setText, setText, updateHeaders
public static final String USE_MEMORY_COPY
protected MimeMessageSource source
protected boolean messageParsed
protected boolean headersModified
protected boolean bodyModified
public MimeMessageWrapper(javax.mail.Session session, MimeMessageSource source) throws javax.mail.MessagingException
source
- the MimeMessageSourcejavax.mail.MessagingException
public MimeMessageWrapper(MimeMessageSource source) throws javax.mail.MessagingException
source
- the MimeMessageSourcejavax.mail.MessagingException
javax.mail.MessagingException
public MimeMessageWrapper(javax.mail.internet.MimeMessage original) throws javax.mail.MessagingException
javax.mail.MessagingException
protected void updateMessageID() throws javax.mail.MessagingException
updateMessageID
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
MimeMessage.updateMessageID()
public String getSourceId()
MimeMessageSource
protected void loadHeaders() throws javax.mail.MessagingException
javax.mail.MessagingException
- if an error is encountered while loading the headerspublic void loadMessage() throws javax.mail.MessagingException
javax.mail.MessagingException
- if an error is encountered while loading the messagepublic boolean isModified()
public boolean isBodyModified()
public boolean isHeaderModified()
public void writeTo(OutputStream os) throws IOException, javax.mail.MessagingException
writeTo
in interface javax.mail.Part
writeTo
in class javax.mail.internet.MimeMessage
IOException
javax.mail.MessagingException
public void writeTo(OutputStream os, String[] ignoreList) throws IOException, javax.mail.MessagingException
writeTo
in class javax.mail.internet.MimeMessage
IOException
javax.mail.MessagingException
public void writeTo(OutputStream headerOs, OutputStream bodyOs) throws IOException, javax.mail.MessagingException
IOException
javax.mail.MessagingException
public void writeTo(OutputStream headerOs, OutputStream bodyOs, String[] ignoreList) throws IOException, javax.mail.MessagingException
IOException
javax.mail.MessagingException
public void writeTo(OutputStream headerOs, OutputStream bodyOs, String[] ignoreList, boolean preLoad) throws IOException, javax.mail.MessagingException
IOException
javax.mail.MessagingException
public int getSize() throws javax.mail.MessagingException
MimeMessage.saveChanges()
getSize
in interface javax.mail.Part
getSize
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
public int getLineCount() throws javax.mail.MessagingException
getLineCount
in interface javax.mail.Part
getLineCount
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
public long getMessageSize() throws javax.mail.MessagingException
javax.mail.MessagingException
public String[] getHeader(String name) throws javax.mail.MessagingException
getHeader
in interface javax.mail.Part
getHeader
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
public String getHeader(String name, String delimiter) throws javax.mail.MessagingException
getHeader
in interface javax.mail.internet.MimePart
getHeader
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
public Enumeration getAllHeaders() throws javax.mail.MessagingException
getAllHeaders
in interface javax.mail.Part
getAllHeaders
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
public Enumeration getMatchingHeaders(String[] names) throws javax.mail.MessagingException
getMatchingHeaders
in interface javax.mail.Part
getMatchingHeaders
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
public Enumeration getNonMatchingHeaders(String[] names) throws javax.mail.MessagingException
getNonMatchingHeaders
in interface javax.mail.Part
getNonMatchingHeaders
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
public Enumeration getAllHeaderLines() throws javax.mail.MessagingException
getAllHeaderLines
in interface javax.mail.internet.MimePart
getAllHeaderLines
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
public Enumeration getMatchingHeaderLines(String[] names) throws javax.mail.MessagingException
getMatchingHeaderLines
in interface javax.mail.internet.MimePart
getMatchingHeaderLines
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
public Enumeration getNonMatchingHeaderLines(String[] names) throws javax.mail.MessagingException
getNonMatchingHeaderLines
in interface javax.mail.internet.MimePart
getNonMatchingHeaderLines
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
public void setHeader(String name, String value) throws javax.mail.MessagingException
setHeader
in interface javax.mail.Part
setHeader
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
public void addHeader(String name, String value) throws javax.mail.MessagingException
addHeader
in interface javax.mail.Part
addHeader
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
public void removeHeader(String name) throws javax.mail.MessagingException
removeHeader
in interface javax.mail.Part
removeHeader
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
public void addHeaderLine(String line) throws javax.mail.MessagingException
addHeaderLine
in interface javax.mail.internet.MimePart
addHeaderLine
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
public void setDataHandler(DataHandler arg0) throws javax.mail.MessagingException
setDataHandler
in interface javax.mail.Part
setDataHandler
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
Part.setDataHandler(javax.activation.DataHandler)
public void dispose()
Disposable
dispose
in interface Disposable
Disposable.dispose()
protected void parse(InputStream is) throws javax.mail.MessagingException
parse
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
MimeMessage.parse(java.io.InputStream)
protected javax.mail.internet.InternetHeaders createInternetHeaders(InputStream is) throws javax.mail.MessagingException
createInternetHeaders
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
MimeMessage.createInternetHeaders(java.io.InputStream)
protected InputStream getContentStream() throws javax.mail.MessagingException
getContentStream
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
MimeMessage.getContentStream()
public InputStream getRawInputStream() throws javax.mail.MessagingException
getRawInputStream
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
MimeMessage.getRawInputStream()
public InputStream getMessageInputStream() throws javax.mail.MessagingException
InputStream
which holds the full content of the
message. This method tries to optimize this call as far as possible. This
stream contains the updated MimeMessage
content if something was
changedjavax.mail.MessagingException
Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.