File Source: HTMLSubsetPlugin.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.comment;
    20  
    21  import org.apache.commons.logging.Log;
    22  import org.apache.commons.logging.LogFactory;
    23  import org.apache.roller.weblogger.pojos.WeblogEntryComment;
    24  import org.apache.roller.weblogger.util.Utilities;
    25  
    26  
    27  /**
    28   * Transforms the given String into a subset of HTML.
    29   */
    30  public class HTMLSubsetPlugin implements WeblogEntryCommentPlugin {
    31      
             /* 
    P/P       *  Method: org.apache.roller.weblogger.business.plugins.comment.HTMLSubsetPlugin__static_init
              * 
              *  Postconditions:
              *    init'ed(log)
              */
    32      private static final Log log = LogFactory.getLog(AutoformatPlugin.class);
    33      
    34      
             /* 
    P/P       *  Method: void org.apache.roller.weblogger.business.plugins.comment.HTMLSubsetPlugin()
              */
    35      public HTMLSubsetPlugin() {
    36          // no-op
    37      }
    38      
    39      
    40      /**
    41       * Unique identifier.  This should never change. 
    42       */
    43      public String getId() {
                 /* 
    P/P           *  Method: String getId()
                  * 
                  *  Postconditions:
                  *    return_value == &"HTMLSubset"
                  */
    44          return "HTMLSubset";
    45      }
    46      
    47      
    48      public String getName() {
                 /* 
    P/P           *  Method: String getName()
                  * 
                  *  Postconditions:
                  *    return_value == &"HTML Subset Restriction"
                  */
    49          return "HTML Subset Restriction";
    50      }
    51      
    52      
    53      public String getDescription() {
                 /* 
    P/P           *  Method: String getDescription()
                  * 
                  *  Postconditions:
                  *    return_value == &"Transforms the given comment body into a subset of HTML"
                  */
    54          return "Transforms the given comment body into a subset of HTML";
    55      }
    56      
    57      
    58      public String render(final WeblogEntryComment comment, String text) {
    59          
                 /* 
    P/P           *  Method: String render(WeblogEntryComment, String)
                  * 
                  *  Presumptions:
                  *    org.apache.commons.logging.LogFactory:getLog(...)@32 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    60          log.debug("starting value:\n"+text);
    61          
    62          String output = text;
    63          
    64          // escape html
    65          output = Utilities.escapeHTML(output);
    66          
    67          // just use old utilities method
    68          output = Utilities.transformToHTMLSubset(output);
    69          
    70          log.debug("ending value:\n"+output);
    71          
    72          return output;
    73      }
    74      
    75  }








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