readmoredecorator.java

### File Source: readmoredecorator.java

             /*
        P/P   *  Method: net.sourceforge.pebble.decorator.ReadMoreDecorator__static_init
              */
         1  package net.sourceforge.pebble.decorator;
         2
         3  import net.sourceforge.pebble.api.decorator.ContentDecoratorContext;
         4  import net.sourceforge.pebble.domain.Blog;
         5  import net.sourceforge.pebble.domain.BlogEntry;
         6  import net.sourceforge.pebble.util.I18n;
         7
         8  /**
         9   * Adds a read more link :
        10   *  - when the entry is aggregated
        11   *  - when an excerpt is present, in the summary view
        12   *
        13   * @author Simon Brown
        14   */
             /*
        P/P   *  Method: void net.sourceforge.pebble.decorator.ReadMoreDecorator()
              */
        15  public class ReadMoreDecorator extends ContentDecoratorSupport {
        16
        17
        18    /**
        19     * Decorates the specified blog entry.
        20     *
        21     * @param context   the context in which the decoration is running
        22     * @param blogEntry the blog entry to be decorated
        23     */
        24    public void decorate(ContentDecoratorContext context, BlogEntry blogEntry) {
                 /*
        P/P       *  Method: void decorate(ContentDecoratorContext, BlogEntry)
                  *
                  *  Preconditions:
                  *    blogEntry != null
                  *    (soft) context != null
                  *
                  *  Test Vectors:
                  *    java.lang.String:length(...)@27: {0}, {1..232-1}
                  *
                  *  Preconditions:
                  *    init'ed(blogEntry.originalPermalink)
                  *    init'ed(blogEntry.excerpt)
                  *    (soft) blogEntry.blog != null
                  *    (soft) blogEntry.propertyChangeSupport != null
                  *    (soft) init'ed(blogEntry.blog.id)
                  *    (soft) init'ed(context.view)
                  *    (soft) init'ed(blogEntry.body)
                  *
                  *  Postconditions:
                  *    (soft) init'ed(blogEntry.body)
                  *    init'ed(blogEntry.excerpt)
                  *    possibly_updated(blogEntry.permalink)
                  *
                  *  Preconditions:
                  *    (soft) net/sourceforge/pebble/domain/BlogManager.instance != null
                  *    (soft) init'ed(net/sourceforge/pebble/domain/BlogManager.instance.multiBlog)
                  *
                  *  Test Vectors:
                  *    blogEntry.originalPermalink: Addr_Set{null}, Inverse{null}
                  *    context.view: {-231..-1, 1..232-1}, {0}
                  *    blogEntry.excerpt: Addr_Set{null}, Inverse{null}
                  */
        25      Blog blog = blogEntry.getBlog();
        26
        27      if ((blogEntry.getExcerpt() != null && blogEntry.getExcerpt().length() > 0 && context.getView() == ContentDecoratorContext.SUMMARY_VIEW)) {
        28        StringBuffer buf = new StringBuffer();
        29        buf.append(blogEntry.getExcerpt());
        30
        31        buf.append("<p><a href=\"");
        32        buf.append(blogEntry.getPermalink());
        33        buf.append("\">");
        34        buf.append(I18n.getMessage(blog, "common.readMore"));
        35        buf.append("</a></p>");
        36
        37        blogEntry.setExcerpt(buf.toString());
        38      } else if (blogEntry.isAggregated()) {
        39        StringBuffer buf = new StringBuffer();
        40        buf.append(blogEntry.getBody());
        41
        42        buf.append("<p><a href=\"");
        43        buf.append(blogEntry.getPermalink());
        44        buf.append("\">");
        45        buf.append(I18n.getMessage(blog, "common.readMore"));
        46        buf.append("</a></p>");
        47
        48        blogEntry.setBody(buf.toString());
        49      }
        50    }
        51
        52  }

SofCheck Inspector Build Version : 2.22510

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