Clover Coverage Report - Pebble 2.5-SNAPSHOT
Coverage timestamp: Sat Jun 12 2010 09:39:29 EST
../../../../img/srcFileCovDistChart3.png 44% of files have more coverage
19   52   5   19
4   28   0,26   1
1     5  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  ReadMoreDecorator       Line # 15 19 0% 5 18 25% 0.25
 
  (14)
 
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    */
 
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  14 toggle public void decorate(ContentDecoratorContext context, BlogEntry blogEntry) {
25  14 Blog blog = blogEntry.getBlog();
26   
27  14 if ((blogEntry.getExcerpt() != null && blogEntry.getExcerpt().length() > 0 && context.getView() == ContentDecoratorContext.SUMMARY_VIEW)) {
28  0 StringBuffer buf = new StringBuffer();
29  0 buf.append(blogEntry.getExcerpt());
30   
31  0 buf.append("<p><a href=\"");
32  0 buf.append(blogEntry.getPermalink());
33  0 buf.append("\">");
34  0 buf.append(I18n.getMessage(blog, "common.readMore"));
35  0 buf.append("</a></p>");
36   
37  0 blogEntry.setExcerpt(buf.toString());
38  14 } else if (blogEntry.isAggregated()) {
39  0 StringBuffer buf = new StringBuffer();
40  0 buf.append(blogEntry.getBody());
41   
42  0 buf.append("<p><a href=\"");
43  0 buf.append(blogEntry.getPermalink());
44  0 buf.append("\">");
45  0 buf.append(I18n.getMessage(blog, "common.readMore"));
46  0 buf.append("</a></p>");
47   
48  0 blogEntry.setBody(buf.toString());
49    }
50    }
51   
52    }