technoratitagsdecorator.java

### File Source: technoratitagsdecorator.java

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

SofCheck Inspector Build Version : 2.22510

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