Split ListenerSupport into two classes.
[jSite2.git] / src / net / pterodactylus / jsite / core / InsertListenerSupport.java
1 /*
2  * jSite-next - InsertListenerSupport.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  * Helper class that fires {@link InsertListener} events.
26  *
27  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
28  */
29 public class InsertListenerSupport extends ListenerSupport<InsertListener> {
30
31         /**
32          * Notifies all listeners that the insert was added.
33          *
34          * @see InsertListener#insertAdded(Insert)
35          * @param insert
36          *            The insert that was added
37          */
38         public void fireInsertAdded(Insert insert) {
39                 for (InsertListener insertListener : getListeners()) {
40                         insertListener.insertAdded(insert);
41                 }
42         }
43
44         /**
45          * Notifies all listeners that the insert was removed.
46          *
47          * @see InsertListener#insertRemoved(Insert)
48          * @param insert
49          *            The insert that was removed
50          */
51         public void fireInsertRemoved(Insert insert) {
52                 for (InsertListener insertListener : getListeners()) {
53                         insertListener.insertRemoved(insert);
54                 }
55         }
56
57         /**
58          * Notifies all listeners that the insert was started.
59          *
60          * @see InsertListener#insertStarted(Insert)
61          * @param insert
62          *            The insert that was started
63          */
64         public void fireInsertStarted(Insert insert) {
65                 for (InsertListener insertListener : getListeners()) {
66                         insertListener.insertStarted(insert);
67                 }
68         }
69
70         /**
71          * Notifies all listeners that the insert made progress.
72          *
73          * @see InsertListener#insertProgressed(Insert)
74          * @param insert
75          *            The insert that made progress
76          */
77         public void fireInsertProgressed(Insert insert) {
78                 for (InsertListener insertListener : getListeners()) {
79                         insertListener.insertProgressed(insert);
80                 }
81         }
82
83         /**
84          * Notifies all listeners that the insert generated a URI.
85          *
86          * @see InsertListener#insertGeneratedURI(Insert, String)
87          * @param insert
88          *            The insert that generated a URI
89          * @param generatedUri
90          *            The URI that was generated
91          */
92         public void fireInsertGeneratedURI(Insert insert, String generatedUri) {
93                 for (InsertListener insertListener : getListeners()) {
94                         insertListener.insertGeneratedURI(insert, generatedUri);
95                 }
96         }
97
98         /**
99          * Notifies all listeners that the insert has finished.
100          *
101          * @see InsertListener#insertFinished(Insert)
102          * @param insert
103          *            The insert that was finished
104          */
105         public void fireInsertFinished(Insert insert) {
106                 for (InsertListener insertListener : getListeners()) {
107                         insertListener.insertFinished(insert);
108                 }
109         }
110
111 }