Clover Coverage Report - Pebble 2.5-SNAPSHOT
Coverage timestamp: Sat Jun 12 2010 09:39:29 EST
../../../../img/srcFileCovDistChart0.png 48% of files have more coverage
23   62   9   23
12   39   0,39   1
1     9  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  BlogCategoriesDecorator       Line # 16 23 0% 9 36 0% 0.0
 
No Tests
 
1    package net.sourceforge.pebble.decorator;
2   
3    import java.util.Iterator;
4   
5    import net.sourceforge.pebble.api.decorator.ContentDecoratorContext;
6    import net.sourceforge.pebble.domain.BlogEntry;
7    import net.sourceforge.pebble.domain.Category;
8    import net.sourceforge.pebble.util.I18n;
9   
10    /**
11    * Generates category links for inclusion in the body of blog entries,
12    * when rendered as HTML.
13    *
14    * @author Simon Brown
15    */
 
16    public class BlogCategoriesDecorator extends ContentDecoratorSupport {
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  0 toggle public void decorate(ContentDecoratorContext context, BlogEntry blogEntry) {
25  0 if (context.getMedia() == ContentDecoratorContext.HTML_PAGE) {
26  0 Iterator categories = blogEntry.getCategories().iterator();
27   
28  0 if (categories.hasNext()) {
29  0 StringBuffer buf = new StringBuffer();
30   
31  0 buf.append("<div class=\"categories\"><span>");
32  0 buf.append(I18n.getMessage(blogEntry.getBlog(), "category.categories"));
33  0 buf.append(" : </span>");
34  0 while (categories.hasNext()) {
35  0 Category category = (Category)categories.next();
36  0 buf.append("<a href=\"");
37  0 buf.append(category.getPermalink());
38  0 buf.append("\">");
39  0 buf.append(category.getName());
40  0 buf.append("</a>");
41   
42  0 if (categories.hasNext()) {
43  0 buf.append(", ");
44    }
45    }
46  0 buf.append("</div>");
47   
48    // now add the HTML to the body and excerpt, if they aren't empty
49  0 String body = blogEntry.getBody();
50  0 if (body != null && body.trim().length() > 0) {
51  0 blogEntry.setBody(body + buf.toString());
52    }
53   
54  0 String excerpt = blogEntry.getExcerpt();
55  0 if (excerpt != null && excerpt.trim().length() > 0) {
56  0 blogEntry.setExcerpt(excerpt + buf.toString());
57    }
58    }
59    }
60    }
61   
62    }