View Javadoc

1   /*
2    * Copyright 1999-2006 Faculty of Mathematics, Physics and Informatics, Comenius
3    * University, Bratislava. This file is protected by the Mozilla Public License
4    * version 1.1 (the "License"); you may not use this file except in compliance
5    * with the License. You may obtain a copy of the License at
6    * http://euromath2.sourceforge.net/license.html Unless required by applicable
7    * law or agreed to in writing, software distributed under the License is
8    * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9    * KIND, either express or implied. See the License for the specific language
10   * governing permissions and limitations under the License.
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  }