org.apache.mailet
Interface Mail

All Superinterfaces:
java.lang.Cloneable, java.io.Serializable
All Known Implementing Classes:
MailImpl

public interface Mail
extends java.io.Serializable, java.lang.Cloneable

Wrap a MimeMessage with routing information (from SMTP) such as SMTP specified recipients, sender, and ip address and hostname of sending server. It also contains its state which represents which processor in the mailet container it is currently running. Special processor names are "root" and "error".

Version:
CVS $Revision: 494012 $ $Date: 2007-01-08 10:23:58 +0000 (lun, 08 gen 2007) $

Field Summary
static java.lang.String DEFAULT
           
static java.lang.String ERROR
           
static java.lang.String GHOST
           
static java.lang.String TRANSPORT
           
 
Method Summary
 java.io.Serializable getAttribute(java.lang.String name)
          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.lang.String getErrorMessage()
          The error message, if any, associated with this message.
 java.util.Date getLastUpdated()
           
 javax.mail.internet.MimeMessage getMessage()
          Returns the MimeMessage stored in this message
 long getMessageSize()
           
 java.lang.String getName()
          Returns the message name of this message
 java.util.Collection getRecipients()
          Returns a Collection of MailAddress objects that are recipients of this message
 java.lang.String getRemoteAddr()
          The remote ip address of the server that connected to send this message
 java.lang.String getRemoteHost()
          The remote hostname of the server that connected to send this message
 MailAddress getSender()
          The sender of the message, as specified by the MAIL FROM header, or internally defined
 java.lang.String getState()
          The current state of the message, such as GHOST, ERROR, or DEFAULT
 boolean hasAttributes()
           
 void removeAllAttributes()
          Removes all the attributes associated with this Mail instance.
 java.io.Serializable removeAttribute(java.lang.String name)
          Removes the attribute with the given name from this Mail instance.
 java.io.Serializable setAttribute(java.lang.String name, java.io.Serializable object)
          Binds an object to a given attribute name in this Mail instance.
 void setErrorMessage(java.lang.String msg)
          Sets the error message associated with this message.
 void setLastUpdated(java.util.Date lastUpdated)
           
 void setMessage(javax.mail.internet.MimeMessage message)
          Sets the MimeMessage associated with this message via the object.
 void setName(java.lang.String newName)
          Set the message name of this message
 void setRecipients(java.util.Collection recipients)
          Method setRecipients.
 void setState(java.lang.String state)
          Sets the state of this message.
 

Field Detail

GHOST

static final java.lang.String GHOST
See Also:
Constant Field Values

DEFAULT

static final java.lang.String DEFAULT
See Also:
Constant Field Values

ERROR

static final java.lang.String ERROR
See Also:
Constant Field Values

TRANSPORT

static final java.lang.String TRANSPORT
See Also:
Constant Field Values
Method Detail

getName

java.lang.String getName()
Returns the message name of this message

Returns:
the message name
Since:
Mailet API v2.3

setName

void setName(java.lang.String newName)
Set the message name of this message

Parameters:
newName - new name
Since:
Mailet API v2.3

getMessage

javax.mail.internet.MimeMessage getMessage()
                                           throws javax.mail.MessagingException
Returns the MimeMessage stored in this message

Returns:
the MimeMessage that this Mail object wraps
Throws:
javax.mail.MessagingException - - an error occured while loading this object

getRecipients

java.util.Collection getRecipients()
Returns a Collection of MailAddress objects that are recipients of this message

Returns:
a Collection of MailAddress objects that are recipients of this message

setRecipients

void setRecipients(java.util.Collection recipients)
Method setRecipients.

Parameters:
recipients - a Collection of MailAddress Objects representing the recipients of this message
Since:
Mailet API v3.0-unstable

getSender

MailAddress getSender()
The sender of the message, as specified by the MAIL FROM header, or internally defined

Returns:
a MailAddress of the sender of this message

getState

java.lang.String getState()
The current state of the message, such as GHOST, ERROR, or DEFAULT

Returns:
the state of this message

getRemoteHost

java.lang.String getRemoteHost()
The remote hostname of the server that connected to send this message

Returns:
a String of the hostname of the server that connected to send this message

getRemoteAddr

java.lang.String getRemoteAddr()
The remote ip address of the server that connected to send this message

Returns:
a String of the ip address of the server that connected to send this message

getErrorMessage

java.lang.String getErrorMessage()
The error message, if any, associated with this message. Not sure why this is needed.

Returns:
a String of a descriptive error message

setErrorMessage

void setErrorMessage(java.lang.String msg)
Sets the error message associated with this message. Not sure why this is needed.

Parameters:
msg - - a descriptive error message

setMessage

void setMessage(javax.mail.internet.MimeMessage message)
Sets the MimeMessage associated with this message via the object.

Parameters:
message - - the new MimeMessage that this Mail object will wrap

setState

void setState(java.lang.String state)
Sets the state of this message.

Parameters:
state - - the new state of this message

getAttribute

java.io.Serializable getAttribute(java.lang.String name)
Returns the Mail session attribute with the given name, or null if there is no attribute by that name. An attribute allows a mailet to give this Mail instance additional information not already provided by this interface.

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.*.

Parameters:
name - - a String specifying the name of the attribute
Returns:
an Object containing the value of the attribute, or null if no attribute exists matching the given name
Since:
Mailet API v2.1

getAttributeNames

java.util.Iterator getAttributeNames()
Returns an Iterator containing the attribute names currently available within this Mail instance. Use the getAttribute(java.lang.String) method with an attribute name to get the value of an attribute.

Returns:
an Iterator of attribute names
Since:
Mailet API v2.1

hasAttributes

boolean hasAttributes()
Returns:
true if this Mail instance has any attributes set.
Since:
Mailet API v2.1

removeAttribute

java.io.Serializable removeAttribute(java.lang.String name)
Removes the attribute with the given name from this Mail instance. After removal, subsequent calls to getAttribute(java.lang.String) to retrieve the attribute's value will return null.

Parameters:
name - - a String specifying the name of the attribute to be removed
Returns:
previous attribute value associated with specified name, or null if there was no mapping for name (null can also mean that null was bound to the name)
Since:
Mailet API v2.1

removeAllAttributes

void removeAllAttributes()
Removes all the attributes associated with this Mail instance.

Since:
Mailet API v2.1

setAttribute

java.io.Serializable setAttribute(java.lang.String name,
                                  java.io.Serializable object)
Binds an object to a given attribute name in this Mail instance. If the name specified is already used for an attribute, this method will remove the old attribute and bind the name to the new attribute. As instances of Mail is Serializable, it is necessary that the attributes being Serializable as well

Attribute names should follow the same convention as package names. The Mailet API specification reserves names matching org.apache.james.* and org.apache.mailet.*.

Parameters:
name - - a String specifying the name of the attribute
object - - a Serializable Object representing the attribute to be bound
Returns:
the object previously bound to the name, null if the name was not bound (null can also mean that null was bound to the name)
Since:
Mailet API v2.1

getMessageSize

long getMessageSize()
                    throws javax.mail.MessagingException
Returns:
message size
Throws:
javax.mail.MessagingException
Since:
Mailet API v2.3

getLastUpdated

java.util.Date getLastUpdated()
Returns:
the last update date
Since:
Mailet API v2.3

setLastUpdated

void setLastUpdated(java.util.Date lastUpdated)
Parameters:
lastUpdated - the new last updated date
Since:
Mailet API v2.3


Copyright © 2002-2007 The Apache Software Foundation. All Rights Reserved.