1
2
3
4
5
6
7
8
9
10
11
12 package sk.uniba.euromath.document;
13 import java.util.HashSet;
14 import java.util.Set;
15 /***
16 * Manages the document listeners. All listeners must be equal only to itself in
17 * order for them to be correctly placed into a <code>Set</code>. Class is
18 * not intended to be instantiated by clients.
19 * @author Martin Vysny
20 */
21 public final class DocumentListeners {
22 /***
23 * Reference to the xml access.
24 */
25 private final XMLAccess xmlAccess;
26 /***
27 * Set of registered general listener instances.
28 */
29 private final Set<IGeneralListener> general = new HashSet<IGeneralListener>();
30 /***
31 * Constructor.
32 * @param xmlAccess
33 */
34 DocumentListeners(XMLAccess xmlAccess) {
35 super();
36 this.xmlAccess = xmlAccess;
37 }
38 /***
39 * Called when the document was transformed and is ready for rendering.
40 * Invokes general listener.
41 */
42 void documentWasTransformed() {
43 for (IGeneralListener listener : general) {
44 listener.documentWasTransformed(xmlAccess);
45 }
46 }
47 /***
48 * Registers the general listener.
49 * @param listener the listener to be registered.
50 */
51 public void addGeneralListener(IGeneralListener listener) {
52 general.add(listener);
53 }
54 /***
55 * Removes the general listener.
56 * @param listener the listener to be removed.
57 */
58 public void removeGeneralListener(IGeneralListener listener) {
59 general.remove(listener);
60 }
61 }