54565f133658aa894a1b4f91e40fb7195e94c163
[jSite2.git] / src / net / pterodactylus / jsite / core / NodeListenerSupport.java
1 /*
2  * jSite-next - NodeListenerSupport.java -
3  * Copyright © 2008 David Roden
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 package net.pterodactylus.jsite.core;
21
22 import net.pterodactylus.util.event.ListenerSupport;
23
24 /**
25  * Listener support for {@link NodeListener} events.
26  *
27  * @author David Roden <droden@gmail.com>
28  */
29 public class NodeListenerSupport extends ListenerSupport<NodeListener> {
30
31         /**
32          * Notifies all listeners that a node was added.
33          *
34          * @see NodeListener#nodeAdded(Node)
35          * @param node
36          *            The node that was added
37          */
38         public void fireNodeAdded(Node node) {
39                 for (NodeListener nodeListener : getListeners()) {
40                         nodeListener.nodeAdded(node);
41                 }
42         }
43
44         /**
45          * Notifies all listeners that a node was removed.
46          *
47          * @see NodeListener#nodeRemoved(Node)
48          * @param node
49          *            The node that was removed
50          */
51         public void fireNodeRemoved(Node node) {
52                 for (NodeListener nodeListener : getListeners()) {
53                         nodeListener.nodeRemoved(node);
54                 }
55         }
56
57         /**
58          * Notifies all listeners that a node was connected.
59          *
60          * @see NodeListener#nodeConnected(Node)
61          * @param node
62          *            The node that was connected
63          */
64         public void fireNodeConnected(Node node) {
65                 for (NodeListener nodeListener : getListeners()) {
66                         nodeListener.nodeConnected(node);
67                 }
68         }
69
70         /**
71          * Notifies all listeners that the connection to a node failed.
72          *
73          * @see NodeListener#nodeConnectionFailed(Node, Throwable)
74          * @param node
75          *            The node that could not be connected
76          * @param cause
77          *            The cause of the connection failure
78          */
79         public void fireNodeConnectionFailed(Node node, Throwable cause) {
80                 for (NodeListener nodeListener : getListeners()) {
81                         nodeListener.nodeConnectionFailed(node, cause);
82                 }
83         }
84
85         /**
86          * Notifies all listeners that a node was disconnected.
87          *
88          * @see NodeListener#nodeDisconnected(Node, Throwable)
89          * @param node
90          *            The node that was disconnected
91          * @param cause
92          *            The cause of the disconnect, or <code>null</code> if there was
93          *            no exception
94          */
95         public void fireNodeDisconnected(Node node, Throwable cause) {
96                 for (NodeListener nodeListener : getListeners()) {
97                         nodeListener.nodeDisconnected(node, cause);
98                 }
99         }
100
101 }