KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > ui > rendering > plugins > ObfuscateEmailPlugin


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. The ASF licenses this file to You
4  * under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License. For additional information regarding
15  * copyright in this work, please see the NOTICE file in the top level
16  * directory of this distribution.
17  */

18
19 package org.apache.roller.ui.rendering.plugins;
20
21 import java.util.Map JavaDoc;
22 import org.apache.commons.lang.StringEscapeUtils;
23 import org.apache.commons.logging.Log;
24 import org.apache.commons.logging.LogFactory;
25 import org.apache.roller.RollerException;
26 import org.apache.roller.model.WeblogEntryPlugin;
27 import org.apache.roller.pojos.WeblogEntryData;
28 import org.apache.roller.pojos.WebsiteData;
29 import org.apache.roller.util.RegexUtil;
30
31
32 /**
33  * Obfuscate email addresses in entry text.
34  */

35 public class ObfuscateEmailPlugin implements WeblogEntryPlugin {
36     
37     private static Log mLogger = LogFactory.getLog(ObfuscateEmailPlugin.class);
38     
39     protected String JavaDoc name = "Email Scrambler";
40     
41     protected String JavaDoc description = "Automatically converts email addresses " +
42             "to me-AT-mail-DOT-com format. Also "scrambles" mailto: links.";
43     
44     
45     public ObfuscateEmailPlugin() {
46         mLogger.debug("ObfuscateEmailPlugin instantiated.");
47     }
48     
49     
50     public String JavaDoc getName() {
51         return name;
52     }
53     
54     
55     public String JavaDoc getDescription() {
56         return StringEscapeUtils.escapeJavaScript(description);
57     }
58     
59     
60     public void init(WebsiteData website) throws RollerException {}
61     
62     
63     public String JavaDoc render(WeblogEntryData entry, String JavaDoc str) {
64         return RegexUtil.encodeEmail(str);
65     }
66     
67 }
68
Popular Tags