View Javadoc

1   /*
2    * Copyright 1999-2006 Faculty of Mathematics, Physics
3    * and Informatics, Comenius University, Bratislava. This file is protected by
4    * the Mozilla Public License version 1.1 (the License); you may not use this
5    * file except in compliance with the License. You may obtain a copy of the
6    * License at http://euromath2.sourceforge.net/license.html Unless required by
7    * applicable law or agreed to in writing, software distributed under the
8    * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9    * OF ANY KIND, either express or implied. See the License for the specific
10   * language governing permissions and limitations under the License.
11   */
12  /*
13   * This file is protected by the Mozilla Public License
14   * located in euromath2-bin.zip file, downloadable from
15   * http://sourceforge.net/projects/euromath2/.
16   */
17  package sk.uniba.euromath.document.schema;
18  import java.util.Map;
19  import javax.xml.namespace.QName;
20  import sk.baka.ikslibs.ptr.DOMPoint;
21  import sk.uniba.euromath.document.schema.plug.IElementLocP;
22  import sk.uniba.euromath.document.schema.plug.INameListP;
23  import sk.uniba.euromath.document.schema.plug.INewElementRuleP;
24  /***
25   * Mutable instance, representing element locator. This element can be
26   * inserted amongst children of some element.
27   * @author Martin Vysny
28   */
29  public final class ElementLoc {
30  	/***
31  	 * Returns point, where the element can be inserted.
32  	 */
33  	public final DOMPoint ip;
34  	/***
35  	 * Returns namelist for element, that can be inserted at specified position.
36  	 */
37  	public INameList<NewElementRule> nameList;
38  	/***
39  	 * Constructor.
40  	 * @param locP wrap this instance.
41  	 */
42  	ElementLoc(IElementLocP locP) {
43  		super();
44  		this.ip = locP.getDOMPoint();
45  		INameListP<INewElementRuleP> nameList = locP.getNameList();
46  		this.nameList = new NameListWrapper<NewElementRule,INewElementRuleP>(nameList, providerInstance);
47  	}
48  	/***
49  	 * Provides the namelist with foreign roots.
50  	 * @author Martin Vysny
51  	 */
52  	private class ForeignRootsProvider implements INameListWrapperDataProvider<INewElementRuleP> {
53  		/*
54  		 * (non-Javadoc)
55  		 * @see sk.uniba.euromath.document.schema.INameListWrapperDataProvider#getForeignRules(sk.uniba.euromath.document.schema.plug.NameListP)
56  		 */
57  		public Map<QName,INewElementRuleP> getForeignRules(INameListP original) {
58  			return SchemaPool.getInstance().getForeignRoots(original);
59  		}
60  	}
61  	/***
62  	 * The instance of the provider.
63  	 */
64  	private final ForeignRootsProvider providerInstance = new ForeignRootsProvider();
65  }