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 import org.w3c.dom.Node;
16 /***
17 * Manages the document listeners. All listeners must be equal only to itself in
18 * order for them to be correctly placed into a <code>Set</code>. Class is
19 * not intended to be instantiated by clients.
20 * @author Martin Vysny
21 */
22 public final class DocumentListeners {
23 /***
24 * Reference to the xml access.
25 */
26 private final XMLAccess xmlAccess;
27 /***
28 * Set of registered general listener instances.
29 */
30 private final Set<IGeneralListener> general = new HashSet<IGeneralListener>();
31 /***
32 * Set of registered modifier listener instances.
33 * @deprecated
34 */
35 @Deprecated
36 private final Set<IModifierListener> modifier = new HashSet<IModifierListener>();
37 /***
38 * Constructor.
39 * @param xmlAccess
40 */
41 DocumentListeners(XMLAccess xmlAccess) {
42 super();
43 this.xmlAccess = xmlAccess;
44 }
45 /***
46 * Called when the document was transformed and is ready for rendering.
47 * Invokes general listener.
48 */
49 void documentWasTransformed() {
50 for (IGeneralListener listener : general) {
51 listener.documentWasTransformed(xmlAccess);
52 }
53 }
54 /***
55 * Registers the general listener.
56 * @param listener the listener to be registered.
57 */
58 public void addGeneralListener(IGeneralListener listener) {
59 general.add(listener);
60 }
61 /***
62 * Removes the general listener.
63 * @param listener the listener to be removed.
64 */
65 public void removeGeneralListener(IGeneralListener listener) {
66 general.remove(listener);
67 }
68 /***
69 * Registers the modifier listener.
70 * @param listener the listener to be registered.
71 * @deprecated
72 */
73 @Deprecated
74 public void addModifierListener(IModifierListener listener) {
75 modifier.add(listener);
76 }
77 /***
78 * Removes the modifier listener.
79 * @param listener the listener to be removed.
80 * @deprecated
81 */
82 @Deprecated
83 public void removeModifierListener(IModifierListener listener) {
84 modifier.remove(listener);
85 }
86 /***
87 * Notifies listeners that a node has been added. Internal method, must not be called by clients.
88 * @param node the node
89 * @param changesIdLevel see <code>IModifierListener</code> interface for
90 * details.
91 * @see IModifierListener
92 * @deprecated
93 */
94 @Deprecated
95 public void nodeAdded(Node node, boolean changesIdLevel) {
96 for (IModifierListener listener : modifier) {
97 listener.nodeAdded(node, changesIdLevel);
98 }
99 }
100 /***
101 * Notifies listeners that a node is about to be deleted. Internal method, must not be called by clients.
102 * @param node the node.
103 * @param changesIdLevel see <code>IModifierListener</code> interface for
104 * details.
105 * @see IModifierListener
106 * @deprecated
107 */
108 @Deprecated
109 public void nodeDelete(Node node, boolean changesIdLevel) {
110 for (IModifierListener listener : modifier) {
111 listener.nodeDelete(node, changesIdLevel);
112 }
113 }
114 /***
115 * Notifies listeners that a node has been changed. Internal method, must not be called by clients.
116 * @param tracer tracks changes.
117 * @param changesIdLevel see <code>IModifierListener</code> interface for
118 * details.
119 * @see IModifierListener
120 * @deprecated
121 */
122 @Deprecated
123 public void nodeModified(ChangeTracer tracer, boolean changesIdLevel) {
124 for (IModifierListener listener : modifier) {
125 listener.nodeModified(tracer, changesIdLevel);
126 }
127 }
128 }