KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > presentation > velocity > plugins > email > ObfuscateEmailPlugin


1 /*
2  * Created on Nov 2, 2003
3  *
4  */

5 package org.roller.presentation.velocity.plugins.email;
6
7 import org.apache.commons.lang.StringEscapeUtils;
8 import org.apache.commons.logging.Log;
9 import org.apache.commons.logging.LogFactory;
10 import org.apache.velocity.context.Context;
11 import org.roller.pojos.WeblogEntryData;
12 import org.roller.presentation.RollerRequest;
13 import org.roller.presentation.velocity.PagePlugin;
14 import org.roller.util.RegexUtil;
15
16 /**
17  * @author lance
18  *
19  */

20 public class ObfuscateEmailPlugin implements PagePlugin
21 {
22     protected String JavaDoc name = "Email Scrambler";
23     protected String JavaDoc description = "Automatically converts email addresses " +
24       "to me-AT-mail-DOT-com format. Also "scrambles" mailto: links.";
25     
26     private static Log mLogger =
27        LogFactory.getFactory().getInstance(ObfuscateEmailPlugin.class);
28            
29     public ObfuscateEmailPlugin()
30     {
31         mLogger.debug("ObfuscateEmailPlugin instantiated.");
32     }
33     
34     public String JavaDoc toString() { return name; }
35
36     /* (non-Javadoc)
37      * @see org.roller.presentation.velocity.PagePlugin#init(org.roller.presentation.RollerRequest, org.apache.velocity.context.Context)
38      */

39     public void init(RollerRequest rreq, Context ctx)
40     {
41     }
42
43     /*
44      * Find any likely email addresses and HEX escape them
45      * (non-Javadoc)
46      * @see org.roller.presentation.velocity.PagePlugin#render(java.lang.String)
47      */

48     public String JavaDoc render(String JavaDoc str)
49     {
50         return RegexUtil.encodeEmail(str);
51     }
52     
53     public String JavaDoc render(WeblogEntryData entry, boolean skipFlag)
54     {
55         return render(entry.getText());
56     }
57
58     public String JavaDoc getName() { return name; }
59     public String JavaDoc getDescription() { return StringEscapeUtils.escapeJavaScript(description); }
60
61 }
62
Popular Tags