blogtagsdecorator.java

### File Source: blogtagsdecorator.java

             /*
        P/P   *  Method: net.sourceforge.pebble.decorator.BlogTagsDecorator__static_init
              */
         1  package net.sourceforge.pebble.decorator;
         2
         3  import net.sourceforge.pebble.domain.BlogEntry;
         4  import net.sourceforge.pebble.domain.PageBasedContent;
         5  import net.sourceforge.pebble.api.decorator.ContentDecoratorContext;
         6
         7  /**
         8   * Generates tag links for inclusion in the body of blog entries,
         9   * when rendered as HTML and newsfeeds.
        10   *
        11   * @author Simon Brown
        12   */
             /*
        P/P   *  Method: void net.sourceforge.pebble.decorator.BlogTagsDecorator()
              *
              *  Postconditions:
              *    this.resourceKey == &"tag.tags"
              *    this.target == &""
              */
        13  public class BlogTagsDecorator extends AbstractTagsDecorator {
        14
        15    /**
        16     * Decorates the specified blog entry.
        17     *
        18     * @param context   the context in which the decoration is running
        19     * @param blogEntry the blog entry to be decorated
        20     *          if something goes wrong when running the decorator
        21     */
        22    @Override
        23    public void decorate(ContentDecoratorContext context, BlogEntry blogEntry) {
                 /*
        P/P       *  Method: void decorate(ContentDecoratorContext, BlogEntry)
                  *
                  *  Preconditions:
                  *    blogEntry != null
                  *    context != null
                  *
                  *  Test Vectors:
                  *    java.lang.String:length(...)@28: {0}, {1..232-1}
                  *    java.lang.String:length(...)@33: {0}, {1..232-1}
                  *
                  *  Preconditions:
                  *    init'ed(context.media)
                  *    init'ed(blogEntry.body)
                  *    init'ed(blogEntry.excerpt)
                  *    (soft) init'ed(blogEntry.blog)
                  *    (soft) blogEntry.propertyChangeSupport != null
                  *    (soft) init'ed(blogEntry.tagsAsList)
                  *
                  *  Postconditions:
                  *    init'ed(blogEntry.body)
                  *    init'ed(blogEntry.excerpt)
                  *
                  *  Test Vectors:
                  *    blogEntry.body: Addr_Set{null}, Inverse{null}
                  *    blogEntry.excerpt: Addr_Set{null}, Inverse{null}
                  */
        24      String html = generateDecorationHtml(context, blogEntry);
        25
        26      // now add the tags to the body and excerpt, if they aren't empty
        27      String body = blogEntry.getBody();
        28      if (body != null && body.trim().length() > 0) {
        29        blogEntry.setBody(body + html);
        30      }
        31
        32      String excerpt = blogEntry.getExcerpt();
        33      if (excerpt != null && excerpt.trim().length() > 0) {
        34        blogEntry.setExcerpt(excerpt + html);
        35      }
        36    }
        37
        38    /**
        39     * Gets the base URL for tag links, complete with trailing slash.
        40     *
        41     * @param content   the owning content
        42     * @return  a URL as a String
        43     */
        44    public String getBaseUrl(PageBasedContent content) {
                 /*
        P/P       *  Method: String getBaseUrl(PageBasedContent)
                  *
                  *  Preconditions:
                  *    content != null
                  *
                  *  Postconditions:
                  *    return_value != null
                  *
                  *  Preconditions:
                  *    content.blog != null
                  *    (soft) init'ed(content.blog.id)
                  *    (soft) net/sourceforge/pebble/domain/BlogManager.instance != null
                  *    (soft) init'ed(net/sourceforge/pebble/domain/BlogManager.instance.multiBlog)
                  */
        45      return content.getBlog().getUrl() + "tags/";
        46    }
        47
        48  }

SofCheck Inspector Build Version : 2.22510

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