KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > jdom > DocumentWrapper


1 package com.icl.saxon.jdom;
2 import com.icl.saxon.om.DocumentInfo;
3 import com.icl.saxon.om.NamePool;
4 import com.icl.saxon.om.NodeInfo;
5 import com.icl.saxon.KeyManager;
6 import org.jdom.Document;
7
8 import java.util.Hashtable JavaDoc;
9
10
11 /**
12   * The root node of an XPath tree. (Or equivalently, the tree itself).<P>
13   * This class should have been named Root; it is used not only for the root of a document,
14   * but also for the root of a result tree fragment, which is not constrained to contain a
15   * single top-level element.
16   * @author <A HREF="mailto:mhkay@iclway.co.uk>Michael H. Kay</A>
17   */

18
19 public class DocumentWrapper extends NodeWrapper implements DocumentInfo {
20     
21     protected Hashtable JavaDoc keyTable = new Hashtable JavaDoc();
22     protected NamePool namePool;
23     protected String JavaDoc baseURI;
24     
25     public DocumentWrapper(Document doc, String JavaDoc baseURI) {
26         super(doc, null, 0);
27         node = doc;
28         nodeType = NodeInfo.ROOT;
29         this.baseURI = baseURI;
30         docWrapper = this;
31         namePool = NamePool.getDefaultNamePool();
32     }
33
34     /**
35     * Set the name pool used for all names in this document
36     */

37     
38     public void setNamePool(NamePool pool) {
39         namePool = pool;
40     }
41     
42     /**
43     * Get the name pool used for the names in this document
44     */

45     
46     public NamePool getNamePool() {
47         return namePool;
48     }
49     
50     /**
51     * Get the element with a given ID, if any
52     * @param id the required ID value
53     * @return null: JDOM does not provide any information about attribute types.
54     */

55     
56     public NodeInfo selectID(String JavaDoc id) {
57         return null;
58     }
59
60     /**
61     * Get the index for a given key
62     * @param keymanager The key manager managing this key
63     * @param fingerprint The fingerprint of the name of the key (unique with the key manager)
64     * @return The index, if one has been built, in the form of a Hashtable that
65     * maps the key value to a list of nodes having that key value. If no index
66     * has been built, returns null.
67     */

68
69     public Hashtable JavaDoc getKeyIndex(KeyManager keyManager, int fingerprint) {
70         String JavaDoc key = keyManager.hashCode() + "#" + fingerprint;
71         return (Hashtable JavaDoc)keyTable.get(key);
72     }
73
74     /**
75     * Set the index for a given key
76     * @param keymanager The key manager managing this key
77     * @param fingerprint The fingerprint of the name of the key (unique with the key manager)
78     * @param index the index, in the form of a Hashtable that
79     * maps the key value to a list of nodes having that key value
80     */

81
82     public void setKeyIndex(KeyManager keyManager, int fingerprint, Hashtable JavaDoc index) {
83         String JavaDoc key = keyManager.hashCode() + "#" + fingerprint;
84         keyTable.put(key, index);
85     }
86
87     /**
88     * Get the unparsed entity with a given name
89     * @param name the name of the entity
90     * @return null: JDOM does not provide access to unparsed entities
91     */

92
93     public String JavaDoc getUnparsedEntity(String JavaDoc name) {
94         return null;
95     }
96
97     
98 }
99
100 //
101
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
102
// you may not use this file except in compliance with the License. You may obtain a copy of the
103
// License at http://www.mozilla.org/MPL/
104
//
105
// Software distributed under the License is distributed on an "AS IS" basis,
106
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
107
// See the License for the specific language governing rights and limitations under the License.
108
//
109
// The Original Code is: all this file.
110
//
111
// The Initial Developer of the Original Code is
112
// Michael Kay (mhkay@iclway.co.uk).
113
//
114
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
115
//
116
// Contributor(s): none.
117
//
118
Popular Tags