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
50   156   27   12,5
46   82   0,54   4
4     6,75  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  DefaultEventDispatcher       Line # 52 50 0% 27 12 88% 0.88
 
  (184)
 
1    /*
2    * Copyright (c) 2003-2006, Simon Brown
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions are met:
7    *
8    * - Redistributions of source code must retain the above copyright
9    * notice, this list of conditions and the following disclaimer.
10    *
11    * - Redistributions in binary form must reproduce the above copyright
12    * notice, this list of conditions and the following disclaimer in
13    * the documentation and/or other materials provided with the
14    * distribution.
15    *
16    * - Neither the name of Pebble nor the names of its contributors may
17    * be used to endorse or promote products derived from this software
18    * without specific prior written permission.
19    *
20    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23    * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30    * POSSIBILITY OF SUCH DAMAGE.
31    */
32    package net.sourceforge.pebble.event;
33   
34    import net.sourceforge.pebble.api.event.blog.BlogEvent;
35    import net.sourceforge.pebble.api.event.blog.BlogListener;
36    import net.sourceforge.pebble.api.event.blogentry.BlogEntryEvent;
37    import net.sourceforge.pebble.api.event.blogentry.BlogEntryListener;
38    import net.sourceforge.pebble.api.event.comment.CommentEvent;
39    import net.sourceforge.pebble.api.event.comment.CommentListener;
40    import net.sourceforge.pebble.api.event.EventDispatcher;
41    import net.sourceforge.pebble.api.event.trackback.TrackBackEvent;
42    import net.sourceforge.pebble.api.event.trackback.TrackBackListener;
43   
44    import java.util.Iterator;
45   
46    /**
47    * Responsible for dispatching events to registered listeners, which are
48    * called in the order they were added.
49    *
50    * @author Simon Brown
51    */
 
52    public class DefaultEventDispatcher extends EventDispatcher {
53   
54    /**
55    * Fires a blog event to registered listeners.
56    *
57    * @param event the BlogEvent instance
58    */
 
59  2642 toggle public void fireBlogEvent(BlogEvent event) {
60  2642 Iterator it = getEventListenerList().getBlogListeners().iterator();
61  2648 while (it.hasNext()) {
62  6 BlogListener listener = (BlogListener)it.next();
63  6 if (event.getType() == BlogEvent.BLOG_STARTED) {
64  2 listener.blogStarted(event);
65  4 } else if (event.getType() == BlogEvent.BLOG_STOPPED) {
66  4 listener.blogStopped(event);
67    }
68   
69    // has the event been vetoed?
70  6 if (event.isVetoed()) {
71  0 break;
72    }
73    }
74    }
75   
76    /**
77    * Fires a blog entry event to registered listeners.
78    *
79    * @param event the BlogEntryEvent instance
80    */
 
81  324 toggle public void fireBlogEntryEvent(BlogEntryEvent event) {
82  324 Iterator it = getEventListenerList().getBlogEntryListeners().iterator();
83  2922 while (it.hasNext()) {
84  2598 BlogEntryListener listener = (BlogEntryListener)it.next();
85  2598 if (event.getType() == BlogEntryEvent.BLOG_ENTRY_ADDED) {
86  2208 listener.blogEntryAdded(event);
87  390 } else if (event.getType() == BlogEntryEvent.BLOG_ENTRY_REMOVED) {
88  144 listener.blogEntryRemoved(event);
89  246 } else if (event.getType() == BlogEntryEvent.BLOG_ENTRY_CHANGED) {
90  98 listener.blogEntryChanged(event);
91  148 } else if (event.getType() == BlogEntryEvent.BLOG_ENTRY_PUBLISHED) {
92  114 listener.blogEntryPublished(event);
93  34 } else if (event.getType() == BlogEntryEvent.BLOG_ENTRY_UNPUBLISHED) {
94  34 listener.blogEntryUnpublished(event);
95    }
96   
97    // has the event been vetoed?
98  2598 if (event.isVetoed()) {
99  0 break;
100    }
101    }
102    }
103   
104    /**
105    * Fires a comment event to registered listeners.
106    *
107    * @param event the CommentEvent instance
108    */
 
109  142 toggle public void fireCommentEvent(CommentEvent event) {
110  142 Iterator it = getEventListenerList().getCommentListeners().iterator();
111  1150 while (it.hasNext()) {
112  1008 CommentListener listener = (CommentListener)it.next();
113  1008 if (event.getType() == CommentEvent.COMMENT_ADDED) {
114  548 listener.commentAdded(event);
115  460 } else if (event.getType() == CommentEvent.COMMENT_REMOVED) {
116  120 listener.commentRemoved(event);
117  340 } else if (event.getType() == CommentEvent.COMMENT_APPROVED) {
118  324 listener.commentApproved(event);
119  16 } else if (event.getType() == CommentEvent.COMMENT_REJECTED) {
120  16 listener.commentRejected(event);
121    }
122   
123    // has the event been vetoed?
124  1008 if (event.isVetoed()) {
125  0 break;
126    }
127    }
128    }
129   
130    /**
131    * Fires a TrackBack event to registered listeners.
132    *
133    * @param event the TrackBackEvent instance
134    */
 
135  26 toggle public void fireTrackBackEvent(TrackBackEvent event) {
136  26 Iterator it = getEventListenerList().getTrackBackListeners().iterator();
137  222 while (it.hasNext()) {
138  196 TrackBackListener listener = (TrackBackListener)it.next();
139  196 if (event.getType() == TrackBackEvent.TRACKBACK_ADDED) {
140  100 listener.trackBackAdded(event);
141  96 } else if (event.getType() == TrackBackEvent.TRACKBACK_REMOVED) {
142  64 listener.trackBackRemoved(event);
143  32 } else if (event.getType() == TrackBackEvent.TRACKBACK_APPROVED) {
144  16 listener.trackBackApproved(event);
145  16 } else if (event.getType() == TrackBackEvent.TRACKBACK_REJECTED) {
146  16 listener.trackBackRejected(event);
147    }
148   
149    // has the event been vetoed?
150  196 if (event.isVetoed()) {
151  0 break;
152    }
153    }
154    }
155   
156    }