|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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(Mail mail,
java.lang.String newName)
|
|
MailImpl(javax.mail.internet.MimeMessage message)
A constructor which will attempt to obtain sender and recipients from the headers of the MimeMessage supplied. |
|
MailImpl(java.lang.String name,
MailAddress sender,
java.util.Collection recipients)
A constructor that creates a MailImpl with the specified name, sender, and recipients. |
|
MailImpl(java.lang.String name,
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,
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()
|
Mail |
duplicate()
Duplicate the MailImpl. |
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)
Returns the Mail session attribute with the given name, or null if there is no attribute by that name. |
java.util.Iterator |
getAttributeNames()
Returns an Iterator containing the attribute names currently available within this Mail instance. |
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. |
MailAddress |
getSender()
Get the sender of this MailImpl. |
java.lang.String |
getState()
Get the state of this MailImpl. |
boolean |
hasAttributes()
|
void |
removeAllAttributes()
Removes all the attributes associated with this Mail instance. |
java.io.Serializable |
removeAttribute(java.lang.String key)
Removes the attribute with the given name from this Mail instance. |
java.io.Serializable |
setAttribute(java.lang.String key,
java.io.Serializable object)
Binds an object to a given attribute name in this Mail instance. |
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(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, 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(Mail mail, java.lang.String newName) throws javax.mail.MessagingException
mail
- newName
-
javax.mail.MessagingException
public MailImpl(java.lang.String name, 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, 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
public MailImpl(javax.mail.internet.MimeMessage message) throws javax.mail.MessagingException
message
- - a MimeMessage from which to construct a Mail
javax.mail.MessagingException
Method Detail |
---|
public Mail duplicate()
public Mail duplicate(java.lang.String newName)
newName
- the name for the duplicated mail
public java.lang.String getErrorMessage()
getErrorMessage
in interface Mail
public javax.mail.internet.MimeMessage getMessage() throws javax.mail.MessagingException
getMessage
in interface Mail
javax.mail.MessagingException
- - an error occured while loading this objectpublic void setName(java.lang.String name)
setName
in interface Mail
name
- the name of this MailImplpublic java.lang.String getName()
getName
in interface Mail
public java.util.Collection getRecipients()
getRecipients
in interface Mail
public MailAddress getSender()
getSender
in interface Mail
public java.lang.String getState()
getState
in interface Mail
public java.lang.String getRemoteHost()
getRemoteHost
in interface Mail
public java.lang.String getRemoteAddr()
getRemoteAddr
in interface Mail
public java.util.Date getLastUpdated()
getLastUpdated
in interface 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 Mail
javax.mail.MessagingException
- if a problem occurs while computing the message sizepublic void setErrorMessage(java.lang.String msg)
setErrorMessage
in interface Mail
msg
- the new error message associated with this MailImplpublic void setMessage(javax.mail.internet.MimeMessage message)
setMessage
in interface Mail
message
- the new MimeMessage associated with this MailImplpublic void setRecipients(java.util.Collection recipients)
setRecipients
in interface Mail
recipients
- the recipients for this MailImplpublic void setSender(MailAddress sender)
sender
- the sender of this MailImplpublic void setState(java.lang.String state)
setState
in interface 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 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)
public java.io.Serializable getAttribute(java.lang.String key)
Mail
A list of currently set attributes can be retrieved using getAttributeNames.
The attribute is returned as a java.lang.Object or some subclass. Attribute names should follow the same convention as package names. The Mailet API specification reserves names matching org.apache.james.* and org.apache.mailet.*.
getAttribute
in interface Mail
key
- - a String specifying the name of the attribute
Mail.getAttribute(String)
public java.io.Serializable setAttribute(java.lang.String key, java.io.Serializable object)
Mail
Attribute names should follow the same convention as package names. The Mailet API specification reserves names matching org.apache.james.* and org.apache.mailet.*.
setAttribute
in interface Mail
key
- - a String specifying the name of the attributeobject
- - a Serializable Object representing the attribute to be bound
Mail.setAttribute(String,Serializable)
public java.io.Serializable removeAttribute(java.lang.String key)
Mail
removeAttribute
in interface Mail
key
- - a String specifying the name of the attribute to be removed
Mail.removeAttribute(String)
public void removeAllAttributes()
Mail
removeAllAttributes
in interface Mail
Mail.removeAllAttributes()
public java.util.Iterator getAttributeNames()
Mail
getAttributeNames
in interface Mail
Mail.getAttributeNames()
public boolean hasAttributes()
hasAttributes
in interface Mail
Mail.hasAttributes()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |