Clover Coverage Report - Pebble 2.5-SNAPSHOT
Coverage timestamp: Sat Jun 12 2010 09:39:29 EST
../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
10   118   7   3,33
8   35   0,7   3
3     2,33  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  EventDispatcher       Line # 48 10 0% 7 1 95,2% 0.95238096
 
  (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.api.event;
33   
34    import net.sourceforge.pebble.api.event.blog.BlogEvent;
35    import net.sourceforge.pebble.api.event.blogentry.BlogEntryEvent;
36    import net.sourceforge.pebble.api.event.comment.CommentEvent;
37    import net.sourceforge.pebble.api.event.trackback.TrackBackEvent;
38    import net.sourceforge.pebble.event.EventListenerList;
39    import net.sourceforge.pebble.domain.BlogEntry;
40    import org.apache.commons.logging.Log;
41    import org.apache.commons.logging.LogFactory;
42   
43    /**
44    * Responsible for dispatching events to registered listeners.
45    *
46    * @author Simon Brown
47    */
 
48    public abstract class EventDispatcher {
49   
50    private static final Log log = LogFactory.getLog(EventDispatcher.class);
51   
52    /** the event listener list */
53    private EventListenerList eventListenerList;
54   
55    /**
56    * Gets the event listener list.
57    *
58    * @return an EventListenerList object
59    */
 
60  3134 toggle public EventListenerList getEventListenerList() {
61  3134 return this.eventListenerList;
62    }
63   
64    /**
65    * Sets the event listener list.
66    *
67    * @param eventListenerList an EventListenerList object
68    */
 
69  1334 toggle public void setEventListenerList(EventListenerList eventListenerList) {
70  1334 this.eventListenerList = eventListenerList;
71    }
72   
73    /**
74    * Fires all outstanding events on a given blog entry.
75    *
76    * @param blogEntry the blog entry to fire events on
77    */
 
78  372 toggle public void fireEvents(BlogEntry blogEntry) {
79  864 while (blogEntry.hasEvents()) {
80  492 PebbleEvent event = blogEntry.nextEvent();
81  492 if (event instanceof BlogEntryEvent) {
82  324 fireBlogEntryEvent((BlogEntryEvent)event);
83  168 } else if (event instanceof CommentEvent) {
84  142 fireCommentEvent((CommentEvent)event);
85  26 } else if (event instanceof TrackBackEvent) {
86  26 fireTrackBackEvent((TrackBackEvent)event);
87    }
88    }
89    }
90   
91    /**
92    * Fires a blog event to registered listeners.
93    *
94    * @param event the BlogEvent instance
95    */
96    public abstract void fireBlogEvent(BlogEvent event);
97   
98    /**
99    * Fires a blog entry event to registered listeners.
100    *
101    * @param event the BlogEntryEvent instance
102    */
103    public abstract void fireBlogEntryEvent(BlogEntryEvent event);
104   
105    /**
106    * Fires a comment event to registered listeners.
107    *
108    * @param event the CommentEvent instance
109    */
110    public abstract void fireCommentEvent(CommentEvent event);
111    /**
112    * Fires a TrackBack event to registered listeners.
113    *
114    * @param event the TrackBackEvent instance
115    */
116    public abstract void fireTrackBackEvent(TrackBackEvent event);
117   
118    }