File Source: staticpagetagsdecorator.java

         /* 
    P/P   *  Method: net.sourceforge.pebble.decorator.StaticPageTagsDecorator__static_init
          */
     1  package net.sourceforge.pebble.decorator;
     2  
     3  import net.sourceforge.pebble.domain.PageBasedContent;
     4  import net.sourceforge.pebble.domain.StaticPage;
     5  import net.sourceforge.pebble.api.decorator.ContentDecoratorContext;
     6  
     7  /**
     8   * Generates tag links for inclusion in the body of static pages,
     9   * when rendered as HTML and newsfeeds.
    10   *
    11   * @author Simon Brown
    12   */
         /* 
    P/P   *  Method: void net.sourceforge.pebble.decorator.StaticPageTagsDecorator()
          * 
          *  Postconditions:
          *    this.resourceKey == &"tag.tags"
          *    this.target == &""
          */
    13  public class StaticPageTagsDecorator extends AbstractTagsDecorator {
    14  
    15    /**
    16     * Decorates the specified static page.
    17     *
    18     * @param context    the context in which the decoration is running
    19     * @param staticPage the static page to be decorated
    20     */
    21    @Override
    22    public void decorate(ContentDecoratorContext context, StaticPage staticPage) {
             /* 
    P/P       *  Method: void decorate(ContentDecoratorContext, StaticPage)
              * 
              *  Preconditions:
              *    context != null
              * 
              *  Test Vectors:
              *    java.lang.String:length(...)@27: {0}, {1..232-1}
              * 
              *  Preconditions:
              *    init'ed(context.media)
              *    init'ed(staticPage.body)
              *    (soft) staticPage != null
              *    (soft) init'ed(staticPage.blog)
              *    (soft) staticPage.propertyChangeSupport != null
              *    (soft) init'ed(staticPage.tagsAsList)
              * 
              *  Postconditions:
              *    init'ed(staticPage.body)
              * 
              *  Test Vectors:
              *    staticPage.body: Addr_Set{null}, Inverse{null}
              */
    23      String html = generateDecorationHtml(context, staticPage);
    24  
    25      // now add the tags to the body, if not empty
    26      String body = staticPage.getBody();
    27      if (body != null && body.trim().length() > 0) {
    28        staticPage.setBody(body + html);
    29      }
    30    }
    31  
    32    /**
    33     * Gets the base URL for tag links, complete with trailing slash.
    34     *
    35     * @param content   the owning content
    36     * @return  a URL as a String
    37     */
    38    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)
              */
    39      return content.getBlog().getUrl() + "tags/";
    40    }
    41  
    42  }








SofCheck Inspector Build Version : 2.22510
staticpagetagsdecorator.java 2010-Jun-25 19:40:32
staticpagetagsdecorator.class 2010-Jul-19 20:23:40