blob: c77dda7bba6d3b18c5dea5560d870a49c88282f8 [file] [log] [blame]
<HTML>
<BODY BGCOLOR="white">
<PRE>
<FONT color="green">001</FONT> /*<a name="line.1"></a>
<FONT color="green">002</FONT> * Licensed to the Apache Software Foundation (ASF) under one<a name="line.2"></a>
<FONT color="green">003</FONT> * or more contributor license agreements. See the NOTICE file<a name="line.3"></a>
<FONT color="green">004</FONT> * distributed with this work for additional information<a name="line.4"></a>
<FONT color="green">005</FONT> * regarding copyright ownership. The ASF licenses this file<a name="line.5"></a>
<FONT color="green">006</FONT> * to you under the Apache License, Version 2.0 (the "License");<a name="line.6"></a>
<FONT color="green">007</FONT> * you may not use this file except in compliance with the License.<a name="line.7"></a>
<FONT color="green">008</FONT> * You may obtain a copy of the License at<a name="line.8"></a>
<FONT color="green">009</FONT> *<a name="line.9"></a>
<FONT color="green">010</FONT> * http://www.apache.org/licenses/LICENSE-2.0<a name="line.10"></a>
<FONT color="green">011</FONT> *<a name="line.11"></a>
<FONT color="green">012</FONT> * Unless required by applicable law or agreed to in writing, software<a name="line.12"></a>
<FONT color="green">013</FONT> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.13"></a>
<FONT color="green">014</FONT> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.14"></a>
<FONT color="green">015</FONT> * See the License for the specific language governing permissions and<a name="line.15"></a>
<FONT color="green">016</FONT> * limitations under the License.<a name="line.16"></a>
<FONT color="green">017</FONT> */<a name="line.17"></a>
<FONT color="green">018</FONT> /*<a name="line.18"></a>
<FONT color="green">019</FONT> * $Id: DOM2DTMdefaultNamespaceDeclarationNode.java 1225427 2011-12-29 04:33:32Z mrglavas $<a name="line.19"></a>
<FONT color="green">020</FONT> */<a name="line.20"></a>
<FONT color="green">021</FONT> <a name="line.21"></a>
<FONT color="green">022</FONT> package org.apache.xml.dtm.ref.dom2dtm;<a name="line.22"></a>
<FONT color="green">023</FONT> <a name="line.23"></a>
<FONT color="green">024</FONT> import org.apache.xml.dtm.DTMException;<a name="line.24"></a>
<FONT color="green">025</FONT> <a name="line.25"></a>
<FONT color="green">026</FONT> import org.w3c.dom.Attr;<a name="line.26"></a>
<FONT color="green">027</FONT> import org.w3c.dom.Document;<a name="line.27"></a>
<FONT color="green">028</FONT> import org.w3c.dom.Element;<a name="line.28"></a>
<FONT color="green">029</FONT> import org.w3c.dom.NamedNodeMap;<a name="line.29"></a>
<FONT color="green">030</FONT> import org.w3c.dom.Node;<a name="line.30"></a>
<FONT color="green">031</FONT> import org.w3c.dom.NodeList;<a name="line.31"></a>
<FONT color="green">032</FONT> import org.w3c.dom.TypeInfo;<a name="line.32"></a>
<FONT color="green">033</FONT> import org.w3c.dom.UserDataHandler;<a name="line.33"></a>
<FONT color="green">034</FONT> import org.w3c.dom.DOMException;<a name="line.34"></a>
<FONT color="green">035</FONT> <a name="line.35"></a>
<FONT color="green">036</FONT> /** This is a kluge to let us shove a declaration for xml: into the<a name="line.36"></a>
<FONT color="green">037</FONT> * DOM2DTM model. Basically, it creates a proxy node in DOM space to<a name="line.37"></a>
<FONT color="green">038</FONT> * carry the additional information. This is _NOT_ a full DOM<a name="line.38"></a>
<FONT color="green">039</FONT> * implementation, and shouldn't be one since it sits alongside the<a name="line.39"></a>
<FONT color="green">040</FONT> * DOM rather than becoming part of the DOM model.<a name="line.40"></a>
<FONT color="green">041</FONT> * <a name="line.41"></a>
<FONT color="green">042</FONT> * (This used to be an internal class within DOM2DTM. Moved out because<a name="line.42"></a>
<FONT color="green">043</FONT> * I need to perform an instanceof operation on it to support a temporary<a name="line.43"></a>
<FONT color="green">044</FONT> * workaround in DTMManagerDefault.)<a name="line.44"></a>
<FONT color="green">045</FONT> * <a name="line.45"></a>
<FONT color="green">046</FONT> * %REVIEW% What if the DOM2DTM was built around a DocumentFragment and<a name="line.46"></a>
<FONT color="green">047</FONT> * there isn't a single root element? I think this fails that case...<a name="line.47"></a>
<FONT color="green">048</FONT> * <a name="line.48"></a>
<FONT color="green">049</FONT> * %REVIEW% An alternative solution would be to create the node _only_<a name="line.49"></a>
<FONT color="green">050</FONT> * in DTM space, but given how DOM2DTM is currently written I think<a name="line.50"></a>
<FONT color="green">051</FONT> * this is simplest.<a name="line.51"></a>
<FONT color="green">052</FONT> * */<a name="line.52"></a>
<FONT color="green">053</FONT> public class DOM2DTMdefaultNamespaceDeclarationNode implements Attr,TypeInfo<a name="line.53"></a>
<FONT color="green">054</FONT> {<a name="line.54"></a>
<FONT color="green">055</FONT> static final String NOT_SUPPORTED_ERR="Unsupported operation on pseudonode";<a name="line.55"></a>
<FONT color="green">056</FONT> <a name="line.56"></a>
<FONT color="green">057</FONT> Element pseudoparent;<a name="line.57"></a>
<FONT color="green">058</FONT> String prefix,uri,nodename;<a name="line.58"></a>
<FONT color="green">059</FONT> int handle;<a name="line.59"></a>
<FONT color="green">060</FONT> DOM2DTMdefaultNamespaceDeclarationNode(Element pseudoparent,String prefix,String uri,int handle)<a name="line.60"></a>
<FONT color="green">061</FONT> {<a name="line.61"></a>
<FONT color="green">062</FONT> this.pseudoparent=pseudoparent;<a name="line.62"></a>
<FONT color="green">063</FONT> this.prefix=prefix;<a name="line.63"></a>
<FONT color="green">064</FONT> this.uri=uri;<a name="line.64"></a>
<FONT color="green">065</FONT> this.handle=handle;<a name="line.65"></a>
<FONT color="green">066</FONT> this.nodename="xmlns:"+prefix;<a name="line.66"></a>
<FONT color="green">067</FONT> }<a name="line.67"></a>
<FONT color="green">068</FONT> public String getNodeName() {return nodename;}<a name="line.68"></a>
<FONT color="green">069</FONT> public String getName() {return nodename;}<a name="line.69"></a>
<FONT color="green">070</FONT> public String getNamespaceURI() {return "http://www.w3.org/2000/xmlns/";}<a name="line.70"></a>
<FONT color="green">071</FONT> public String getPrefix() {return prefix;}<a name="line.71"></a>
<FONT color="green">072</FONT> public String getLocalName() {return prefix;}<a name="line.72"></a>
<FONT color="green">073</FONT> public String getNodeValue() {return uri;}<a name="line.73"></a>
<FONT color="green">074</FONT> public String getValue() {return uri;}<a name="line.74"></a>
<FONT color="green">075</FONT> public Element getOwnerElement() {return pseudoparent;}<a name="line.75"></a>
<FONT color="green">076</FONT> <a name="line.76"></a>
<FONT color="green">077</FONT> public boolean isSupported(String feature, String version) {return false;}<a name="line.77"></a>
<FONT color="green">078</FONT> public boolean hasChildNodes() {return false;}<a name="line.78"></a>
<FONT color="green">079</FONT> public boolean hasAttributes() {return false;}<a name="line.79"></a>
<FONT color="green">080</FONT> public Node getParentNode() {return null;}<a name="line.80"></a>
<FONT color="green">081</FONT> public Node getFirstChild() {return null;}<a name="line.81"></a>
<FONT color="green">082</FONT> public Node getLastChild() {return null;}<a name="line.82"></a>
<FONT color="green">083</FONT> public Node getPreviousSibling() {return null;}<a name="line.83"></a>
<FONT color="green">084</FONT> public Node getNextSibling() {return null;}<a name="line.84"></a>
<FONT color="green">085</FONT> public boolean getSpecified() {return false;}<a name="line.85"></a>
<FONT color="green">086</FONT> public void normalize() {return;}<a name="line.86"></a>
<FONT color="green">087</FONT> public NodeList getChildNodes() {return null;}<a name="line.87"></a>
<FONT color="green">088</FONT> public NamedNodeMap getAttributes() {return null;}<a name="line.88"></a>
<FONT color="green">089</FONT> public short getNodeType() {return Node.ATTRIBUTE_NODE;}<a name="line.89"></a>
<FONT color="green">090</FONT> public void setNodeValue(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}<a name="line.90"></a>
<FONT color="green">091</FONT> public void setValue(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}<a name="line.91"></a>
<FONT color="green">092</FONT> public void setPrefix(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}<a name="line.92"></a>
<FONT color="green">093</FONT> public Node insertBefore(Node a, Node b) {throw new DTMException(NOT_SUPPORTED_ERR);}<a name="line.93"></a>
<FONT color="green">094</FONT> public Node replaceChild(Node a, Node b) {throw new DTMException(NOT_SUPPORTED_ERR);}<a name="line.94"></a>
<FONT color="green">095</FONT> public Node appendChild(Node a) {throw new DTMException(NOT_SUPPORTED_ERR);}<a name="line.95"></a>
<FONT color="green">096</FONT> public Node removeChild(Node a) {throw new DTMException(NOT_SUPPORTED_ERR);}<a name="line.96"></a>
<FONT color="green">097</FONT> public Document getOwnerDocument() {return pseudoparent.getOwnerDocument();}<a name="line.97"></a>
<FONT color="green">098</FONT> public Node cloneNode(boolean deep) {throw new DTMException(NOT_SUPPORTED_ERR);}<a name="line.98"></a>
<FONT color="green">099</FONT> <a name="line.99"></a>
<FONT color="green">100</FONT> /** Non-DOM method, part of the temporary kluge<a name="line.100"></a>
<FONT color="green">101</FONT> * %REVIEW% This would be a pruning problem, but since it will always be<a name="line.101"></a>
<FONT color="green">102</FONT> * added to the root element and we prune on elements, we shouldn't have <a name="line.102"></a>
<FONT color="green">103</FONT> * to worry.<a name="line.103"></a>
<FONT color="green">104</FONT> */<a name="line.104"></a>
<FONT color="green">105</FONT> public int getHandleOfNode() <a name="line.105"></a>
<FONT color="green">106</FONT> {<a name="line.106"></a>
<FONT color="green">107</FONT> return handle;<a name="line.107"></a>
<FONT color="green">108</FONT> }<a name="line.108"></a>
<FONT color="green">109</FONT> <a name="line.109"></a>
<FONT color="green">110</FONT> //RAMESH: PENDING=&gt; Add proper implementation for the below DOM L3 additions<a name="line.110"></a>
<FONT color="green">111</FONT> <a name="line.111"></a>
<FONT color="green">112</FONT> /**<a name="line.112"></a>
<FONT color="green">113</FONT> * @see org.w3c.dom.TypeInfo#getTypeName()<a name="line.113"></a>
<FONT color="green">114</FONT> */<a name="line.114"></a>
<FONT color="green">115</FONT> public String getTypeName() {return null; }<a name="line.115"></a>
<FONT color="green">116</FONT> <a name="line.116"></a>
<FONT color="green">117</FONT> /**<a name="line.117"></a>
<FONT color="green">118</FONT> * @see org.w3c.dom.TypeInfo#getTypeNamespace()<a name="line.118"></a>
<FONT color="green">119</FONT> */<a name="line.119"></a>
<FONT color="green">120</FONT> public String getTypeNamespace() { return null;}<a name="line.120"></a>
<FONT color="green">121</FONT> <a name="line.121"></a>
<FONT color="green">122</FONT> /**<a name="line.122"></a>
<FONT color="green">123</FONT> * @see or.gw3c.dom.TypeInfo#isDerivedFrom(String,String,int)<a name="line.123"></a>
<FONT color="green">124</FONT> */<a name="line.124"></a>
<FONT color="green">125</FONT> public boolean isDerivedFrom( String ns, String localName, int derivationMethod ) {<a name="line.125"></a>
<FONT color="green">126</FONT> return false;<a name="line.126"></a>
<FONT color="green">127</FONT> }<a name="line.127"></a>
<FONT color="green">128</FONT> <a name="line.128"></a>
<FONT color="green">129</FONT> public TypeInfo getSchemaTypeInfo() { return this; }<a name="line.129"></a>
<FONT color="green">130</FONT> <a name="line.130"></a>
<FONT color="green">131</FONT> public boolean isId( ) { return false; }<a name="line.131"></a>
<FONT color="green">132</FONT> <a name="line.132"></a>
<FONT color="green">133</FONT> /**<a name="line.133"></a>
<FONT color="green">134</FONT> * Associate an object to a key on this node. The object can later be<a name="line.134"></a>
<FONT color="green">135</FONT> * retrieved from this node by calling &lt;code&gt;getUserData&lt;/code&gt; with the<a name="line.135"></a>
<FONT color="green">136</FONT> * same key.<a name="line.136"></a>
<FONT color="green">137</FONT> * @param key The key to associate the object to.<a name="line.137"></a>
<FONT color="green">138</FONT> * @param data The object to associate to the given key, or<a name="line.138"></a>
<FONT color="green">139</FONT> * &lt;code&gt;null&lt;/code&gt; to remove any existing association to that key.<a name="line.139"></a>
<FONT color="green">140</FONT> * @param handler The handler to associate to that key, or<a name="line.140"></a>
<FONT color="green">141</FONT> * &lt;code&gt;null&lt;/code&gt;.<a name="line.141"></a>
<FONT color="green">142</FONT> * @return Returns the &lt;code&gt;DOMObject&lt;/code&gt; previously associated to<a name="line.142"></a>
<FONT color="green">143</FONT> * the given key on this node, or &lt;code&gt;null&lt;/code&gt; if there was none.<a name="line.143"></a>
<FONT color="green">144</FONT> * @since DOM Level 3<a name="line.144"></a>
<FONT color="green">145</FONT> */<a name="line.145"></a>
<FONT color="green">146</FONT> public Object setUserData(String key,<a name="line.146"></a>
<FONT color="green">147</FONT> Object data,<a name="line.147"></a>
<FONT color="green">148</FONT> UserDataHandler handler) {<a name="line.148"></a>
<FONT color="green">149</FONT> return getOwnerDocument().setUserData( key, data, handler);<a name="line.149"></a>
<FONT color="green">150</FONT> }<a name="line.150"></a>
<FONT color="green">151</FONT> <a name="line.151"></a>
<FONT color="green">152</FONT> /**<a name="line.152"></a>
<FONT color="green">153</FONT> * Retrieves the object associated to a key on a this node. The object<a name="line.153"></a>
<FONT color="green">154</FONT> * must first have been set to this node by calling<a name="line.154"></a>
<FONT color="green">155</FONT> * &lt;code&gt;setUserData&lt;/code&gt; with the same key.<a name="line.155"></a>
<FONT color="green">156</FONT> * @param key The key the object is associated to.<a name="line.156"></a>
<FONT color="green">157</FONT> * @return Returns the &lt;code&gt;DOMObject&lt;/code&gt; associated to the given key<a name="line.157"></a>
<FONT color="green">158</FONT> * on this node, or &lt;code&gt;null&lt;/code&gt; if there was none.<a name="line.158"></a>
<FONT color="green">159</FONT> * @since DOM Level 3<a name="line.159"></a>
<FONT color="green">160</FONT> */<a name="line.160"></a>
<FONT color="green">161</FONT> public Object getUserData(String key) {<a name="line.161"></a>
<FONT color="green">162</FONT> return getOwnerDocument().getUserData( key);<a name="line.162"></a>
<FONT color="green">163</FONT> } <a name="line.163"></a>
<FONT color="green">164</FONT> <a name="line.164"></a>
<FONT color="green">165</FONT> /**<a name="line.165"></a>
<FONT color="green">166</FONT> * This method returns a specialized object which implements the<a name="line.166"></a>
<FONT color="green">167</FONT> * specialized APIs of the specified feature and version. The<a name="line.167"></a>
<FONT color="green">168</FONT> * specialized object may also be obtained by using binding-specific<a name="line.168"></a>
<FONT color="green">169</FONT> * casting methods but is not necessarily expected to, as discussed in Mixed DOM implementations.<a name="line.169"></a>
<FONT color="green">170</FONT> * @param feature The name of the feature requested (case-insensitive).<a name="line.170"></a>
<FONT color="green">171</FONT> * @param version This is the version number of the feature to test. If<a name="line.171"></a>
<FONT color="green">172</FONT> * the version is &lt;code&gt;null&lt;/code&gt; or the empty string, supporting<a name="line.172"></a>
<FONT color="green">173</FONT> * any version of the feature will cause the method to return an<a name="line.173"></a>
<FONT color="green">174</FONT> * object that supports at least one version of the feature.<a name="line.174"></a>
<FONT color="green">175</FONT> * @return Returns an object which implements the specialized APIs of<a name="line.175"></a>
<FONT color="green">176</FONT> * the specified feature and version, if any, or &lt;code&gt;null&lt;/code&gt; if<a name="line.176"></a>
<FONT color="green">177</FONT> * there is no object which implements interfaces associated with that<a name="line.177"></a>
<FONT color="green">178</FONT> * feature. If the &lt;code&gt;DOMObject&lt;/code&gt; returned by this method<a name="line.178"></a>
<FONT color="green">179</FONT> * implements the &lt;code&gt;Node&lt;/code&gt; interface, it must delegate to the<a name="line.179"></a>
<FONT color="green">180</FONT> * primary core &lt;code&gt;Node&lt;/code&gt; and not return results inconsistent<a name="line.180"></a>
<FONT color="green">181</FONT> * with the primary core &lt;code&gt;Node&lt;/code&gt; such as attributes,<a name="line.181"></a>
<FONT color="green">182</FONT> * childNodes, etc.<a name="line.182"></a>
<FONT color="green">183</FONT> * @since DOM Level 3<a name="line.183"></a>
<FONT color="green">184</FONT> */<a name="line.184"></a>
<FONT color="green">185</FONT> public Object getFeature(String feature, String version) {<a name="line.185"></a>
<FONT color="green">186</FONT> // we don't have any alternate node, either this node does the job<a name="line.186"></a>
<FONT color="green">187</FONT> // or we don't have anything that does<a name="line.187"></a>
<FONT color="green">188</FONT> return isSupported(feature, version) ? this : null;<a name="line.188"></a>
<FONT color="green">189</FONT> }<a name="line.189"></a>
<FONT color="green">190</FONT> <a name="line.190"></a>
<FONT color="green">191</FONT> /**<a name="line.191"></a>
<FONT color="green">192</FONT> * Tests whether two nodes are equal.<a name="line.192"></a>
<FONT color="green">193</FONT> * &lt;br&gt;This method tests for equality of nodes, not sameness (i.e.,<a name="line.193"></a>
<FONT color="green">194</FONT> * whether the two nodes are references to the same object) which can be<a name="line.194"></a>
<FONT color="green">195</FONT> * tested with &lt;code&gt;Node.isSameNode&lt;/code&gt;. All nodes that are the same<a name="line.195"></a>
<FONT color="green">196</FONT> * will also be equal, though the reverse may not be true.<a name="line.196"></a>
<FONT color="green">197</FONT> * &lt;br&gt;Two nodes are equal if and only if the following conditions are<a name="line.197"></a>
<FONT color="green">198</FONT> * satisfied: The two nodes are of the same type.The following string<a name="line.198"></a>
<FONT color="green">199</FONT> * attributes are equal: &lt;code&gt;nodeName&lt;/code&gt;, &lt;code&gt;localName&lt;/code&gt;,<a name="line.199"></a>
<FONT color="green">200</FONT> * &lt;code&gt;namespaceURI&lt;/code&gt;, &lt;code&gt;prefix&lt;/code&gt;, &lt;code&gt;nodeValue&lt;/code&gt;<a name="line.200"></a>
<FONT color="green">201</FONT> * , &lt;code&gt;baseURI&lt;/code&gt;. This is: they are both &lt;code&gt;null&lt;/code&gt;, or<a name="line.201"></a>
<FONT color="green">202</FONT> * they have the same length and are character for character identical.<a name="line.202"></a>
<FONT color="green">203</FONT> * The &lt;code&gt;attributes&lt;/code&gt; &lt;code&gt;NamedNodeMaps&lt;/code&gt; are equal.<a name="line.203"></a>
<FONT color="green">204</FONT> * This is: they are both &lt;code&gt;null&lt;/code&gt;, or they have the same<a name="line.204"></a>
<FONT color="green">205</FONT> * length and for each node that exists in one map there is a node that<a name="line.205"></a>
<FONT color="green">206</FONT> * exists in the other map and is equal, although not necessarily at the<a name="line.206"></a>
<FONT color="green">207</FONT> * same index.The &lt;code&gt;childNodes&lt;/code&gt; &lt;code&gt;NodeLists&lt;/code&gt; are<a name="line.207"></a>
<FONT color="green">208</FONT> * equal. This is: they are both &lt;code&gt;null&lt;/code&gt;, or they have the<a name="line.208"></a>
<FONT color="green">209</FONT> * same length and contain equal nodes at the same index. This is true<a name="line.209"></a>
<FONT color="green">210</FONT> * for &lt;code&gt;Attr&lt;/code&gt; nodes as for any other type of node. Note that<a name="line.210"></a>
<FONT color="green">211</FONT> * normalization can affect equality; to avoid this, nodes should be<a name="line.211"></a>
<FONT color="green">212</FONT> * normalized before being compared.<a name="line.212"></a>
<FONT color="green">213</FONT> * &lt;br&gt;For two &lt;code&gt;DocumentType&lt;/code&gt; nodes to be equal, the following<a name="line.213"></a>
<FONT color="green">214</FONT> * conditions must also be satisfied: The following string attributes<a name="line.214"></a>
<FONT color="green">215</FONT> * are equal: &lt;code&gt;publicId&lt;/code&gt;, &lt;code&gt;systemId&lt;/code&gt;,<a name="line.215"></a>
<FONT color="green">216</FONT> * &lt;code&gt;internalSubset&lt;/code&gt;.The &lt;code&gt;entities&lt;/code&gt;<a name="line.216"></a>
<FONT color="green">217</FONT> * &lt;code&gt;NamedNodeMaps&lt;/code&gt; are equal.The &lt;code&gt;notations&lt;/code&gt;<a name="line.217"></a>
<FONT color="green">218</FONT> * &lt;code&gt;NamedNodeMaps&lt;/code&gt; are equal.<a name="line.218"></a>
<FONT color="green">219</FONT> * &lt;br&gt;On the other hand, the following do not affect equality: the<a name="line.219"></a>
<FONT color="green">220</FONT> * &lt;code&gt;ownerDocument&lt;/code&gt; attribute, the &lt;code&gt;specified&lt;/code&gt;<a name="line.220"></a>
<FONT color="green">221</FONT> * attribute for &lt;code&gt;Attr&lt;/code&gt; nodes, the<a name="line.221"></a>
<FONT color="green">222</FONT> * &lt;code&gt;isWhitespaceInElementContent&lt;/code&gt; attribute for<a name="line.222"></a>
<FONT color="green">223</FONT> * &lt;code&gt;Text&lt;/code&gt; nodes, as well as any user data or event listeners<a name="line.223"></a>
<FONT color="green">224</FONT> * registered on the nodes.<a name="line.224"></a>
<FONT color="green">225</FONT> * @param arg The node to compare equality with.<a name="line.225"></a>
<FONT color="green">226</FONT> * @param deep If &lt;code&gt;true&lt;/code&gt;, recursively compare the subtrees; if<a name="line.226"></a>
<FONT color="green">227</FONT> * &lt;code&gt;false&lt;/code&gt;, compare only the nodes themselves (and its<a name="line.227"></a>
<FONT color="green">228</FONT> * attributes, if it is an &lt;code&gt;Element&lt;/code&gt;).<a name="line.228"></a>
<FONT color="green">229</FONT> * @return If the nodes, and possibly subtrees are equal,<a name="line.229"></a>
<FONT color="green">230</FONT> * &lt;code&gt;true&lt;/code&gt; otherwise &lt;code&gt;false&lt;/code&gt;.<a name="line.230"></a>
<FONT color="green">231</FONT> * @since DOM Level 3<a name="line.231"></a>
<FONT color="green">232</FONT> */<a name="line.232"></a>
<FONT color="green">233</FONT> public boolean isEqualNode(Node arg) {<a name="line.233"></a>
<FONT color="green">234</FONT> if (arg == this) {<a name="line.234"></a>
<FONT color="green">235</FONT> return true;<a name="line.235"></a>
<FONT color="green">236</FONT> }<a name="line.236"></a>
<FONT color="green">237</FONT> if (arg.getNodeType() != getNodeType()) {<a name="line.237"></a>
<FONT color="green">238</FONT> return false;<a name="line.238"></a>
<FONT color="green">239</FONT> }<a name="line.239"></a>
<FONT color="green">240</FONT> // in theory nodeName can't be null but better be careful<a name="line.240"></a>
<FONT color="green">241</FONT> // who knows what other implementations may be doing?...<a name="line.241"></a>
<FONT color="green">242</FONT> if (getNodeName() == null) {<a name="line.242"></a>
<FONT color="green">243</FONT> if (arg.getNodeName() != null) {<a name="line.243"></a>
<FONT color="green">244</FONT> return false;<a name="line.244"></a>
<FONT color="green">245</FONT> }<a name="line.245"></a>
<FONT color="green">246</FONT> }<a name="line.246"></a>
<FONT color="green">247</FONT> else if (!getNodeName().equals(arg.getNodeName())) {<a name="line.247"></a>
<FONT color="green">248</FONT> return false;<a name="line.248"></a>
<FONT color="green">249</FONT> }<a name="line.249"></a>
<FONT color="green">250</FONT> <a name="line.250"></a>
<FONT color="green">251</FONT> if (getLocalName() == null) {<a name="line.251"></a>
<FONT color="green">252</FONT> if (arg.getLocalName() != null) {<a name="line.252"></a>
<FONT color="green">253</FONT> return false;<a name="line.253"></a>
<FONT color="green">254</FONT> }<a name="line.254"></a>
<FONT color="green">255</FONT> }<a name="line.255"></a>
<FONT color="green">256</FONT> else if (!getLocalName().equals(arg.getLocalName())) {<a name="line.256"></a>
<FONT color="green">257</FONT> return false;<a name="line.257"></a>
<FONT color="green">258</FONT> }<a name="line.258"></a>
<FONT color="green">259</FONT> <a name="line.259"></a>
<FONT color="green">260</FONT> if (getNamespaceURI() == null) {<a name="line.260"></a>
<FONT color="green">261</FONT> if (arg.getNamespaceURI() != null) {<a name="line.261"></a>
<FONT color="green">262</FONT> return false;<a name="line.262"></a>
<FONT color="green">263</FONT> }<a name="line.263"></a>
<FONT color="green">264</FONT> }<a name="line.264"></a>
<FONT color="green">265</FONT> else if (!getNamespaceURI().equals(arg.getNamespaceURI())) {<a name="line.265"></a>
<FONT color="green">266</FONT> return false;<a name="line.266"></a>
<FONT color="green">267</FONT> }<a name="line.267"></a>
<FONT color="green">268</FONT> <a name="line.268"></a>
<FONT color="green">269</FONT> if (getPrefix() == null) {<a name="line.269"></a>
<FONT color="green">270</FONT> if (arg.getPrefix() != null) {<a name="line.270"></a>
<FONT color="green">271</FONT> return false;<a name="line.271"></a>
<FONT color="green">272</FONT> }<a name="line.272"></a>
<FONT color="green">273</FONT> }<a name="line.273"></a>
<FONT color="green">274</FONT> else if (!getPrefix().equals(arg.getPrefix())) {<a name="line.274"></a>
<FONT color="green">275</FONT> return false;<a name="line.275"></a>
<FONT color="green">276</FONT> }<a name="line.276"></a>
<FONT color="green">277</FONT> <a name="line.277"></a>
<FONT color="green">278</FONT> if (getNodeValue() == null) {<a name="line.278"></a>
<FONT color="green">279</FONT> if (arg.getNodeValue() != null) {<a name="line.279"></a>
<FONT color="green">280</FONT> return false;<a name="line.280"></a>
<FONT color="green">281</FONT> }<a name="line.281"></a>
<FONT color="green">282</FONT> }<a name="line.282"></a>
<FONT color="green">283</FONT> else if (!getNodeValue().equals(arg.getNodeValue())) {<a name="line.283"></a>
<FONT color="green">284</FONT> return false;<a name="line.284"></a>
<FONT color="green">285</FONT> }<a name="line.285"></a>
<FONT color="green">286</FONT> /*<a name="line.286"></a>
<FONT color="green">287</FONT> if (getBaseURI() == null) {<a name="line.287"></a>
<FONT color="green">288</FONT> if (((NodeImpl) arg).getBaseURI() != null) {<a name="line.288"></a>
<FONT color="green">289</FONT> return false;<a name="line.289"></a>
<FONT color="green">290</FONT> }<a name="line.290"></a>
<FONT color="green">291</FONT> }<a name="line.291"></a>
<FONT color="green">292</FONT> else if (!getBaseURI().equals(((NodeImpl) arg).getBaseURI())) {<a name="line.292"></a>
<FONT color="green">293</FONT> return false;<a name="line.293"></a>
<FONT color="green">294</FONT> }<a name="line.294"></a>
<FONT color="green">295</FONT> */<a name="line.295"></a>
<FONT color="green">296</FONT> <a name="line.296"></a>
<FONT color="green">297</FONT> return true;<a name="line.297"></a>
<FONT color="green">298</FONT> }<a name="line.298"></a>
<FONT color="green">299</FONT> <a name="line.299"></a>
<FONT color="green">300</FONT> /**<a name="line.300"></a>
<FONT color="green">301</FONT> * DOM Level 3 - Experimental:<a name="line.301"></a>
<FONT color="green">302</FONT> * Look up the namespace URI associated to the given prefix, starting from this node.<a name="line.302"></a>
<FONT color="green">303</FONT> * Use lookupNamespaceURI(null) to lookup the default namespace<a name="line.303"></a>
<FONT color="green">304</FONT> *<a name="line.304"></a>
<FONT color="green">305</FONT> * @param namespaceURI<a name="line.305"></a>
<FONT color="green">306</FONT> * @return th URI for the namespace<a name="line.306"></a>
<FONT color="green">307</FONT> * @since DOM Level 3<a name="line.307"></a>
<FONT color="green">308</FONT> */<a name="line.308"></a>
<FONT color="green">309</FONT> public String lookupNamespaceURI(String specifiedPrefix) {<a name="line.309"></a>
<FONT color="green">310</FONT> short type = this.getNodeType();<a name="line.310"></a>
<FONT color="green">311</FONT> switch (type) {<a name="line.311"></a>
<FONT color="green">312</FONT> case Node.ELEMENT_NODE : {<a name="line.312"></a>
<FONT color="green">313</FONT> <a name="line.313"></a>
<FONT color="green">314</FONT> String namespace = this.getNamespaceURI();<a name="line.314"></a>
<FONT color="green">315</FONT> String prefix = this.getPrefix();<a name="line.315"></a>
<FONT color="green">316</FONT> if (namespace !=null) {<a name="line.316"></a>
<FONT color="green">317</FONT> // REVISIT: is it possible that prefix is empty string?<a name="line.317"></a>
<FONT color="green">318</FONT> if (specifiedPrefix== null &amp;&amp; prefix==specifiedPrefix) {<a name="line.318"></a>
<FONT color="green">319</FONT> // looking for default namespace<a name="line.319"></a>
<FONT color="green">320</FONT> return namespace;<a name="line.320"></a>
<FONT color="green">321</FONT> } else if (prefix != null &amp;&amp; prefix.equals(specifiedPrefix)) {<a name="line.321"></a>
<FONT color="green">322</FONT> // non default namespace<a name="line.322"></a>
<FONT color="green">323</FONT> return namespace;<a name="line.323"></a>
<FONT color="green">324</FONT> }<a name="line.324"></a>
<FONT color="green">325</FONT> }<a name="line.325"></a>
<FONT color="green">326</FONT> if (this.hasAttributes()) {<a name="line.326"></a>
<FONT color="green">327</FONT> NamedNodeMap map = this.getAttributes();<a name="line.327"></a>
<FONT color="green">328</FONT> int length = map.getLength();<a name="line.328"></a>
<FONT color="green">329</FONT> for (int i=0;i&lt;length;i++) {<a name="line.329"></a>
<FONT color="green">330</FONT> Node attr = map.item(i);<a name="line.330"></a>
<FONT color="green">331</FONT> String attrPrefix = attr.getPrefix();<a name="line.331"></a>
<FONT color="green">332</FONT> String value = attr.getNodeValue();<a name="line.332"></a>
<FONT color="green">333</FONT> namespace = attr.getNamespaceURI();<a name="line.333"></a>
<FONT color="green">334</FONT> if (namespace !=null &amp;&amp; namespace.equals("http://www.w3.org/2000/xmlns/")) {<a name="line.334"></a>
<FONT color="green">335</FONT> // at this point we are dealing with DOM Level 2 nodes only<a name="line.335"></a>
<FONT color="green">336</FONT> if (specifiedPrefix == null &amp;&amp;<a name="line.336"></a>
<FONT color="green">337</FONT> attr.getNodeName().equals("xmlns")) {<a name="line.337"></a>
<FONT color="green">338</FONT> // default namespace<a name="line.338"></a>
<FONT color="green">339</FONT> return value;<a name="line.339"></a>
<FONT color="green">340</FONT> } else if (attrPrefix !=null &amp;&amp;<a name="line.340"></a>
<FONT color="green">341</FONT> attrPrefix.equals("xmlns") &amp;&amp;<a name="line.341"></a>
<FONT color="green">342</FONT> attr.getLocalName().equals(specifiedPrefix)) {<a name="line.342"></a>
<FONT color="green">343</FONT> // non default namespace<a name="line.343"></a>
<FONT color="green">344</FONT> return value;<a name="line.344"></a>
<FONT color="green">345</FONT> }<a name="line.345"></a>
<FONT color="green">346</FONT> }<a name="line.346"></a>
<FONT color="green">347</FONT> }<a name="line.347"></a>
<FONT color="green">348</FONT> }<a name="line.348"></a>
<FONT color="green">349</FONT> /*<a name="line.349"></a>
<FONT color="green">350</FONT> NodeImpl ancestor = (NodeImpl)getElementAncestor(this);<a name="line.350"></a>
<FONT color="green">351</FONT> if (ancestor != null) {<a name="line.351"></a>
<FONT color="green">352</FONT> return ancestor.lookupNamespaceURI(specifiedPrefix);<a name="line.352"></a>
<FONT color="green">353</FONT> }<a name="line.353"></a>
<FONT color="green">354</FONT> */<a name="line.354"></a>
<FONT color="green">355</FONT> <a name="line.355"></a>
<FONT color="green">356</FONT> return null;<a name="line.356"></a>
<FONT color="green">357</FONT> <a name="line.357"></a>
<FONT color="green">358</FONT> <a name="line.358"></a>
<FONT color="green">359</FONT> }<a name="line.359"></a>
<FONT color="green">360</FONT> /*<a name="line.360"></a>
<FONT color="green">361</FONT> case Node.DOCUMENT_NODE : {<a name="line.361"></a>
<FONT color="green">362</FONT> return((NodeImpl)((Document)this).getDocumentElement()).lookupNamespaceURI(specifiedPrefix) ;<a name="line.362"></a>
<FONT color="green">363</FONT> }<a name="line.363"></a>
<FONT color="green">364</FONT> */<a name="line.364"></a>
<FONT color="green">365</FONT> case Node.ENTITY_NODE :<a name="line.365"></a>
<FONT color="green">366</FONT> case Node.NOTATION_NODE:<a name="line.366"></a>
<FONT color="green">367</FONT> case Node.DOCUMENT_FRAGMENT_NODE:<a name="line.367"></a>
<FONT color="green">368</FONT> case Node.DOCUMENT_TYPE_NODE:<a name="line.368"></a>
<FONT color="green">369</FONT> // type is unknown<a name="line.369"></a>
<FONT color="green">370</FONT> return null;<a name="line.370"></a>
<FONT color="green">371</FONT> case Node.ATTRIBUTE_NODE:{<a name="line.371"></a>
<FONT color="green">372</FONT> if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {<a name="line.372"></a>
<FONT color="green">373</FONT> return getOwnerElement().lookupNamespaceURI(specifiedPrefix);<a name="line.373"></a>
<FONT color="green">374</FONT> <a name="line.374"></a>
<FONT color="green">375</FONT> }<a name="line.375"></a>
<FONT color="green">376</FONT> return null;<a name="line.376"></a>
<FONT color="green">377</FONT> }<a name="line.377"></a>
<FONT color="green">378</FONT> default:{<a name="line.378"></a>
<FONT color="green">379</FONT> /*<a name="line.379"></a>
<FONT color="green">380</FONT> NodeImpl ancestor = (NodeImpl)getElementAncestor(this);<a name="line.380"></a>
<FONT color="green">381</FONT> if (ancestor != null) {<a name="line.381"></a>
<FONT color="green">382</FONT> return ancestor.lookupNamespaceURI(specifiedPrefix);<a name="line.382"></a>
<FONT color="green">383</FONT> }<a name="line.383"></a>
<FONT color="green">384</FONT> */<a name="line.384"></a>
<FONT color="green">385</FONT> return null;<a name="line.385"></a>
<FONT color="green">386</FONT> }<a name="line.386"></a>
<FONT color="green">387</FONT> <a name="line.387"></a>
<FONT color="green">388</FONT> }<a name="line.388"></a>
<FONT color="green">389</FONT> }<a name="line.389"></a>
<FONT color="green">390</FONT> <a name="line.390"></a>
<FONT color="green">391</FONT> /**<a name="line.391"></a>
<FONT color="green">392</FONT> * DOM Level 3: Experimental<a name="line.392"></a>
<FONT color="green">393</FONT> * This method checks if the specified &lt;code&gt;namespaceURI&lt;/code&gt; is the<a name="line.393"></a>
<FONT color="green">394</FONT> * default namespace or not.<a name="line.394"></a>
<FONT color="green">395</FONT> * @param namespaceURI The namespace URI to look for.<a name="line.395"></a>
<FONT color="green">396</FONT> * @return &lt;code&gt;true&lt;/code&gt; if the specified &lt;code&gt;namespaceURI&lt;/code&gt;<a name="line.396"></a>
<FONT color="green">397</FONT> * is the default namespace, &lt;code&gt;false&lt;/code&gt; otherwise.<a name="line.397"></a>
<FONT color="green">398</FONT> * @since DOM Level 3<a name="line.398"></a>
<FONT color="green">399</FONT> */<a name="line.399"></a>
<FONT color="green">400</FONT> public boolean isDefaultNamespace(String namespaceURI){<a name="line.400"></a>
<FONT color="green">401</FONT> /*<a name="line.401"></a>
<FONT color="green">402</FONT> // REVISIT: remove casts when DOM L3 becomes REC.<a name="line.402"></a>
<FONT color="green">403</FONT> short type = this.getNodeType();<a name="line.403"></a>
<FONT color="green">404</FONT> switch (type) {<a name="line.404"></a>
<FONT color="green">405</FONT> case Node.ELEMENT_NODE: {<a name="line.405"></a>
<FONT color="green">406</FONT> String namespace = this.getNamespaceURI();<a name="line.406"></a>
<FONT color="green">407</FONT> String prefix = this.getPrefix();<a name="line.407"></a>
<FONT color="green">408</FONT> <a name="line.408"></a>
<FONT color="green">409</FONT> // REVISIT: is it possible that prefix is empty string?<a name="line.409"></a>
<FONT color="green">410</FONT> if (prefix == null || prefix.length() == 0) {<a name="line.410"></a>
<FONT color="green">411</FONT> if (namespaceURI == null) {<a name="line.411"></a>
<FONT color="green">412</FONT> return (namespace == namespaceURI);<a name="line.412"></a>
<FONT color="green">413</FONT> }<a name="line.413"></a>
<FONT color="green">414</FONT> return namespaceURI.equals(namespace);<a name="line.414"></a>
<FONT color="green">415</FONT> }<a name="line.415"></a>
<FONT color="green">416</FONT> if (this.hasAttributes()) {<a name="line.416"></a>
<FONT color="green">417</FONT> ElementImpl elem = (ElementImpl)this;<a name="line.417"></a>
<FONT color="green">418</FONT> NodeImpl attr = (NodeImpl)elem.getAttributeNodeNS("http://www.w3.org/2000/xmlns/", "xmlns");<a name="line.418"></a>
<FONT color="green">419</FONT> if (attr != null) {<a name="line.419"></a>
<FONT color="green">420</FONT> String value = attr.getNodeValue();<a name="line.420"></a>
<FONT color="green">421</FONT> if (namespaceURI == null) {<a name="line.421"></a>
<FONT color="green">422</FONT> return (namespace == value);<a name="line.422"></a>
<FONT color="green">423</FONT> }<a name="line.423"></a>
<FONT color="green">424</FONT> return namespaceURI.equals(value);<a name="line.424"></a>
<FONT color="green">425</FONT> }<a name="line.425"></a>
<FONT color="green">426</FONT> }<a name="line.426"></a>
<FONT color="green">427</FONT> <a name="line.427"></a>
<FONT color="green">428</FONT> NodeImpl ancestor = (NodeImpl)getElementAncestor(this);<a name="line.428"></a>
<FONT color="green">429</FONT> if (ancestor != null) {<a name="line.429"></a>
<FONT color="green">430</FONT> return ancestor.isDefaultNamespace(namespaceURI);<a name="line.430"></a>
<FONT color="green">431</FONT> }<a name="line.431"></a>
<FONT color="green">432</FONT> return false;<a name="line.432"></a>
<FONT color="green">433</FONT> }<a name="line.433"></a>
<FONT color="green">434</FONT> case Node.DOCUMENT_NODE:{<a name="line.434"></a>
<FONT color="green">435</FONT> return((NodeImpl)((Document)this).getDocumentElement()).isDefaultNamespace(namespaceURI);<a name="line.435"></a>
<FONT color="green">436</FONT> }<a name="line.436"></a>
<FONT color="green">437</FONT> <a name="line.437"></a>
<FONT color="green">438</FONT> case Node.ENTITY_NODE :<a name="line.438"></a>
<FONT color="green">439</FONT> case Node.NOTATION_NODE:<a name="line.439"></a>
<FONT color="green">440</FONT> case Node.DOCUMENT_FRAGMENT_NODE:<a name="line.440"></a>
<FONT color="green">441</FONT> case Node.DOCUMENT_TYPE_NODE:<a name="line.441"></a>
<FONT color="green">442</FONT> // type is unknown<a name="line.442"></a>
<FONT color="green">443</FONT> return false;<a name="line.443"></a>
<FONT color="green">444</FONT> case Node.ATTRIBUTE_NODE:{<a name="line.444"></a>
<FONT color="green">445</FONT> if (this.ownerNode.getNodeType() == Node.ELEMENT_NODE) {<a name="line.445"></a>
<FONT color="green">446</FONT> return ownerNode.isDefaultNamespace(namespaceURI);<a name="line.446"></a>
<FONT color="green">447</FONT> <a name="line.447"></a>
<FONT color="green">448</FONT> }<a name="line.448"></a>
<FONT color="green">449</FONT> return false;<a name="line.449"></a>
<FONT color="green">450</FONT> }<a name="line.450"></a>
<FONT color="green">451</FONT> default:{ <a name="line.451"></a>
<FONT color="green">452</FONT> NodeImpl ancestor = (NodeImpl)getElementAncestor(this);<a name="line.452"></a>
<FONT color="green">453</FONT> if (ancestor != null) {<a name="line.453"></a>
<FONT color="green">454</FONT> return ancestor.isDefaultNamespace(namespaceURI);<a name="line.454"></a>
<FONT color="green">455</FONT> }<a name="line.455"></a>
<FONT color="green">456</FONT> return false;<a name="line.456"></a>
<FONT color="green">457</FONT> }<a name="line.457"></a>
<FONT color="green">458</FONT> <a name="line.458"></a>
<FONT color="green">459</FONT> }<a name="line.459"></a>
<FONT color="green">460</FONT> */<a name="line.460"></a>
<FONT color="green">461</FONT> return false;<a name="line.461"></a>
<FONT color="green">462</FONT> <a name="line.462"></a>
<FONT color="green">463</FONT> <a name="line.463"></a>
<FONT color="green">464</FONT> }<a name="line.464"></a>
<FONT color="green">465</FONT> <a name="line.465"></a>
<FONT color="green">466</FONT> /**<a name="line.466"></a>
<FONT color="green">467</FONT> *<a name="line.467"></a>
<FONT color="green">468</FONT> * DOM Level 3 - Experimental:<a name="line.468"></a>
<FONT color="green">469</FONT> * Look up the prefix associated to the given namespace URI, starting from this node.<a name="line.469"></a>
<FONT color="green">470</FONT> *<a name="line.470"></a>
<FONT color="green">471</FONT> * @param namespaceURI<a name="line.471"></a>
<FONT color="green">472</FONT> * @return the prefix for the namespace<a name="line.472"></a>
<FONT color="green">473</FONT> */<a name="line.473"></a>
<FONT color="green">474</FONT> public String lookupPrefix(String namespaceURI){<a name="line.474"></a>
<FONT color="green">475</FONT> <a name="line.475"></a>
<FONT color="green">476</FONT> // REVISIT: When Namespaces 1.1 comes out this may not be true<a name="line.476"></a>
<FONT color="green">477</FONT> // Prefix can't be bound to null namespace<a name="line.477"></a>
<FONT color="green">478</FONT> if (namespaceURI == null) {<a name="line.478"></a>
<FONT color="green">479</FONT> return null;<a name="line.479"></a>
<FONT color="green">480</FONT> }<a name="line.480"></a>
<FONT color="green">481</FONT> <a name="line.481"></a>
<FONT color="green">482</FONT> short type = this.getNodeType();<a name="line.482"></a>
<FONT color="green">483</FONT> <a name="line.483"></a>
<FONT color="green">484</FONT> switch (type) {<a name="line.484"></a>
<FONT color="green">485</FONT> /*<a name="line.485"></a>
<FONT color="green">486</FONT> case Node.ELEMENT_NODE: {<a name="line.486"></a>
<FONT color="green">487</FONT> <a name="line.487"></a>
<FONT color="green">488</FONT> String namespace = this.getNamespaceURI(); // to flip out children<a name="line.488"></a>
<FONT color="green">489</FONT> return lookupNamespacePrefix(namespaceURI, (ElementImpl)this);<a name="line.489"></a>
<FONT color="green">490</FONT> }<a name="line.490"></a>
<FONT color="green">491</FONT> <a name="line.491"></a>
<FONT color="green">492</FONT> case Node.DOCUMENT_NODE:{<a name="line.492"></a>
<FONT color="green">493</FONT> return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI);<a name="line.493"></a>
<FONT color="green">494</FONT> }<a name="line.494"></a>
<FONT color="green">495</FONT> */<a name="line.495"></a>
<FONT color="green">496</FONT> case Node.ENTITY_NODE :<a name="line.496"></a>
<FONT color="green">497</FONT> case Node.NOTATION_NODE:<a name="line.497"></a>
<FONT color="green">498</FONT> case Node.DOCUMENT_FRAGMENT_NODE:<a name="line.498"></a>
<FONT color="green">499</FONT> case Node.DOCUMENT_TYPE_NODE:<a name="line.499"></a>
<FONT color="green">500</FONT> // type is unknown<a name="line.500"></a>
<FONT color="green">501</FONT> return null;<a name="line.501"></a>
<FONT color="green">502</FONT> case Node.ATTRIBUTE_NODE:{<a name="line.502"></a>
<FONT color="green">503</FONT> if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {<a name="line.503"></a>
<FONT color="green">504</FONT> return getOwnerElement().lookupPrefix(namespaceURI);<a name="line.504"></a>
<FONT color="green">505</FONT> <a name="line.505"></a>
<FONT color="green">506</FONT> }<a name="line.506"></a>
<FONT color="green">507</FONT> return null;<a name="line.507"></a>
<FONT color="green">508</FONT> }<a name="line.508"></a>
<FONT color="green">509</FONT> default:{ <a name="line.509"></a>
<FONT color="green">510</FONT> /*<a name="line.510"></a>
<FONT color="green">511</FONT> NodeImpl ancestor = (NodeImpl)getElementAncestor(this);<a name="line.511"></a>
<FONT color="green">512</FONT> if (ancestor != null) {<a name="line.512"></a>
<FONT color="green">513</FONT> return ancestor.lookupPrefix(namespaceURI);<a name="line.513"></a>
<FONT color="green">514</FONT> }<a name="line.514"></a>
<FONT color="green">515</FONT> */<a name="line.515"></a>
<FONT color="green">516</FONT> return null;<a name="line.516"></a>
<FONT color="green">517</FONT> }<a name="line.517"></a>
<FONT color="green">518</FONT> }<a name="line.518"></a>
<FONT color="green">519</FONT> }<a name="line.519"></a>
<FONT color="green">520</FONT> <a name="line.520"></a>
<FONT color="green">521</FONT> /**<a name="line.521"></a>
<FONT color="green">522</FONT> * Returns whether this node is the same node as the given one.<a name="line.522"></a>
<FONT color="green">523</FONT> * &lt;br&gt;This method provides a way to determine whether two<a name="line.523"></a>
<FONT color="green">524</FONT> * &lt;code&gt;Node&lt;/code&gt; references returned by the implementation reference<a name="line.524"></a>
<FONT color="green">525</FONT> * the same object. When two &lt;code&gt;Node&lt;/code&gt; references are references<a name="line.525"></a>
<FONT color="green">526</FONT> * to the same object, even if through a proxy, the references may be<a name="line.526"></a>
<FONT color="green">527</FONT> * used completely interchangably, such that all attributes have the<a name="line.527"></a>
<FONT color="green">528</FONT> * same values and calling the same DOM method on either reference<a name="line.528"></a>
<FONT color="green">529</FONT> * always has exactly the same effect.<a name="line.529"></a>
<FONT color="green">530</FONT> * @param other The node to test against.<a name="line.530"></a>
<FONT color="green">531</FONT> * @return Returns &lt;code&gt;true&lt;/code&gt; if the nodes are the same,<a name="line.531"></a>
<FONT color="green">532</FONT> * &lt;code&gt;false&lt;/code&gt; otherwise.<a name="line.532"></a>
<FONT color="green">533</FONT> * @since DOM Level 3<a name="line.533"></a>
<FONT color="green">534</FONT> */<a name="line.534"></a>
<FONT color="green">535</FONT> public boolean isSameNode(Node other) {<a name="line.535"></a>
<FONT color="green">536</FONT> // we do not use any wrapper so the answer is obvious<a name="line.536"></a>
<FONT color="green">537</FONT> return this == other;<a name="line.537"></a>
<FONT color="green">538</FONT> }<a name="line.538"></a>
<FONT color="green">539</FONT> <a name="line.539"></a>
<FONT color="green">540</FONT> /**<a name="line.540"></a>
<FONT color="green">541</FONT> * This attribute returns the text content of this node and its<a name="line.541"></a>
<FONT color="green">542</FONT> * descendants. When it is defined to be null, setting it has no effect.<a name="line.542"></a>
<FONT color="green">543</FONT> * When set, any possible children this node may have are removed and<a name="line.543"></a>
<FONT color="green">544</FONT> * replaced by a single &lt;code&gt;Text&lt;/code&gt; node containing the string<a name="line.544"></a>
<FONT color="green">545</FONT> * this attribute is set to. On getting, no serialization is performed,<a name="line.545"></a>
<FONT color="green">546</FONT> * the returned string does not contain any markup. No whitespace<a name="line.546"></a>
<FONT color="green">547</FONT> * normalization is performed, the returned string does not contain the<a name="line.547"></a>
<FONT color="green">548</FONT> * element content whitespaces . Similarly, on setting, no parsing is<a name="line.548"></a>
<FONT color="green">549</FONT> * performed either, the input string is taken as pure textual content.<a name="line.549"></a>
<FONT color="green">550</FONT> * &lt;br&gt;The string returned is made of the text content of this node<a name="line.550"></a>
<FONT color="green">551</FONT> * depending on its type, as defined below:<a name="line.551"></a>
<FONT color="green">552</FONT> * &lt;table border='1'&gt;<a name="line.552"></a>
<FONT color="green">553</FONT> * &lt;tr&gt;<a name="line.553"></a>
<FONT color="green">554</FONT> * &lt;th&gt;Node type&lt;/th&gt;<a name="line.554"></a>
<FONT color="green">555</FONT> * &lt;th&gt;Content&lt;/th&gt;<a name="line.555"></a>
<FONT color="green">556</FONT> * &lt;/tr&gt;<a name="line.556"></a>
<FONT color="green">557</FONT> * &lt;tr&gt;<a name="line.557"></a>
<FONT color="green">558</FONT> * &lt;td valign='top' rowspan='1' colspan='1'&gt;<a name="line.558"></a>
<FONT color="green">559</FONT> * ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,<a name="line.559"></a>
<FONT color="green">560</FONT> * DOCUMENT_FRAGMENT_NODE&lt;/td&gt;<a name="line.560"></a>
<FONT color="green">561</FONT> * &lt;td valign='top' rowspan='1' colspan='1'&gt;concatenation of the &lt;code&gt;textContent&lt;/code&gt;<a name="line.561"></a>
<FONT color="green">562</FONT> * attribute value of every child node, excluding COMMENT_NODE and<a name="line.562"></a>
<FONT color="green">563</FONT> * PROCESSING_INSTRUCTION_NODE nodes&lt;/td&gt;<a name="line.563"></a>
<FONT color="green">564</FONT> * &lt;/tr&gt;<a name="line.564"></a>
<FONT color="green">565</FONT> * &lt;tr&gt;<a name="line.565"></a>
<FONT color="green">566</FONT> * &lt;td valign='top' rowspan='1' colspan='1'&gt;ATTRIBUTE_NODE, TEXT_NODE,<a name="line.566"></a>
<FONT color="green">567</FONT> * CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE&lt;/td&gt;<a name="line.567"></a>
<FONT color="green">568</FONT> * &lt;td valign='top' rowspan='1' colspan='1'&gt;<a name="line.568"></a>
<FONT color="green">569</FONT> * &lt;code&gt;nodeValue&lt;/code&gt;&lt;/td&gt;<a name="line.569"></a>
<FONT color="green">570</FONT> * &lt;/tr&gt;<a name="line.570"></a>
<FONT color="green">571</FONT> * &lt;tr&gt;<a name="line.571"></a>
<FONT color="green">572</FONT> * &lt;td valign='top' rowspan='1' colspan='1'&gt;DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE&lt;/td&gt;<a name="line.572"></a>
<FONT color="green">573</FONT> * &lt;td valign='top' rowspan='1' colspan='1'&gt;<a name="line.573"></a>
<FONT color="green">574</FONT> * null&lt;/td&gt;<a name="line.574"></a>
<FONT color="green">575</FONT> * &lt;/tr&gt;<a name="line.575"></a>
<FONT color="green">576</FONT> * &lt;/table&gt;<a name="line.576"></a>
<FONT color="green">577</FONT> * @exception DOMException<a name="line.577"></a>
<FONT color="green">578</FONT> * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.<a name="line.578"></a>
<FONT color="green">579</FONT> * @exception DOMException<a name="line.579"></a>
<FONT color="green">580</FONT> * DOMSTRING_SIZE_ERR: Raised when it would return more characters than<a name="line.580"></a>
<FONT color="green">581</FONT> * fit in a &lt;code&gt;DOMString&lt;/code&gt; variable on the implementation<a name="line.581"></a>
<FONT color="green">582</FONT> * platform.<a name="line.582"></a>
<FONT color="green">583</FONT> * @since DOM Level 3<a name="line.583"></a>
<FONT color="green">584</FONT> */<a name="line.584"></a>
<FONT color="green">585</FONT> public void setTextContent(String textContent)<a name="line.585"></a>
<FONT color="green">586</FONT> throws DOMException {<a name="line.586"></a>
<FONT color="green">587</FONT> setNodeValue(textContent);<a name="line.587"></a>
<FONT color="green">588</FONT> }<a name="line.588"></a>
<FONT color="green">589</FONT> <a name="line.589"></a>
<FONT color="green">590</FONT> /**<a name="line.590"></a>
<FONT color="green">591</FONT> * This attribute returns the text content of this node and its<a name="line.591"></a>
<FONT color="green">592</FONT> * descendants. When it is defined to be null, setting it has no effect.<a name="line.592"></a>
<FONT color="green">593</FONT> * When set, any possible children this node may have are removed and<a name="line.593"></a>
<FONT color="green">594</FONT> * replaced by a single &lt;code&gt;Text&lt;/code&gt; node containing the string<a name="line.594"></a>
<FONT color="green">595</FONT> * this attribute is set to. On getting, no serialization is performed,<a name="line.595"></a>
<FONT color="green">596</FONT> * the returned string does not contain any markup. No whitespace<a name="line.596"></a>
<FONT color="green">597</FONT> * normalization is performed, the returned string does not contain the<a name="line.597"></a>
<FONT color="green">598</FONT> * element content whitespaces . Similarly, on setting, no parsing is<a name="line.598"></a>
<FONT color="green">599</FONT> * performed either, the input string is taken as pure textual content.<a name="line.599"></a>
<FONT color="green">600</FONT> * &lt;br&gt;The string returned is made of the text content of this node<a name="line.600"></a>
<FONT color="green">601</FONT> * depending on its type, as defined below:<a name="line.601"></a>
<FONT color="green">602</FONT> * &lt;table border='1'&gt;<a name="line.602"></a>
<FONT color="green">603</FONT> * &lt;tr&gt;<a name="line.603"></a>
<FONT color="green">604</FONT> * &lt;th&gt;Node type&lt;/th&gt;<a name="line.604"></a>
<FONT color="green">605</FONT> * &lt;th&gt;Content&lt;/th&gt;<a name="line.605"></a>
<FONT color="green">606</FONT> * &lt;/tr&gt;<a name="line.606"></a>
<FONT color="green">607</FONT> * &lt;tr&gt;<a name="line.607"></a>
<FONT color="green">608</FONT> * &lt;td valign='top' rowspan='1' colspan='1'&gt;<a name="line.608"></a>
<FONT color="green">609</FONT> * ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,<a name="line.609"></a>
<FONT color="green">610</FONT> * DOCUMENT_FRAGMENT_NODE&lt;/td&gt;<a name="line.610"></a>
<FONT color="green">611</FONT> * &lt;td valign='top' rowspan='1' colspan='1'&gt;concatenation of the &lt;code&gt;textContent&lt;/code&gt;<a name="line.611"></a>
<FONT color="green">612</FONT> * attribute value of every child node, excluding COMMENT_NODE and<a name="line.612"></a>
<FONT color="green">613</FONT> * PROCESSING_INSTRUCTION_NODE nodes&lt;/td&gt;<a name="line.613"></a>
<FONT color="green">614</FONT> * &lt;/tr&gt;<a name="line.614"></a>
<FONT color="green">615</FONT> * &lt;tr&gt;<a name="line.615"></a>
<FONT color="green">616</FONT> * &lt;td valign='top' rowspan='1' colspan='1'&gt;ATTRIBUTE_NODE, TEXT_NODE,<a name="line.616"></a>
<FONT color="green">617</FONT> * CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE&lt;/td&gt;<a name="line.617"></a>
<FONT color="green">618</FONT> * &lt;td valign='top' rowspan='1' colspan='1'&gt;<a name="line.618"></a>
<FONT color="green">619</FONT> * &lt;code&gt;nodeValue&lt;/code&gt;&lt;/td&gt;<a name="line.619"></a>
<FONT color="green">620</FONT> * &lt;/tr&gt;<a name="line.620"></a>
<FONT color="green">621</FONT> * &lt;tr&gt;<a name="line.621"></a>
<FONT color="green">622</FONT> * &lt;td valign='top' rowspan='1' colspan='1'&gt;DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE&lt;/td&gt;<a name="line.622"></a>
<FONT color="green">623</FONT> * &lt;td valign='top' rowspan='1' colspan='1'&gt;<a name="line.623"></a>
<FONT color="green">624</FONT> * null&lt;/td&gt;<a name="line.624"></a>
<FONT color="green">625</FONT> * &lt;/tr&gt;<a name="line.625"></a>
<FONT color="green">626</FONT> * &lt;/table&gt;<a name="line.626"></a>
<FONT color="green">627</FONT> * @exception DOMException<a name="line.627"></a>
<FONT color="green">628</FONT> * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.<a name="line.628"></a>
<FONT color="green">629</FONT> * @exception DOMException<a name="line.629"></a>
<FONT color="green">630</FONT> * DOMSTRING_SIZE_ERR: Raised when it would return more characters than<a name="line.630"></a>
<FONT color="green">631</FONT> * fit in a &lt;code&gt;DOMString&lt;/code&gt; variable on the implementation<a name="line.631"></a>
<FONT color="green">632</FONT> * platform.<a name="line.632"></a>
<FONT color="green">633</FONT> * @since DOM Level 3<a name="line.633"></a>
<FONT color="green">634</FONT> */<a name="line.634"></a>
<FONT color="green">635</FONT> public String getTextContent() throws DOMException {<a name="line.635"></a>
<FONT color="green">636</FONT> return getNodeValue(); // overriden in some subclasses<a name="line.636"></a>
<FONT color="green">637</FONT> }<a name="line.637"></a>
<FONT color="green">638</FONT> <a name="line.638"></a>
<FONT color="green">639</FONT> /**<a name="line.639"></a>
<FONT color="green">640</FONT> * Compares a node with this node with regard to their position in the<a name="line.640"></a>
<FONT color="green">641</FONT> * document.<a name="line.641"></a>
<FONT color="green">642</FONT> * @param other The node to compare against this node.<a name="line.642"></a>
<FONT color="green">643</FONT> * @return Returns how the given node is positioned relatively to this<a name="line.643"></a>
<FONT color="green">644</FONT> * node.<a name="line.644"></a>
<FONT color="green">645</FONT> * @since DOM Level 3<a name="line.645"></a>
<FONT color="green">646</FONT> */<a name="line.646"></a>
<FONT color="green">647</FONT> public short compareDocumentPosition(Node other) throws DOMException {<a name="line.647"></a>
<FONT color="green">648</FONT> return 0;<a name="line.648"></a>
<FONT color="green">649</FONT> }<a name="line.649"></a>
<FONT color="green">650</FONT> <a name="line.650"></a>
<FONT color="green">651</FONT> /**<a name="line.651"></a>
<FONT color="green">652</FONT> * The absolute base URI of this node or &lt;code&gt;null&lt;/code&gt; if undefined.<a name="line.652"></a>
<FONT color="green">653</FONT> * This value is computed according to . However, when the<a name="line.653"></a>
<FONT color="green">654</FONT> * &lt;code&gt;Document&lt;/code&gt; supports the feature "HTML" , the base URI is<a name="line.654"></a>
<FONT color="green">655</FONT> * computed using first the value of the href attribute of the HTML BASE<a name="line.655"></a>
<FONT color="green">656</FONT> * element if any, and the value of the &lt;code&gt;documentURI&lt;/code&gt;<a name="line.656"></a>
<FONT color="green">657</FONT> * attribute from the &lt;code&gt;Document&lt;/code&gt; interface otherwise.<a name="line.657"></a>
<FONT color="green">658</FONT> * &lt;br&gt; When the node is an &lt;code&gt;Element&lt;/code&gt;, a &lt;code&gt;Document&lt;/code&gt;<a name="line.658"></a>
<FONT color="green">659</FONT> * or a a &lt;code&gt;ProcessingInstruction&lt;/code&gt;, this attribute represents<a name="line.659"></a>
<FONT color="green">660</FONT> * the properties [base URI] defined in . When the node is a<a name="line.660"></a>
<FONT color="green">661</FONT> * &lt;code&gt;Notation&lt;/code&gt;, an &lt;code&gt;Entity&lt;/code&gt;, or an<a name="line.661"></a>
<FONT color="green">662</FONT> * &lt;code&gt;EntityReference&lt;/code&gt;, this attribute represents the<a name="line.662"></a>
<FONT color="green">663</FONT> * properties [declaration base URI] in the . How will this be affected<a name="line.663"></a>
<FONT color="green">664</FONT> * by resolution of relative namespace URIs issue?It's not.Should this<a name="line.664"></a>
<FONT color="green">665</FONT> * only be on Document, Element, ProcessingInstruction, Entity, and<a name="line.665"></a>
<FONT color="green">666</FONT> * Notation nodes, according to the infoset? If not, what is it equal to<a name="line.666"></a>
<FONT color="green">667</FONT> * on other nodes? Null? An empty string? I think it should be the<a name="line.667"></a>
<FONT color="green">668</FONT> * parent's.No.Should this be read-only and computed or and actual<a name="line.668"></a>
<FONT color="green">669</FONT> * read-write attribute?Read-only and computed (F2F 19 Jun 2000 and<a name="line.669"></a>
<FONT color="green">670</FONT> * teleconference 30 May 2001).If the base HTML element is not yet<a name="line.670"></a>
<FONT color="green">671</FONT> * attached to a document, does the insert change the Document.baseURI?<a name="line.671"></a>
<FONT color="green">672</FONT> * Yes. (F2F 26 Sep 2001)<a name="line.672"></a>
<FONT color="green">673</FONT> * @since DOM Level 3<a name="line.673"></a>
<FONT color="green">674</FONT> */<a name="line.674"></a>
<FONT color="green">675</FONT> public String getBaseURI() {<a name="line.675"></a>
<FONT color="green">676</FONT> return null;<a name="line.676"></a>
<FONT color="green">677</FONT> }<a name="line.677"></a>
<FONT color="green">678</FONT> }<a name="line.678"></a>
<FONT color="green">679</FONT> <a name="line.679"></a>
</PRE>
</BODY>
</HTML>