File Source: eventlistenerlist.java
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.BlogListener;
35 import net.sourceforge.pebble.api.event.blogentry.BlogEntryListener;
36 import net.sourceforge.pebble.api.event.comment.CommentListener;
37 import net.sourceforge.pebble.api.event.trackback.TrackBackListener;
38 import org.apache.commons.logging.Log;
39 import org.apache.commons.logging.LogFactory;
40
41 import java.util.ArrayList;
42 import java.util.List;
43
44 /**
45 * Maintains a list of listeners, allowing them to be added and removed.
46 *
47 * @author Simon Brown
48 */
49 public class EventListenerList {
50
51 /** the log in use by this class */
/*
P/P * Method: net.sourceforge.pebble.event.EventListenerList__static_init
*
* Postconditions:
* init'ed(log)
*/
52 private static final Log log = LogFactory.getLog(EventListenerList.class);
53
54 /** the list of blog listeners */
55 private List blogListeners;
56
57 /** the list of blog entry listeners */
58 private List blogEntryListeners;
59
60 /** the list of comment listeners */
61 private List commentListeners;
62
63 /** the list of TrackBack listeners */
64 private List trackBackListeners;
65
66 /**
67 * Default, no args constructor.
68 */
/*
P/P * Method: void net.sourceforge.pebble.event.EventListenerList()
*
* Postconditions:
* this.blogEntryListeners == &new ArrayList(EventListenerList#2)
* this.blogListeners == &new ArrayList(EventListenerList#1)
* this.commentListeners == &new ArrayList(EventListenerList#3)
* this.trackBackListeners == &new ArrayList(EventListenerList#4)
* new ArrayList(EventListenerList#1) num objects == 1
* new ArrayList(EventListenerList#2) num objects == 1
* new ArrayList(EventListenerList#3) num objects == 1
* new ArrayList(EventListenerList#4) num objects == 1
*/
69 public EventListenerList() {
70 this.blogListeners = new ArrayList();
71 this.blogEntryListeners = new ArrayList();
72 this.commentListeners = new ArrayList();
73 this.trackBackListeners = new ArrayList();
74 }
75
76 /**
77 * Gets the list of blog listeners.
78 *
79 * @return a List of BlogListener instances
80 */
81 public List getBlogListeners() {
/*
P/P * Method: List getBlogListeners()
*
* Preconditions:
* init'ed(this.blogListeners)
*
* Postconditions:
* return_value == this.blogListeners
* init'ed(return_value)
*/
82 return this.blogListeners;
83 }
84
85 /**
86 * Registers a blog listener.
87 *
88 * @param listener a BlogListener instance
89 */
90 public void addBlogListener(BlogListener listener) {
/*
P/P * Method: void addBlogListener(BlogListener)
*
* Preconditions:
* this.blogListeners != null
* (soft) listener != null
*
* Presumptions:
* java.lang.Object:getClass(...)@93 != null
* org.apache.commons.logging.LogFactory:getLog(...)@52 != null
*
* Test Vectors:
* java.util.List:contains(...)@91: {1}, {0}
*/
91 if (!blogListeners.contains(listener)) {
92 blogListeners.add(listener);
93 log.debug(listener.getClass().getName() + " registered");
94 }
95 }
96
97 /**
98 * Unregisters a blog listener.
99 *
100 * @param listener a BlogListener instance
101 */
102 public void removeBlogListener(BlogListener listener) {
/*
P/P * Method: void removeBlogListener(BlogListener)
*
* Preconditions:
* this.blogListeners != null
*/
103 blogListeners.remove(listener);
104 }
105
106 /**
107 * Gets the list of blog entry listeners.
108 *
109 * @return a List of BlogEntryListener instances
110 */
111 public List getBlogEntryListeners() {
/*
P/P * Method: List getBlogEntryListeners()
*
* Preconditions:
* init'ed(this.blogEntryListeners)
*
* Postconditions:
* return_value == this.blogEntryListeners
* init'ed(return_value)
*/
112 return this.blogEntryListeners;
113 }
114
115 /**
116 * Registers a blog entry listener.
117 *
118 * @param listener a BlogEntryListener instance
119 */
120 public void addBlogEntryListener(BlogEntryListener listener) {
/*
P/P * Method: void addBlogEntryListener(BlogEntryListener)
*
* Preconditions:
* this.blogEntryListeners != null
* (soft) listener != null
*
* Presumptions:
* java.lang.Object:getClass(...)@123 != null
* org.apache.commons.logging.LogFactory:getLog(...)@52 != null
*
* Test Vectors:
* java.util.List:contains(...)@121: {1}, {0}
*/
121 if (!blogEntryListeners.contains(listener)) {
122 blogEntryListeners.add(listener);
123 log.debug(listener.getClass().getName() + " registered");
124 }
125 }
126
127 /**
128 * Gets the list of comment listeners.
129 *
130 * @return a List of CommentListener instances
131 */
132 public List getCommentListeners() {
/*
P/P * Method: List getCommentListeners()
*
* Preconditions:
* init'ed(this.commentListeners)
*
* Postconditions:
* return_value == this.commentListeners
* init'ed(return_value)
*/
133 return this.commentListeners;
134 }
135
136 /**
137 * Registers a comment listener.
138 *
139 * @param listener a CommentListener instance
140 */
141 public void addCommentListener(CommentListener listener) {
/*
P/P * Method: void addCommentListener(CommentListener)
*
* Preconditions:
* this.commentListeners != null
* (soft) listener != null
*
* Presumptions:
* java.lang.Object:getClass(...)@144 != null
* org.apache.commons.logging.LogFactory:getLog(...)@52 != null
*
* Test Vectors:
* java.util.List:contains(...)@142: {1}, {0}
*/
142 if (!commentListeners.contains(listener)) {
143 commentListeners.add(listener);
144 log.debug(listener.getClass().getName() + " registered");
145 }
146 }
147
148 /**
149 * Gets the list of TrackBack listeners.
150 *
151 * @return a List of TrackBackListener instances
152 */
153 public List getTrackBackListeners() {
/*
P/P * Method: List getTrackBackListeners()
*
* Preconditions:
* init'ed(this.trackBackListeners)
*
* Postconditions:
* return_value == this.trackBackListeners
* init'ed(return_value)
*/
154 return this.trackBackListeners;
155 }
156
157 /**
158 * Registers a TrackBack listener.
159 *
160 * @param listener a TrackBackListener instance
161 */
162 public void addTrackBackListener(TrackBackListener listener) {
/*
P/P * Method: void addTrackBackListener(TrackBackListener)
*
* Preconditions:
* this.trackBackListeners != null
* (soft) listener != null
*
* Presumptions:
* java.lang.Object:getClass(...)@165 != null
* org.apache.commons.logging.LogFactory:getLog(...)@52 != null
*
* Test Vectors:
* java.util.List:contains(...)@163: {1}, {0}
*/
163 if (!trackBackListeners.contains(listener)) {
164 trackBackListeners.add(listener);
165 log.debug(listener.getClass().getName() + " registered");
166 }
167 }
168
169
170 }
SofCheck Inspector Build Version : 2.22510
| eventlistenerlist.java |
2010-Jun-25 19:40:32 |
| eventlistenerlist.class |
2010-Jul-19 20:23:40 |