File Source: ObfuscateEmailPlugin.java

     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.weblogger.business.plugins.entry;
    20  
    21  import java.util.Map;
    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.weblogger.WebloggerException;
    26  import org.apache.roller.weblogger.business.plugins.entry.WeblogEntryPlugin;
    27  import org.apache.roller.weblogger.pojos.WeblogEntry;
    28  import org.apache.roller.weblogger.pojos.Weblog;
    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      
             /* 
    P/P       *  Method: org.apache.roller.weblogger.business.plugins.entry.ObfuscateEmailPlugin__static_init
              * 
              *  Postconditions:
              *    init'ed(mLogger)
              */
    37      private static Log mLogger = LogFactory.getLog(ObfuscateEmailPlugin.class);
    38      
    39      protected String name = "Email Scrambler";
    40      
    41      protected String description = "Automatically converts email addresses " +
    42              "to me-AT-mail-DOT-com format.  Also "scrambles" mailto: links.";
    43      
    44      
             /* 
    P/P       *  Method: void org.apache.roller.weblogger.business.plugins.entry.ObfuscateEmailPlugin()
              * 
              *  Preconditions:
              *    mLogger != null
              * 
              *  Postconditions:
              *    this.description == &"Automatically converts email addresses to me-AT-mail-DOT-com format.  Also "scrambles" mailto: links."
              *    this.name == &"Email Scrambler"
              */
    45      public ObfuscateEmailPlugin() {
    46          mLogger.debug("ObfuscateEmailPlugin instantiated.");
    47      }
    48      
    49      
    50      public String getName() {
                 /* 
    P/P           *  Method: String getName()
                  * 
                  *  Preconditions:
                  *    init'ed(this.name)
                  * 
                  *  Postconditions:
                  *    return_value == this.name
                  *    init'ed(return_value)
                  */
    51          return name;
    52      }
    53      
    54      
    55      public String getDescription() {
                 /* 
    P/P           *  Method: String getDescription()
                  * 
                  *  Preconditions:
                  *    init'ed(this.description)
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    56          return StringEscapeUtils.escapeJavaScript(description);
    57      }
    58      
    59      
             /* 
    P/P       *  Method: void init(Weblog)
              */
    60      public void init(Weblog website) throws WebloggerException {}
    61      
    62      
    63      public String render(WeblogEntry entry, String str) {
                 /* 
    P/P           *  Method: String render(WeblogEntry, String)
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    64          return RegexUtil.encodeEmail(str);
    65      }
    66      
    67  }








SofCheck Inspector Build Version : 2.18479
ObfuscateEmailPlugin.java 2009-Jan-02 14:25:16
ObfuscateEmailPlugin.class 2009-Sep-04 03:12:31