htmldecorator.java

### File Source: htmldecorator.java

             /*
        P/P   *  Method: net.sourceforge.pebble.decorator.HtmlDecorator__static_init
              */
         1  package net.sourceforge.pebble.decorator;
         2
         3  import net.sourceforge.pebble.api.decorator.ContentDecoratorContext;
         4  import net.sourceforge.pebble.domain.Comment;
         5  import net.sourceforge.pebble.domain.TrackBack;
         6  import net.sourceforge.pebble.util.StringUtils;
         7
         8  /**
         9   * Decorates blog entries and comments by rendering them as HTML.
        10   *
        11   * @author Simon Brown
        12   */
             /*
        P/P   *  Method: void net.sourceforge.pebble.decorator.HtmlDecorator()
              */
        13  public class HtmlDecorator extends ContentDecoratorSupport {
        14
        15    /**
        16     * Decorates the specified comment.
        17     *
        18     * @param context the context in which the decoration is running
        19     * @param comment the comment to be decorated
        20     */
        21    public void decorate(ContentDecoratorContext context, Comment comment) {
                 /*
        P/P       *  Method: void decorate(ContentDecoratorContext, Comment)
                  *
                  *  Preconditions:
                  *    comment != null
                  *    init'ed(comment.author)
                  *    init'ed(comment.body)
                  *    init'ed(comment.email)
                  *    init'ed(comment.title)
                  *    init'ed(comment.website)
                  *    (soft) init'ed(comment.blogEntry)
                  *
                  *  Postconditions:
                  *    comment.author != null
                  *    init'ed(comment.body)
                  *    init'ed(comment.email)
                  *    comment.title != null
                  *    init'ed(comment.website)
                  */
        22      comment.setAuthor(StringUtils.filterHTML(comment.getAuthor()));
        23      comment.setWebsite(StringUtils.filterHTML(comment.getWebsite()));
        24      comment.setEmail(StringUtils.filterHTML(comment.getEmail()));
        25      comment.setTitle(StringUtils.filterHTML(comment.getTitle()));
        26      comment.setBody(StringUtils.transformToHTMLSubset(StringUtils.transformHTML(comment.getBody())));
        27    }
        28
        29    /**
        30     * Decorates the specified TrackBack.
        31     *
        32     * @param context   the context in which the decoration is running
        33     * @param trackBack the TrackBack to be decorated
        34     */
        35    public void decorate(ContentDecoratorContext context, TrackBack trackBack) {
                 /*
        P/P       *  Method: void decorate(ContentDecoratorContext, TrackBack)
                  *
                  *  Preconditions:
                  *    trackBack != null
                  *    init'ed(trackBack.blogName)
                  *    init'ed(trackBack.excerpt)
                  *    init'ed(trackBack.title)
                  *    init'ed(trackBack.url)
                  *
                  *  Postconditions:
                  *    trackBack.blogName != null
                  *    trackBack.excerpt != null
                  *    init'ed(trackBack.title)
                  *    init'ed(trackBack.url)
                  */
        36      trackBack.setBlogName(StringUtils.filterHTML(trackBack.getBlogName()));
        37      trackBack.setUrl(StringUtils.filterHTML(trackBack.getUrl()));
        38      trackBack.setTitle(StringUtils.filterHTML(trackBack.getTitle()));
        39      trackBack.setExcerpt(StringUtils.transformToHTMLSubset(StringUtils.transformHTML(trackBack.getExcerpt())));
        40    }
        41  }

SofCheck Inspector Build Version : 2.22510

htmldecorator.java | 2010-Jun-25 19:40:32
htmldecorator.class | 2010-Jul-19 20:23:40