org.apache.mailet
Interface Mail

All Superinterfaces:
Cloneable, Serializable

public interface Mail
extends Serializable, 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: 1.3.4.5 $ $Date: 2004/03/15 03:54:24 $

Field Summary
static String DEFAULT
           
static String ERROR
           
static String GHOST
           
static String TRANSPORT
           
 
Method Summary
 Serializable getAttribute(String name)
          Returns the Mail session attribute with the given name, or null if there is no attribute by that name.
 Iterator getAttributeNames()
          Returns an Iterator containing the attribute names currently available within this Mail instance.
 String getErrorMessage()
          The error message, if any, associated with this message.
 MimeMessage getMessage()
          Returns the MimeMessage stored in this message
 Collection getRecipients()
          Returns a Collection of MailAddress objects that are recipients of this message
 String getRemoteAddr()
          The remote ip address of the server that connected to send this message
 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
 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.
 Serializable removeAttribute(String name)
          Removes the attribute with the given name from this Mail instance.
 Serializable setAttribute(String name, Serializable object)
          Binds an object to a given attribute name in this Mail instance.
 void setErrorMessage(String msg)
          Sets the error message associated with this message.
 void setMessage(MimeMessage message)
          Sets the MimeMessage associated with this message via the object.
 void setState(String state)
          Sets the state of this message.
 

Field Detail

GHOST

public static final String GHOST
See Also:
Constant Field Values

DEFAULT

public static final String DEFAULT
See Also:
Constant Field Values

ERROR

public static final String ERROR
See Also:
Constant Field Values

TRANSPORT

public static final String TRANSPORT
See Also:
Constant Field Values
Method Detail

getMessage

public MimeMessage getMessage()
                       throws MessagingException
Returns the MimeMessage stored in this message

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

getRecipients

public 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

getSender

public 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

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

Returns:
the state of this message

getRemoteHost

public 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

public 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

public 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

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

Parameters:
msg - - a descriptive error message

setMessage

public void setMessage(MimeMessage message)
Sets the MimeMessage associated with this message via the object.

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

setState

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

Parameters:
state - - the new state of this message

getAttribute

public Serializable getAttribute(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 Java Mailet API specification reserves names matching java.*, javax.*, and sun.*

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

public 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

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

removeAttribute

public Serializable removeAttribute(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

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

Since:
Mailet API v2.1

setAttribute

public Serializable setAttribute(String name,
                                 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


"Copyright © 1999-2003 ASF James Project. All Rights Reserved."