FileDocCategorySizeDatePackage
SetMailAttribute.javaAPI DocApache James 2.3.13188Fri Jan 12 12:56:30 GMT 2007org.apache.james.transport.mailets

SetMailAttribute

public class SetMailAttribute extends org.apache.mailet.GenericMailet
This mailet sets attributes on the Mail. Sample configuration: <mailet match="All" class="SetMailAttribute"> <name1>value1</name1> <name2>value2</name2> </mailet>
version
CVS $Revision: 494012 $ $Date: 2007-01-08 11:23:58 +0100 (Mo, 08 Jan 2007) $
since
2.2.0

Fields Summary
private HashMap
attributesToSet
private Set
entries
Constructors Summary
Methods Summary
public java.lang.StringgetMailetInfo()
Return a string describing this mailet.

return
a string describing this mailet

    
                     
       
        return "Set Mail Attribute Mailet";
    
public voidinit()
Initialize the mailet

throws
MailetException if the processor parameter is missing

        Iterator iter = getInitParameterNames();
        while (iter.hasNext()) {
            String name = iter.next().toString();
            String value = getInitParameter (name);
            attributesToSet.put (name,value);
        }
        entries = attributesToSet.entrySet();
    
public voidservice(org.apache.mailet.Mail mail)
Sets the configured attributes

param
mail the mail to process
throws
MessagingException in all cases

        if (entries != null) {
            Iterator iter = entries.iterator();
            while (iter.hasNext()) {
                Map.Entry entry = (Map.Entry)iter.next();
                mail.setAttribute ((String)entry.getKey(),(Serializable)entry.getValue());
            }
        }