FileDocCategorySizeDatePackage
CommandListservFooter.javaAPI DocApache James 2.3.14771Fri Jan 12 12:56:28 GMT 2007org.apache.james.transport.mailets

CommandListservFooter

public class CommandListservFooter extends AbstractAddFooter
CommandListservFooter is based on the AddFooter mailet. It is used by the {@link CommandListservProcessor} to inject a footer into mailing list.

version
CVS $Revision: 494012 $ $Date: 2007-01-08 11:23:58 +0100 (Mo, 08 Jan 2007) $
since
2.2.0
see
XMLResources

Fields Summary
protected String
footerText
protected String
footerHtml
protected ICommandListservManager
commandListservManager
The list serv manager
protected org.apache.oro.text.regex.Perl5Compiler
perl5Compiler
For matching
protected org.apache.oro.text.regex.Pattern
insertPattern
protected org.apache.oro.text.regex.Pattern
newlinePattern
protected org.apache.james.util.XMLResources[]
xmlResources
protected static final int
TEXT_PLAIN
protected static final int
TEXT_HTML
Constructors Summary
public CommandListservFooter(ICommandListservManager commandListservManager)


       
        this.commandListservManager = commandListservManager;
        try {
            insertPattern = perl5Compiler.compile("</body>\\s*</html>", Perl5Compiler.CASE_INSENSITIVE_MASK);
            newlinePattern = perl5Compiler.compile("\r\n|\n", Perl5Compiler.CASE_INSENSITIVE_MASK);
        } catch (MalformedPatternException e) {
            throw new IllegalStateException("Unable to parse regexps: " + e.getMessage());
        }
    
Methods Summary
protected java.lang.StringgetFooterHTML()
Get and cache the footer html text

return
the footer text
see
XMLResources

        if (footerHtml == null) {
            String footerText = getFormattedText(TEXT_HTML);
            footerHtml = Util.substitute(new Perl5Matcher(),
                    newlinePattern,
                    new StringSubstitution(" <br />"),
                    footerText,
                    Util.SUBSTITUTE_ALL);
        }
        return footerHtml;
    
protected java.lang.StringgetFooterText()
Get and cache the footer text

return
the footer text
see
XMLResources

        if (footerText == null) {
            footerText = getFormattedText(TEXT_PLAIN);
        }
        return footerText;
    
protected java.lang.StringgetFormattedText(int index)

see
XMLResources#getString
param
index either {@link #TEXT_PLAIN} or {@link #TEXT_HTML}
return
a formatted text with the proper list and domain

        return xmlResources[index].getString("text");
    
public java.lang.StringgetMailetInfo()
Return a string describing this mailet.

return
a string describing this mailet

        return "CommandListservFooter Mailet";
    
public voidinit()
Initialize the mailet

        try {
            xmlResources = commandListservManager.initXMLResources(new String[]{"footer", "footer_html"});
        } catch (ConfigurationException e) {
            throw new MessagingException(e.getMessage(), e);
        }