From a75c596cfcbb46de853452efc23e83bf239212f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 14 Nov 2008 00:11:34 +0100 Subject: [PATCH] Add NodeListener support class. --- .../jsite/core/NodeListenerSupport.java | 101 +++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 src/net/pterodactylus/jsite/core/NodeListenerSupport.java diff --git a/src/net/pterodactylus/jsite/core/NodeListenerSupport.java b/src/net/pterodactylus/jsite/core/NodeListenerSupport.java new file mode 100644 index 0000000..54565f1 --- /dev/null +++ b/src/net/pterodactylus/jsite/core/NodeListenerSupport.java @@ -0,0 +1,101 @@ +/* + * jSite-next - NodeListenerSupport.java - + * Copyright © 2008 David Roden + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package net.pterodactylus.jsite.core; + +import net.pterodactylus.util.event.ListenerSupport; + +/** + * Listener support for {@link NodeListener} events. + * + * @author David Roden <droden@gmail.com> + */ +public class NodeListenerSupport extends ListenerSupport { + + /** + * Notifies all listeners that a node was added. + * + * @see NodeListener#nodeAdded(Node) + * @param node + * The node that was added + */ + public void fireNodeAdded(Node node) { + for (NodeListener nodeListener : getListeners()) { + nodeListener.nodeAdded(node); + } + } + + /** + * Notifies all listeners that a node was removed. + * + * @see NodeListener#nodeRemoved(Node) + * @param node + * The node that was removed + */ + public void fireNodeRemoved(Node node) { + for (NodeListener nodeListener : getListeners()) { + nodeListener.nodeRemoved(node); + } + } + + /** + * Notifies all listeners that a node was connected. + * + * @see NodeListener#nodeConnected(Node) + * @param node + * The node that was connected + */ + public void fireNodeConnected(Node node) { + for (NodeListener nodeListener : getListeners()) { + nodeListener.nodeConnected(node); + } + } + + /** + * Notifies all listeners that the connection to a node failed. + * + * @see NodeListener#nodeConnectionFailed(Node, Throwable) + * @param node + * The node that could not be connected + * @param cause + * The cause of the connection failure + */ + public void fireNodeConnectionFailed(Node node, Throwable cause) { + for (NodeListener nodeListener : getListeners()) { + nodeListener.nodeConnectionFailed(node, cause); + } + } + + /** + * Notifies all listeners that a node was disconnected. + * + * @see NodeListener#nodeDisconnected(Node, Throwable) + * @param node + * The node that was disconnected + * @param cause + * The cause of the disconnect, or null if there was + * no exception + */ + public void fireNodeDisconnected(Node node, Throwable cause) { + for (NodeListener nodeListener : getListeners()) { + nodeListener.nodeDisconnected(node, cause); + } + } + +} -- 2.7.4