KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xpath > internal > domapi > XPathNamespaceImpl


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 /*
17  * $Id: XPathNamespaceImpl.java,v 1.2.4.1 2005/09/10 04:10:02 jeffsuttor Exp $
18  */

19
20
21 package com.sun.org.apache.xpath.internal.domapi;
22
23 import org.w3c.dom.Attr JavaDoc;
24 import org.w3c.dom.DOMException JavaDoc;
25 import org.w3c.dom.Document JavaDoc;
26 import org.w3c.dom.Element JavaDoc;
27 import org.w3c.dom.NamedNodeMap JavaDoc;
28 import org.w3c.dom.Node JavaDoc;
29 import org.w3c.dom.NodeList JavaDoc;
30 import org.w3c.dom.xpath.XPathNamespace;
31
32 import org.w3c.dom.UserDataHandler JavaDoc;
33
34 /**
35  *
36  *
37  * The <code>XPathNamespace</code> interface is returned by
38  * <code>XPathResult</code> interfaces to represent the XPath namespace node
39  * type that DOM lacks. There is no public constructor for this node type.
40  * Attempts to place it into a hierarchy or a NamedNodeMap result in a
41  * <code>DOMException</code> with the code <code>HIERARCHY_REQUEST_ERR</code>
42  * . This node is read only, so methods or setting of attributes that would
43  * mutate the node result in a DOMException with the code
44  * <code>NO_MODIFICATION_ALLOWED_ERR</code>.
45  * <p>The core specification describes attributes of the <code>Node</code>
46  * interface that are different for different node node types but does not
47  * describe <code>XPATH_NAMESPACE_NODE</code>, so here is a description of
48  * those attributes for this node type. All attributes of <code>Node</code>
49  * not described in this section have a <code>null</code> or
50  * <code>false</code> value.
51  * <p><code>ownerDocument</code> matches the <code>ownerDocument</code> of the
52  * <code>ownerElement</code> even if the element is later adopted.
53  * <p><code>prefix</code> is the prefix of the namespace represented by the
54  * node.
55  * <p><code>nodeName</code> is the same as <code>prefix</code>.
56  * <p><code>nodeType</code> is equal to <code>XPATH_NAMESPACE_NODE</code>.
57  * <p><code>namespaceURI</code> is the namespace URI of the namespace
58  * represented by the node.
59  * <p><code>adoptNode</code>, <code>cloneNode</code>, and
60  * <code>importNode</code> fail on this node type by raising a
61  * <code>DOMException</code> with the code <code>NOT_SUPPORTED_ERR</code>.In
62  * future versions of the XPath specification, the definition of a namespace
63  * node may be changed incomatibly, in which case incompatible changes to
64  * field values may be required to implement versions beyond XPath 1.0.
65  * <p>See also the <a HREF='http://www.w3.org/TR/2004/NOTE-DOM-Level-3-XPath-20040226'>Document Object Model (DOM) Level 3 XPath Specification</a>.
66  *
67  * This implementation wraps the DOM attribute node that contained the
68  * namespace declaration.
69  * @xsl.usage internal
70  */

71
72 class XPathNamespaceImpl implements XPathNamespace {
73
74     // Node that XPathNamespaceImpl wraps
75
final private Node JavaDoc m_attributeNode;
76     
77     /**
78      * Constructor for XPathNamespaceImpl.
79      */

80     XPathNamespaceImpl(Node JavaDoc node) {
81         m_attributeNode = node;
82     }
83
84     /**
85      * @see com.sun.org.apache.xalan.internal.dom3.xpath.XPathNamespace#getOwnerElement()
86      */

87     public Element JavaDoc getOwnerElement() {
88         return ((Attr JavaDoc)m_attributeNode).getOwnerElement();
89     }
90
91     /**
92      * @see org.w3c.dom.Node#getNodeName()
93      */

94     public String JavaDoc getNodeName() {
95         return "#namespace";
96     }
97
98     /**
99      * @see org.w3c.dom.Node#getNodeValue()
100      */

101     public String JavaDoc getNodeValue() throws DOMException JavaDoc {
102         return m_attributeNode.getNodeValue();
103     }
104
105     /**
106      * @see org.w3c.dom.Node#setNodeValue(String)
107      */

108     public void setNodeValue(String JavaDoc arg0) throws DOMException JavaDoc {
109     }
110
111     /**
112      * @see org.w3c.dom.Node#getNodeType()
113      */

114     public short getNodeType() {
115         return XPathNamespace.XPATH_NAMESPACE_NODE;
116     }
117
118     /**
119      * @see org.w3c.dom.Node#getParentNode()
120      */

121     public Node JavaDoc getParentNode() {
122         return m_attributeNode.getParentNode();
123     }
124
125     /**
126      * @see org.w3c.dom.Node#getChildNodes()
127      */

128     public NodeList JavaDoc getChildNodes() {
129         return m_attributeNode.getChildNodes();
130     }
131
132     /**
133      * @see org.w3c.dom.Node#getFirstChild()
134      */

135     public Node JavaDoc getFirstChild() {
136         return m_attributeNode.getFirstChild();
137     }
138
139     /**
140      * @see org.w3c.dom.Node#getLastChild()
141      */

142     public Node JavaDoc getLastChild() {
143         return m_attributeNode.getLastChild();
144     }
145
146     /**
147      * @see org.w3c.dom.Node#getPreviousSibling()
148      */

149     public Node JavaDoc getPreviousSibling() {
150         return m_attributeNode.getPreviousSibling();
151     }
152
153     /**
154      * @see org.w3c.dom.Node#getNextSibling()
155      */

156     public Node JavaDoc getNextSibling() {
157         return m_attributeNode.getNextSibling();
158     }
159
160     /**
161      * @see org.w3c.dom.Node#getAttributes()
162      */

163     public NamedNodeMap JavaDoc getAttributes() {
164         return m_attributeNode.getAttributes();
165     }
166
167     /**
168      * @see org.w3c.dom.Node#getOwnerDocument()
169      */

170     public Document JavaDoc getOwnerDocument() {
171         return m_attributeNode.getOwnerDocument();
172     }
173
174     /**
175      * @see org.w3c.dom.Node#insertBefore(Node, Node)
176      */

177     public Node JavaDoc insertBefore(Node JavaDoc arg0, Node JavaDoc arg1) throws DOMException JavaDoc {
178         return null;
179     }
180
181     /**
182      * @see org.w3c.dom.Node#replaceChild(Node, Node)
183      */

184     public Node JavaDoc replaceChild(Node JavaDoc arg0, Node JavaDoc arg1) throws DOMException JavaDoc {
185         return null;
186     }
187
188     /**
189      * @see org.w3c.dom.Node#removeChild(Node)
190      */

191     public Node JavaDoc removeChild(Node JavaDoc arg0) throws DOMException JavaDoc {
192         return null;
193     }
194
195     /**
196      * @see org.w3c.dom.Node#appendChild(Node)
197      */

198     public Node JavaDoc appendChild(Node JavaDoc arg0) throws DOMException JavaDoc {
199         return null;
200     }
201
202     /**
203      * @see org.w3c.dom.Node#hasChildNodes()
204      */

205     public boolean hasChildNodes() {
206         return false;
207     }
208
209     /**
210      * @see org.w3c.dom.Node#cloneNode(boolean)
211      */

212     public Node JavaDoc cloneNode(boolean arg0) {
213         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR,null);
214     }
215
216     /**
217      * @see org.w3c.dom.Node#normalize()
218      */

219     public void normalize() {
220         m_attributeNode.normalize();
221     }
222
223     /**
224      * @see org.w3c.dom.Node#isSupported(String, String)
225      */

226     public boolean isSupported(String JavaDoc arg0, String JavaDoc arg1) {
227         return m_attributeNode.isSupported(arg0, arg1);
228     }
229
230     /**
231      * @see org.w3c.dom.Node#getNamespaceURI()
232      */

233     public String JavaDoc getNamespaceURI() {
234         
235         // For namespace node, the namespaceURI is the namespace URI
236
// of the namespace represented by the node.
237
return m_attributeNode.getNodeValue();
238     }
239
240     /**
241      * @see org.w3c.dom.Node#getPrefix()
242      */

243     public String JavaDoc getPrefix() {
244         return m_attributeNode.getPrefix();
245     }
246
247     /**
248      * @see org.w3c.dom.Node#setPrefix(String)
249      */

250     public void setPrefix(String JavaDoc arg0) throws DOMException JavaDoc {
251     }
252
253     /**
254      * @see org.w3c.dom.Node#getLocalName()
255      */

256     public String JavaDoc getLocalName() {
257         
258         // For namespace node, the local name is the same as the prefix
259
return m_attributeNode.getPrefix();
260     }
261
262     /**
263      * @see org.w3c.dom.Node#hasAttributes()
264      */

265     public boolean hasAttributes() {
266         return m_attributeNode.hasAttributes();
267     }
268
269     public String JavaDoc getBaseURI ( ) {
270         return null;
271     }
272
273     public short compareDocumentPosition(Node JavaDoc other) throws DOMException JavaDoc {
274         return 0;
275     }
276
277     private String JavaDoc textContent;
278     
279     public String JavaDoc getTextContent() throws DOMException JavaDoc {
280         return textContent;
281     }
282     
283     public void setTextContent(String JavaDoc textContent) throws DOMException JavaDoc {
284         this.textContent = textContent;
285     }
286     
287     public boolean isSameNode(Node JavaDoc other) {
288         return false;
289     }
290
291     public String JavaDoc lookupPrefix(String JavaDoc namespaceURI) {
292         return ""; //PENDING
293
}
294
295     public boolean isDefaultNamespace(String JavaDoc namespaceURI) {
296         return false;
297     }
298
299     public String JavaDoc lookupNamespaceURI(String JavaDoc prefix) {
300         return null;
301     }
302
303     public boolean isEqualNode(Node JavaDoc arg) {
304         return false;
305     }
306
307     public Object JavaDoc getFeature(String JavaDoc feature, String JavaDoc version) {
308         return null; //PENDING
309
}
310
311     public Object JavaDoc setUserData(String JavaDoc key,
312                               Object JavaDoc data,
313                               UserDataHandler JavaDoc handler) {
314         return null; //PENDING
315
}
316
317     public Object JavaDoc getUserData(String JavaDoc key) {
318         return null;
319     }
320 }
321
Popular Tags