Clover Coverage Report - Pebble 2.5-SNAPSHOT
Coverage timestamp: Sat Jun 12 2010 09:39:29 EST
../../../../img/srcFileCovDistChart9.png 23% of files have more coverage
20   81   10   4
10   44   0,5   5
5     2  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  CategoryIndexListener       Line # 11 20 0% 10 5 85,7% 0.85714287
 
  (180)
 
1    package net.sourceforge.pebble.index;
2   
3    import net.sourceforge.pebble.domain.BlogEntry;
4    import net.sourceforge.pebble.api.event.blogentry.BlogEntryEvent;
5    import net.sourceforge.pebble.api.event.blogentry.BlogEntryListener;
6   
7    import java.beans.PropertyChangeEvent;
8    import java.util.Iterator;
9    import java.util.List;
10   
 
11    public class CategoryIndexListener implements BlogEntryListener {
12   
13    /**
14    * Called when a blog entry has been added.
15    *
16    * @param event a BlogEntryEvent instance
17    */
 
18  276 toggle public void blogEntryAdded(BlogEntryEvent event) {
19  276 BlogEntry blogEntry = event.getBlogEntry();
20  276 if (blogEntry.isPublished()) {
21  78 blogEntry.getBlog().getCategoryIndex().index(blogEntry);
22    }
23    }
24   
25    /**
26    * Called when a blog entry has been removed.
27    *
28    * @param event a BlogEntryEvent instance
29    */
 
30  18 toggle public void blogEntryRemoved(BlogEntryEvent event) {
31  18 BlogEntry blogEntry = event.getBlogEntry();
32  18 if (blogEntry.isPublished()) {
33  0 blogEntry.getBlog().getCategoryIndex().unindex(blogEntry);
34    }
35    }
36   
37    /**
38    * Called when a blog entry has been changed.
39    *
40    * @param event a BlogEntryEvent instance
41    */
 
42  12 toggle public void blogEntryChanged(BlogEntryEvent event) {
43  12 BlogEntry blogEntry = event.getBlogEntry();
44   
45  12 if (blogEntry.isPublished()) {
46  6 List propertyChangeEvents = event.getPropertyChangeEvents();
47  6 Iterator it = propertyChangeEvents.iterator();
48  22 while (it.hasNext()) {
49  16 PropertyChangeEvent pce = (PropertyChangeEvent)it.next();
50  16 String property = pce.getPropertyName();
51   
52    // only if the tags or categories change do we need to reindex the tags
53  16 if (property.equals(BlogEntry.CATEGORIES_PROPERTY)) {
54  0 blogEntry.getBlog().getCategoryIndex().unindex(blogEntry);
55  0 blogEntry.getBlog().getCategoryIndex().index(blogEntry);
56    }
57    }
58    }
59    }
60   
61    /**
62    * Called when a blog entry has been published.
63    *
64    * @param event a BlogEntryEvent instance
65    */
 
66  14 toggle public void blogEntryPublished(BlogEntryEvent event) {
67  14 BlogEntry blogEntry = event.getBlogEntry();
68  14 blogEntry.getBlog().getCategoryIndex().index(blogEntry);
69    }
70   
71    /**
72    * Called when a blog entry has been unpublished.
73    *
74    * @param event a BlogEntryEvent instance
75    */
 
76  4 toggle public void blogEntryUnpublished(BlogEntryEvent event) {
77  4 BlogEntry blogEntry = event.getBlogEntry();
78  4 blogEntry.getBlog().getCategoryIndex().unindex(blogEntry);
79    }
80   
81    }