|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.james.core.MailImpl
public class MailImpl
Wraps a MimeMessage adding routing information (from SMTP) and some simple API enhancements.
From James version > 2.2.0a8 "mail attributes" have been added. Backward and forward compatibility is supported: messages stored in file repositories without attributes by James version <= 2.2.0a8 will be processed by later versions as having an empty attributes hashmap; messages stored in file repositories with attributes by James version > 2.2.0a8 will be processed by previous versions, ignoring the attributes.
Field Summary | |
---|---|
static long |
serialVersionUID
We hardcode the serialVersionUID so that from James 1.2 on, MailImpl will be deserializable (so your mail doesn't get lost) |
Fields inherited from interface org.apache.mailet.Mail |
---|
DEFAULT, ERROR, GHOST, TRANSPORT |
Constructor Summary | |
---|---|
MailImpl()
A constructor that creates a new, uninitialized MailImpl |
|
MailImpl(org.apache.mailet.Mail mail)
Create a copy of the input mail and assign it a new name |
|
MailImpl(org.apache.mailet.Mail mail,
java.lang.String newName)
|
|
MailImpl(java.lang.String name,
org.apache.mailet.MailAddress sender,
java.util.Collection recipients)
A constructor that creates a MailImpl with the specified name, sender, and recipients. |
|
MailImpl(java.lang.String name,
org.apache.mailet.MailAddress sender,
java.util.Collection recipients,
java.io.InputStream messageIn)
A constructor that creates a MailImpl with the specified name, sender, recipients, and message data. |
|
MailImpl(java.lang.String name,
org.apache.mailet.MailAddress sender,
java.util.Collection recipients,
javax.mail.internet.MimeMessage message)
A constructor that creates a MailImpl with the specified name, sender, recipients, and MimeMessage. |
Method Summary | |
---|---|
void |
dispose()
|
org.apache.mailet.Mail |
duplicate()
Duplicate the MailImpl. |
org.apache.mailet.Mail |
duplicate(java.lang.String newName)
Duplicate the MailImpl, replacing the mail name with the one passed in as an argument. |
java.io.Serializable |
getAttribute(java.lang.String key)
|
java.util.Iterator |
getAttributeNames()
|
java.util.HashMap |
getAttributesRaw()
This method is necessary, when Mail repositories needs to deal explicitly with storing Mail attributes as a Serializable Note: This method is not exposed in the Mail interface, it is for internal use by James only. |
java.lang.String |
getErrorMessage()
Get the error message associated with this MailImpl. |
java.util.Date |
getLastUpdated()
Get the last updated time for this MailImpl. |
javax.mail.internet.MimeMessage |
getMessage()
Get the MimeMessage associated with this MailImpl. |
long |
getMessageSize()
Return the size of the message including its headers. |
java.lang.String |
getName()
Get the name of this MailImpl. |
java.util.Collection |
getRecipients()
Get the recipients of this MailImpl. |
java.lang.String |
getRemoteAddr()
Get the remote address associated with this MailImpl. |
java.lang.String |
getRemoteHost()
Get the remote host associated with this MailImpl. |
org.apache.mailet.MailAddress |
getSender()
Get the sender of this MailImpl. |
java.lang.String |
getState()
Get the state of this MailImpl. |
boolean |
hasAttributes()
|
static java.lang.String |
newName(org.apache.mailet.Mail mail)
Create a unique new primary key name for the given MailObject. |
void |
removeAllAttributes()
|
java.io.Serializable |
removeAttribute(java.lang.String key)
|
java.io.Serializable |
setAttribute(java.lang.String key,
java.io.Serializable object)
|
void |
setAttributesRaw(java.util.HashMap attr)
This method is necessary, when Mail repositories needs to deal explicitly with retriving Mail attributes as a Serializable Note: This method is not exposed in the Mail interface, it is for internal use by James only. |
void |
setErrorMessage(java.lang.String msg)
Set the error message associated with this MailImpl. |
void |
setLastUpdated(java.util.Date lastUpdated)
Set the date this mail was last updated. |
void |
setMessage(javax.mail.internet.MimeMessage message)
Set the MimeMessage associated with this MailImpl. |
void |
setName(java.lang.String name)
Set the name of this MailImpl. |
void |
setRecipients(java.util.Collection recipients)
Set the recipients for this MailImpl. |
void |
setRemoteAddr(java.lang.String remoteAddr)
Set the remote address associated with this MailImpl. |
void |
setRemoteHost(java.lang.String remoteHost)
Set the remote address associated with this MailImpl. |
void |
setSender(org.apache.mailet.MailAddress sender)
Set the sender of this MailImpl. |
void |
setState(java.lang.String state)
Set the state of this MailImpl. |
void |
writeMessageTo(java.io.OutputStream out)
Writes the message out to an OutputStream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long serialVersionUID
Constructor Detail |
---|
public MailImpl()
public MailImpl(java.lang.String name, org.apache.mailet.MailAddress sender, java.util.Collection recipients)
name
- the name of the MailImplsender
- the sender for this MailImplrecipients
- the collection of recipients of this MailImplpublic MailImpl(org.apache.mailet.Mail mail) throws javax.mail.MessagingException
mail
- original mail
javax.mail.MessagingException
- when the message is not clonablepublic MailImpl(org.apache.mailet.Mail mail, java.lang.String newName) throws javax.mail.MessagingException
mail
- newName
-
javax.mail.MessagingException
public MailImpl(java.lang.String name, org.apache.mailet.MailAddress sender, java.util.Collection recipients, java.io.InputStream messageIn) throws javax.mail.MessagingException
name
- the name of the MailImplsender
- the sender for this MailImplrecipients
- the collection of recipients of this MailImplmessageIn
- a stream containing the message source
javax.mail.MessagingException
public MailImpl(java.lang.String name, org.apache.mailet.MailAddress sender, java.util.Collection recipients, javax.mail.internet.MimeMessage message) throws javax.mail.MessagingException
name
- the name of the MailImplsender
- the sender for this MailImplrecipients
- the collection of recipients of this MailImplmessage
- the MimeMessage associated with this MailImpl
javax.mail.MessagingException
Method Detail |
---|
public org.apache.mailet.Mail duplicate()
public org.apache.mailet.Mail duplicate(java.lang.String newName)
newName
- the name for the duplicated mail
public java.lang.String getErrorMessage()
getErrorMessage
in interface org.apache.mailet.Mail
public javax.mail.internet.MimeMessage getMessage() throws javax.mail.MessagingException
getMessage
in interface org.apache.mailet.Mail
javax.mail.MessagingException
public void setName(java.lang.String name)
setName
in interface org.apache.mailet.Mail
name
- the name of this MailImplpublic java.lang.String getName()
getName
in interface org.apache.mailet.Mail
public java.util.Collection getRecipients()
getRecipients
in interface org.apache.mailet.Mail
public org.apache.mailet.MailAddress getSender()
getSender
in interface org.apache.mailet.Mail
public java.lang.String getState()
getState
in interface org.apache.mailet.Mail
public java.lang.String getRemoteHost()
getRemoteHost
in interface org.apache.mailet.Mail
public java.lang.String getRemoteAddr()
getRemoteAddr
in interface org.apache.mailet.Mail
public java.util.Date getLastUpdated()
getLastUpdated
in interface org.apache.mailet.Mail
public long getMessageSize() throws javax.mail.MessagingException
Return the size of the message including its headers. MimeMessage.getSize() method only returns the size of the message body.
Note: this size is not guaranteed to be accurate - see Sun's documentation of MimeMessage.getSize().
getMessageSize
in interface org.apache.mailet.Mail
javax.mail.MessagingException
- if a problem occurs while computing the message sizepublic void setErrorMessage(java.lang.String msg)
setErrorMessage
in interface org.apache.mailet.Mail
msg
- the new error message associated with this MailImplpublic void setMessage(javax.mail.internet.MimeMessage message)
setMessage
in interface org.apache.mailet.Mail
message
- the new MimeMessage associated with this MailImplpublic void setRecipients(java.util.Collection recipients)
setRecipients
in interface org.apache.mailet.Mail
recipients
- the recipients for this MailImplpublic void setSender(org.apache.mailet.MailAddress sender)
sender
- the sender of this MailImplpublic void setState(java.lang.String state)
setState
in interface org.apache.mailet.Mail
state
- the state of this MailImplpublic void setRemoteHost(java.lang.String remoteHost)
remoteHost
- the new remote host associated with this MailImplpublic void setRemoteAddr(java.lang.String remoteAddr)
remoteAddr
- the new remote address associated with this MailImplpublic void setLastUpdated(java.util.Date lastUpdated)
setLastUpdated
in interface org.apache.mailet.Mail
lastUpdated
- the date the mail was last updatedpublic void writeMessageTo(java.io.OutputStream out) throws java.io.IOException, javax.mail.MessagingException
out
- the OutputStream to which to write the content
javax.mail.MessagingException
- if the MimeMessage is not set for this MailImpl
java.io.IOException
- if an error occurs while reading or writing from the streampublic void dispose()
dispose
in interface org.apache.avalon.framework.activity.Disposable
Disposable.dispose()
public java.util.HashMap getAttributesRaw()
public void setAttributesRaw(java.util.HashMap attr)
attr
- Serializable of the entire attributes collectionpublic java.io.Serializable getAttribute(java.lang.String key)
getAttribute
in interface org.apache.mailet.Mail
Mail.getAttribute(String)
public java.io.Serializable setAttribute(java.lang.String key, java.io.Serializable object)
setAttribute
in interface org.apache.mailet.Mail
Mail.setAttribute(String,Serializable)
public java.io.Serializable removeAttribute(java.lang.String key)
removeAttribute
in interface org.apache.mailet.Mail
Mail.removeAttribute(String)
public void removeAllAttributes()
removeAllAttributes
in interface org.apache.mailet.Mail
Mail.removeAllAttributes()
public java.util.Iterator getAttributeNames()
getAttributeNames
in interface org.apache.mailet.Mail
Mail.getAttributeNames()
public boolean hasAttributes()
hasAttributes
in interface org.apache.mailet.Mail
Mail.hasAttributes()
public static java.lang.String newName(org.apache.mailet.Mail mail) throws javax.mail.MessagingException
mail
- the mail to use as the basis for the new mail name
javax.mail.MessagingException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |