1. /*
  2. * Copyright 1999-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: UnImplNode.java,v
  18. */
  19. package com.sun.org.apache.xml.internal.utils;
  20. import com.sun.org.apache.xml.internal.res.XMLErrorResources;
  21. import com.sun.org.apache.xml.internal.res.XMLMessages;
  22. import org.w3c.dom.Attr;
  23. import org.w3c.dom.CDATASection;
  24. import org.w3c.dom.Comment;
  25. import org.w3c.dom.DOMException;
  26. import org.w3c.dom.DOMImplementation;
  27. import org.w3c.dom.Document;
  28. import org.w3c.dom.DocumentFragment;
  29. import org.w3c.dom.DocumentType;
  30. import org.w3c.dom.Element;
  31. import org.w3c.dom.EntityReference;
  32. import org.w3c.dom.NamedNodeMap;
  33. import org.w3c.dom.Node;
  34. import org.w3c.dom.NodeList;
  35. import org.w3c.dom.ProcessingInstruction;
  36. import org.w3c.dom.Text;
  37. import org.w3c.dom.UserDataHandler;
  38. import org.w3c.dom.DOMConfiguration;
  39. import org.w3c.dom.TypeInfo;
  40. /**
  41. * <meta name="usage" content="internal"/>
  42. * To be subclassed by classes that wish to fake being nodes.
  43. */
  44. public class UnImplNode implements Node, Element, NodeList, Document
  45. {
  46. /**
  47. * Constructor UnImplNode
  48. *
  49. */
  50. public UnImplNode(){}
  51. /**
  52. * Throw an error.
  53. *
  54. * @param msg Message Key for the error
  55. */
  56. public void error(String msg)
  57. {
  58. System.out.println("DOM ERROR! class: " + this.getClass().getName());
  59. throw new RuntimeException(XMLMessages.createXMLMessage(msg, null));
  60. }
  61. /**
  62. * Throw an error.
  63. *
  64. * @param msg Message Key for the error
  65. * @param args Array of arguments to be used in the error message
  66. */
  67. public void error(String msg, Object[] args)
  68. {
  69. System.out.println("DOM ERROR! class: " + this.getClass().getName());
  70. throw new RuntimeException(XMLMessages.createXMLMessage(msg, args)); //"UnImplNode error: "+msg);
  71. }
  72. /**
  73. * Unimplemented. See org.w3c.dom.Node
  74. *
  75. * @param newChild New node to append to the list of this node's children
  76. *
  77. * @return null
  78. *
  79. * @throws DOMException
  80. */
  81. public Node appendChild(Node newChild) throws DOMException
  82. {
  83. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"appendChild not supported!");
  84. return null;
  85. }
  86. /**
  87. * Unimplemented. See org.w3c.dom.Node
  88. *
  89. * @return false
  90. */
  91. public boolean hasChildNodes()
  92. {
  93. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"hasChildNodes not supported!");
  94. return false;
  95. }
  96. /**
  97. * Unimplemented. See org.w3c.dom.Node
  98. *
  99. * @return 0
  100. */
  101. public short getNodeType()
  102. {
  103. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getNodeType not supported!");
  104. return 0;
  105. }
  106. /**
  107. * Unimplemented. See org.w3c.dom.Node
  108. *
  109. * @return null
  110. */
  111. public Node getParentNode()
  112. {
  113. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getParentNode not supported!");
  114. return null;
  115. }
  116. /**
  117. * Unimplemented. See org.w3c.dom.Node
  118. *
  119. * @return null
  120. */
  121. public NodeList getChildNodes()
  122. {
  123. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getChildNodes not supported!");
  124. return null;
  125. }
  126. /**
  127. * Unimplemented. See org.w3c.dom.Node
  128. *
  129. * @return null
  130. */
  131. public Node getFirstChild()
  132. {
  133. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getFirstChild not supported!");
  134. return null;
  135. }
  136. /**
  137. * Unimplemented. See org.w3c.dom.Node
  138. *
  139. * @return null
  140. */
  141. public Node getLastChild()
  142. {
  143. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getLastChild not supported!");
  144. return null;
  145. }
  146. /**
  147. * Unimplemented. See org.w3c.dom.Node
  148. *
  149. * @return null
  150. */
  151. public Node getNextSibling()
  152. {
  153. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getNextSibling not supported!");
  154. return null;
  155. }
  156. /**
  157. * Unimplemented. See org.w3c.dom.NodeList
  158. *
  159. * @return 0
  160. */
  161. public int getLength()
  162. {
  163. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getLength not supported!");
  164. return 0;
  165. } // getLength():int
  166. /**
  167. * Unimplemented. See org.w3c.dom.NodeList
  168. *
  169. * @param index index of a child of this node in its list of children
  170. *
  171. * @return null
  172. */
  173. public Node item(int index)
  174. {
  175. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"item not supported!");
  176. return null;
  177. } // item(int):Node
  178. /**
  179. * Unimplemented. See org.w3c.dom.Node
  180. *
  181. * @return null
  182. */
  183. public Document getOwnerDocument()
  184. {
  185. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getOwnerDocument not supported!");
  186. return null;
  187. }
  188. /**
  189. * Unimplemented. See org.w3c.dom.Node
  190. *
  191. * @return null
  192. */
  193. public String getTagName()
  194. {
  195. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getTagName not supported!");
  196. return null;
  197. }
  198. /**
  199. * Unimplemented. See org.w3c.dom.Node
  200. *
  201. * @return null
  202. */
  203. public String getNodeName()
  204. {
  205. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getNodeName not supported!");
  206. return null;
  207. }
  208. /** Unimplemented. See org.w3c.dom.Node */
  209. public void normalize()
  210. {
  211. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"normalize not supported!");
  212. }
  213. /**
  214. * Unimplemented. See org.w3c.dom.Element
  215. *
  216. * @param name Name of the element
  217. *
  218. * @return null
  219. */
  220. public NodeList getElementsByTagName(String name)
  221. {
  222. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getElementsByTagName not supported!");
  223. return null;
  224. }
  225. /**
  226. * Unimplemented. See org.w3c.dom.Element
  227. *
  228. * @param oldAttr Attribute to be removed from this node's list of attributes
  229. *
  230. * @return null
  231. *
  232. * @throws DOMException
  233. */
  234. public Attr removeAttributeNode(Attr oldAttr) throws DOMException
  235. {
  236. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"removeAttributeNode not supported!");
  237. return null;
  238. }
  239. /**
  240. * Unimplemented. See org.w3c.dom.Element
  241. *
  242. * @param newAttr Attribute node to be added to this node's list of attributes
  243. *
  244. * @return null
  245. *
  246. * @throws DOMException
  247. */
  248. public Attr setAttributeNode(Attr newAttr) throws DOMException
  249. {
  250. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setAttributeNode not supported!");
  251. return null;
  252. }
  253. /**
  254. * Unimplemented. See org.w3c.dom.Element
  255. *
  256. *
  257. * @param name Name of an attribute
  258. *
  259. * @return false
  260. */
  261. public boolean hasAttribute(String name)
  262. {
  263. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"hasAttribute not supported!");
  264. return false;
  265. }
  266. /**
  267. * Unimplemented. See org.w3c.dom.Element
  268. *
  269. *
  270. * @param name
  271. * @param x
  272. *
  273. * @return false
  274. */
  275. public boolean hasAttributeNS(String name, String x)
  276. {
  277. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"hasAttributeNS not supported!");
  278. return false;
  279. }
  280. /**
  281. * Unimplemented. See org.w3c.dom.Element
  282. *
  283. *
  284. * @param name Attribute node name
  285. *
  286. * @return null
  287. */
  288. public Attr getAttributeNode(String name)
  289. {
  290. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getAttributeNode not supported!");
  291. return null;
  292. }
  293. /**
  294. * Unimplemented. See org.w3c.dom.Element
  295. *
  296. * @param name Attribute node name to remove from list of attributes
  297. *
  298. * @throws DOMException
  299. */
  300. public void removeAttribute(String name) throws DOMException
  301. {
  302. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"removeAttribute not supported!");
  303. }
  304. /**
  305. * Unimplemented. See org.w3c.dom.Element
  306. *
  307. * @param name Name of attribute to set
  308. * @param value Value of attribute
  309. *
  310. * @throws DOMException
  311. */
  312. public void setAttribute(String name, String value) throws DOMException
  313. {
  314. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setAttribute not supported!");
  315. }
  316. /**
  317. * Unimplemented. See org.w3c.dom.Element
  318. *
  319. * @param name Name of attribute to get
  320. *
  321. * @return null
  322. */
  323. public String getAttribute(String name)
  324. {
  325. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getAttribute not supported!");
  326. return null;
  327. }
  328. /**
  329. * Unimplemented. Introduced in DOM Level 2.
  330. *
  331. * @return false
  332. */
  333. public boolean hasAttributes()
  334. {
  335. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"hasAttributes not supported!");
  336. return false;
  337. }
  338. /**
  339. * Unimplemented. See org.w3c.dom.Element
  340. *
  341. * @param namespaceURI Namespace URI of the element
  342. * @param localName Local part of qualified name of the element
  343. *
  344. * @return null
  345. */
  346. public NodeList getElementsByTagNameNS(String namespaceURI,
  347. String localName)
  348. {
  349. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getElementsByTagNameNS not supported!");
  350. return null;
  351. }
  352. /**
  353. * Unimplemented. See org.w3c.dom.Element
  354. *
  355. * @param newAttr Attribute to set
  356. *
  357. * @return null
  358. *
  359. * @throws DOMException
  360. */
  361. public Attr setAttributeNodeNS(Attr newAttr) throws DOMException
  362. {
  363. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setAttributeNodeNS not supported!");
  364. return null;
  365. }
  366. /**
  367. * Unimplemented. See org.w3c.dom.Element
  368. *
  369. * @param namespaceURI Namespace URI of attribute node to get
  370. * @param localName Local part of qualified name of attribute node to get
  371. *
  372. * @return null
  373. */
  374. public Attr getAttributeNodeNS(String namespaceURI, String localName)
  375. {
  376. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getAttributeNodeNS not supported!");
  377. return null;
  378. }
  379. /**
  380. * Unimplemented. See org.w3c.dom.Element
  381. *
  382. * @param namespaceURI Namespace URI of attribute node to remove
  383. * @param localName Local part of qualified name of attribute node to remove
  384. *
  385. * @throws DOMException
  386. */
  387. public void removeAttributeNS(String namespaceURI, String localName)
  388. throws DOMException
  389. {
  390. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"removeAttributeNS not supported!");
  391. }
  392. /**
  393. * Unimplemented. See org.w3c.dom.Element
  394. *
  395. * @param namespaceURI Namespace URI of attribute node to set
  396. * @param localName Local part of qualified name of attribute node to set
  397. * NEEDSDOC @param qualifiedName
  398. * @param value value of attribute
  399. *
  400. * @throws DOMException
  401. */
  402. public void setAttributeNS(
  403. String namespaceURI, String qualifiedName, String value)
  404. throws DOMException
  405. {
  406. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setAttributeNS not supported!");
  407. }
  408. /**
  409. * Unimplemented. See org.w3c.dom.Element
  410. *
  411. * @param namespaceURI Namespace URI of attribute node to get
  412. * @param localName Local part of qualified name of attribute node to get
  413. *
  414. * @return null
  415. */
  416. public String getAttributeNS(String namespaceURI, String localName)
  417. {
  418. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getAttributeNS not supported!");
  419. return null;
  420. }
  421. /**
  422. * Unimplemented. See org.w3c.dom.Node
  423. *
  424. * @return null
  425. */
  426. public Node getPreviousSibling()
  427. {
  428. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getPreviousSibling not supported!");
  429. return null;
  430. }
  431. /**
  432. * Unimplemented. See org.w3c.dom.Node
  433. *
  434. * @param deep Flag indicating whether to clone deep (clone member variables)
  435. *
  436. * @return null
  437. */
  438. public Node cloneNode(boolean deep)
  439. {
  440. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"cloneNode not supported!");
  441. return null;
  442. }
  443. /**
  444. * Unimplemented. See org.w3c.dom.Node
  445. *
  446. * @return null
  447. *
  448. * @throws DOMException
  449. */
  450. public String getNodeValue() throws DOMException
  451. {
  452. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getNodeValue not supported!");
  453. return null;
  454. }
  455. /**
  456. * Unimplemented. See org.w3c.dom.Node
  457. *
  458. * @param nodeValue Value to set this node to
  459. *
  460. * @throws DOMException
  461. */
  462. public void setNodeValue(String nodeValue) throws DOMException
  463. {
  464. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setNodeValue not supported!");
  465. }
  466. /**
  467. * Unimplemented. See org.w3c.dom.Node
  468. *
  469. *
  470. * NEEDSDOC @param value
  471. * @return value Node value
  472. *
  473. * @throws DOMException
  474. */
  475. // public String getValue ()
  476. // {
  477. // error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getValue not supported!");
  478. // return null;
  479. // }
  480. /**
  481. * Unimplemented. See org.w3c.dom.Node
  482. *
  483. * @param value Value to set this node to
  484. *
  485. * @throws DOMException
  486. */
  487. public void setValue(String value) throws DOMException
  488. {
  489. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setValue not supported!");
  490. }
  491. /**
  492. * Returns the name of this attribute.
  493. *
  494. * @return the name of this attribute.
  495. */
  496. // public String getName()
  497. // {
  498. // return this.getNodeName();
  499. // }
  500. /**
  501. * Unimplemented. See org.w3c.dom.Node
  502. *
  503. * @return null
  504. */
  505. public Element getOwnerElement()
  506. {
  507. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getOwnerElement not supported!");
  508. return null;
  509. }
  510. /**
  511. * Unimplemented. See org.w3c.dom.Node
  512. *
  513. * @return False
  514. */
  515. public boolean getSpecified()
  516. {
  517. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setValue not supported!");
  518. return false;
  519. }
  520. /**
  521. * Unimplemented. See org.w3c.dom.Node
  522. *
  523. * @return null
  524. */
  525. public NamedNodeMap getAttributes()
  526. {
  527. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getAttributes not supported!");
  528. return null;
  529. }
  530. /**
  531. * Unimplemented. See org.w3c.dom.Node
  532. *
  533. * @param newChild New child node to insert
  534. * @param refChild Insert in front of this child
  535. *
  536. * @return null
  537. *
  538. * @throws DOMException
  539. */
  540. public Node insertBefore(Node newChild, Node refChild) throws DOMException
  541. {
  542. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"insertBefore not supported!");
  543. return null;
  544. }
  545. /**
  546. * Unimplemented. See org.w3c.dom.Node
  547. *
  548. * @param newChild Replace existing child with this one
  549. * @param oldChild Existing child to be replaced
  550. *
  551. * @return null
  552. *
  553. * @throws DOMException
  554. */
  555. public Node replaceChild(Node newChild, Node oldChild) throws DOMException
  556. {
  557. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"replaceChild not supported!");
  558. return null;
  559. }
  560. /**
  561. * Unimplemented. See org.w3c.dom.Node
  562. *
  563. * @param oldChild Child to be removed
  564. *
  565. * @return null
  566. *
  567. * @throws DOMException
  568. */
  569. public Node removeChild(Node oldChild) throws DOMException
  570. {
  571. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"replaceChild not supported!");
  572. return null;
  573. }
  574. /**
  575. * Tests whether the DOM implementation implements a specific feature and
  576. * that feature is supported by this node.
  577. * @param featureThe name of the feature to test. This is the same name
  578. * which can be passed to the method <code>hasFeature</code> on
  579. * <code>DOMImplementation</code>.
  580. * @param versionThis is the version number of the feature to test. In
  581. * Level 2, version 1, this is the string "2.0". If the version is not
  582. * specified, supporting any version of the feature will cause the
  583. * method to return <code>true</code>.
  584. *
  585. * NEEDSDOC @param feature
  586. * NEEDSDOC @param version
  587. * @return Returns <code>false</code>
  588. * @since DOM Level 2
  589. */
  590. public boolean isSupported(String feature, String version)
  591. {
  592. return false;
  593. }
  594. /**
  595. * Unimplemented. See org.w3c.dom.Node
  596. *
  597. * @return null
  598. */
  599. public String getNamespaceURI()
  600. {
  601. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getNamespaceURI not supported!");
  602. return null;
  603. }
  604. /**
  605. * Unimplemented. See org.w3c.dom.Node
  606. *
  607. * @return null
  608. */
  609. public String getPrefix()
  610. {
  611. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getPrefix not supported!");
  612. return null;
  613. }
  614. /**
  615. * Unimplemented. See org.w3c.dom.Node
  616. *
  617. * @param prefix Prefix to set for this node
  618. *
  619. * @throws DOMException
  620. */
  621. public void setPrefix(String prefix) throws DOMException
  622. {
  623. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setPrefix not supported!");
  624. }
  625. /**
  626. * Unimplemented. See org.w3c.dom.Node
  627. *
  628. * @return null
  629. */
  630. public String getLocalName()
  631. {
  632. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getLocalName not supported!");
  633. return null;
  634. }
  635. /**
  636. * Unimplemented. See org.w3c.dom.Document
  637. *
  638. * @return null
  639. */
  640. public DocumentType getDoctype()
  641. {
  642. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  643. return null;
  644. }
  645. /**
  646. * Unimplemented. See org.w3c.dom.Document
  647. *
  648. * @return null
  649. */
  650. public DOMImplementation getImplementation()
  651. {
  652. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  653. return null;
  654. }
  655. /**
  656. * Unimplemented. See org.w3c.dom.Document
  657. *
  658. * @return null
  659. */
  660. public Element getDocumentElement()
  661. {
  662. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  663. return null;
  664. }
  665. /**
  666. * Unimplemented. See org.w3c.dom.Document
  667. *
  668. * @param tagName Element tag name
  669. *
  670. * @return null
  671. *
  672. * @throws DOMException
  673. */
  674. public Element createElement(String tagName) throws DOMException
  675. {
  676. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  677. return null;
  678. }
  679. /**
  680. * Unimplemented. See org.w3c.dom.Document
  681. *
  682. * @return null
  683. */
  684. public DocumentFragment createDocumentFragment()
  685. {
  686. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  687. return null;
  688. }
  689. /**
  690. * Unimplemented. See org.w3c.dom.Document
  691. *
  692. * @param data Data for text node
  693. *
  694. * @return null
  695. */
  696. public Text createTextNode(String data)
  697. {
  698. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  699. return null;
  700. }
  701. /**
  702. * Unimplemented. See org.w3c.dom.Document
  703. *
  704. * @param data Data for comment
  705. *
  706. * @return null
  707. */
  708. public Comment createComment(String data)
  709. {
  710. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  711. return null;
  712. }
  713. /**
  714. * Unimplemented. See org.w3c.dom.Document
  715. *
  716. * @param data Data for CDATA section
  717. *
  718. * @return null
  719. *
  720. * @throws DOMException
  721. */
  722. public CDATASection createCDATASection(String data) throws DOMException
  723. {
  724. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  725. return null;
  726. }
  727. /**
  728. * Unimplemented. See org.w3c.dom.Document
  729. *
  730. * @param target Target for Processing instruction
  731. * @param data Data for Processing instruction
  732. *
  733. * @return null
  734. *
  735. * @throws DOMException
  736. */
  737. public ProcessingInstruction createProcessingInstruction(
  738. String target, String data) throws DOMException
  739. {
  740. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  741. return null;
  742. }
  743. /**
  744. * Unimplemented. See org.w3c.dom.Document
  745. *
  746. * @param name Attribute name
  747. *
  748. * @return null
  749. *
  750. * @throws DOMException
  751. */
  752. public Attr createAttribute(String name) throws DOMException
  753. {
  754. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  755. return null;
  756. }
  757. /**
  758. * Unimplemented. See org.w3c.dom.Document
  759. *
  760. * @param name Entity Reference name
  761. *
  762. * @return null
  763. *
  764. * @throws DOMException
  765. */
  766. public EntityReference createEntityReference(String name)
  767. throws DOMException
  768. {
  769. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  770. return null;
  771. }
  772. /**
  773. * Unimplemented. See org.w3c.dom.Document
  774. *
  775. * @param importedNodeThe node to import.
  776. * @param deepIf <code>true</code>, recursively import the subtree under
  777. * the specified node; if <code>false</code>, import only the node
  778. * itself, as explained above. This has no effect on <code>Attr</code>
  779. * , <code>EntityReference</code>, and <code>Notation</code> nodes.
  780. *
  781. * NEEDSDOC @param importedNode
  782. * NEEDSDOC @param deep
  783. *
  784. * @return null
  785. *
  786. * @throws DOMException
  787. */
  788. public Node importNode(Node importedNode, boolean deep) throws DOMException
  789. {
  790. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  791. return null;
  792. }
  793. /**
  794. * Unimplemented. See org.w3c.dom.Document
  795. *
  796. * @param namespaceURI Namespace URI for the element
  797. * @param qualifiedName Qualified name of the element
  798. *
  799. * @return null
  800. *
  801. * @throws DOMException
  802. */
  803. public Element createElementNS(String namespaceURI, String qualifiedName)
  804. throws DOMException
  805. {
  806. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  807. return null;
  808. }
  809. /**
  810. * Unimplemented. See org.w3c.dom.Document
  811. *
  812. * @param namespaceURI Namespace URI of the attribute
  813. * @param qualifiedName Qualified name of the attribute
  814. *
  815. * @return null
  816. *
  817. * @throws DOMException
  818. */
  819. public Attr createAttributeNS(String namespaceURI, String qualifiedName)
  820. throws DOMException
  821. {
  822. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  823. return null;
  824. }
  825. /**
  826. * Unimplemented. See org.w3c.dom.Document
  827. *
  828. * @param elementId ID of the element to get
  829. *
  830. * @return null
  831. */
  832. public Element getElementById(String elementId)
  833. {
  834. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  835. return null;
  836. }
  837. /**
  838. * Set Node data
  839. *
  840. *
  841. * @param data data to set for this node
  842. *
  843. * @throws DOMException
  844. */
  845. public void setData(String data) throws DOMException
  846. {
  847. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  848. }
  849. /**
  850. * Unimplemented.
  851. *
  852. * @param offset Start offset of substring to extract.
  853. * @param count The length of the substring to extract.
  854. *
  855. * @return null
  856. *
  857. * @throws DOMException
  858. */
  859. public String substringData(int offset, int count) throws DOMException
  860. {
  861. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  862. return null;
  863. }
  864. /**
  865. * Unimplemented.
  866. *
  867. * @param arg String data to append
  868. *
  869. * @throws DOMException
  870. */
  871. public void appendData(String arg) throws DOMException
  872. {
  873. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  874. }
  875. /**
  876. * Unimplemented.
  877. *
  878. * @param offset Start offset of substring to insert.
  879. * @param count The length of the substring to insert.
  880. * NEEDSDOC @param arg
  881. *
  882. * @throws DOMException
  883. */
  884. public void insertData(int offset, String arg) throws DOMException
  885. {
  886. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  887. }
  888. /**
  889. * Unimplemented.
  890. *
  891. * @param offset Start offset of substring to delete.
  892. * @param count The length of the substring to delete.
  893. *
  894. * @throws DOMException
  895. */
  896. public void deleteData(int offset, int count) throws DOMException
  897. {
  898. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  899. }
  900. /**
  901. * Unimplemented.
  902. *
  903. * @param offset Start offset of substring to replace.
  904. * @param count The length of the substring to replace.
  905. * @param arg substring to replace with
  906. *
  907. * @throws DOMException
  908. */
  909. public void replaceData(int offset, int count, String arg)
  910. throws DOMException
  911. {
  912. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  913. }
  914. /**
  915. * Unimplemented.
  916. *
  917. * @param offset Offset into text to split
  918. *
  919. * @return null, unimplemented
  920. *
  921. * @throws DOMException
  922. */
  923. public Text splitText(int offset) throws DOMException
  924. {
  925. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  926. return null;
  927. }
  928. /**
  929. * NEEDSDOC Method adoptNode
  930. *
  931. *
  932. * NEEDSDOC @param source
  933. *
  934. * NEEDSDOC (adoptNode) @return
  935. *
  936. * @throws DOMException
  937. */
  938. public Node adoptNode(Node source) throws DOMException
  939. {
  940. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  941. return null;
  942. }
  943. /**
  944. * <p>EXPERIMENTAL! Based on the <a
  945. * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
  946. * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>.
  947. * <p>
  948. * An attribute specifying, as part of the XML declaration, the encoding
  949. * of this document. This is <code>null</code> when unspecified.
  950. * @since DOM Level 3
  951. *
  952. * NEEDSDOC ($objectName$) @return
  953. */
  954. public String getInputEncoding()
  955. {
  956. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  957. return null;
  958. }
  959. /**
  960. * <p>EXPERIMENTAL! Based on the <a
  961. * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
  962. * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>.
  963. * <p>
  964. * An attribute specifying, as part of the XML declaration, the encoding
  965. * of this document. This is <code>null</code> when unspecified.
  966. * @since DOM Level 3
  967. *
  968. * NEEDSDOC @param encoding
  969. */
  970. public void setInputEncoding(String encoding)
  971. {
  972. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  973. }
  974. /**
  975. * <p>EXPERIMENTAL! Based on the <a
  976. * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
  977. * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>.
  978. * <p>
  979. * An attribute specifying, as part of the XML declaration, whether this
  980. * document is standalone.
  981. * @since DOM Level 3
  982. *
  983. * NEEDSDOC ($objectName$) @return
  984. */
  985. public boolean getStandalone()
  986. {
  987. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  988. return false;
  989. }
  990. /**
  991. * <p>EXPERIMENTAL! Based on the <a
  992. * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
  993. * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>.
  994. * <p>
  995. * An attribute specifying, as part of the XML declaration, whether this
  996. * document is standalone.
  997. * @since DOM Level 3
  998. *
  999. * NEEDSDOC @param standalone
  1000. */
  1001. public void setStandalone(boolean standalone)
  1002. {
  1003. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  1004. }
  1005. /**
  1006. * <p>EXPERIMENTAL! Based on the <a
  1007. * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
  1008. * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>.
  1009. * <p>
  1010. * An attribute specifying whether errors checking is enforced or not.
  1011. * When set to <code>false</code>, the implementation is free to not
  1012. * test every possible error case normally defined on DOM operations,
  1013. * and not raise any <code>DOMException</code>. In case of error, the
  1014. * behavior is undefined. This attribute is <code>true</code> by
  1015. * defaults.
  1016. * @since DOM Level 3
  1017. *
  1018. * NEEDSDOC ($objectName$) @return
  1019. */
  1020. public boolean getStrictErrorChecking()
  1021. {
  1022. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  1023. return false;
  1024. }
  1025. /**
  1026. * <p>EXPERIMENTAL! Based on the <a
  1027. * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
  1028. * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>.
  1029. * <p>
  1030. * An attribute specifying whether errors checking is enforced or not.
  1031. * When set to <code>false</code>, the implementation is free to not
  1032. * test every possible error case normally defined on DOM operations,
  1033. * and not raise any <code>DOMException</code>. In case of error, the
  1034. * behavior is undefined. This attribute is <code>true</code> by
  1035. * defaults.
  1036. * @since DOM Level 3
  1037. *
  1038. * NEEDSDOC @param strictErrorChecking
  1039. */
  1040. public void setStrictErrorChecking(boolean strictErrorChecking)
  1041. {
  1042. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  1043. }
  1044. /**
  1045. * <p>EXPERIMENTAL! Based on the <a
  1046. * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
  1047. * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>.
  1048. * <p>
  1049. * An attribute specifying, as part of the XML declaration, the version
  1050. * number of this document. This is <code>null</code> when unspecified.
  1051. * @since DOM Level 3
  1052. *
  1053. * NEEDSDOC ($objectName$) @return
  1054. */
  1055. public String getVersion()
  1056. {
  1057. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  1058. return null;
  1059. }
  1060. /**
  1061. * <p>EXPERIMENTAL! Based on the <a
  1062. * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
  1063. * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>.
  1064. * <p>
  1065. * An attribute specifying, as part of the XML declaration, the version
  1066. * number of this document. This is <code>null</code> when unspecified.
  1067. * @since DOM Level 3
  1068. *
  1069. * NEEDSDOC @param version
  1070. */
  1071. public void setVersion(String version)
  1072. {
  1073. error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);
  1074. }
  1075. //RAMESH : Pending proper implementation of DOM Level 3
  1076. public Object setUserData(String key,
  1077. Object data,
  1078. UserDataHandler handler) {
  1079. return getOwnerDocument().setUserData( key, data, handler);
  1080. }
  1081. /**
  1082. * Retrieves the object associated to a key on a this node. The object
  1083. * must first have been set to this node by calling
  1084. * <code>setUserData</code> with the same key.
  1085. * @param key The key the object is associated to.
  1086. * @return Returns the <code>DOMObject</code> associated to the given key
  1087. * on this node, or <code>null</code> if there was none.
  1088. * @since DOM Level 3
  1089. */
  1090. public Object getUserData(String key) {
  1091. return getOwnerDocument().getUserData( key);
  1092. }
  1093. /**
  1094. * This method returns a specialized object which implements the
  1095. * specialized APIs of the specified feature and version. The
  1096. * specialized object may also be obtained by using binding-specific
  1097. * casting methods but is not necessarily expected to, as discussed in Mixed DOM implementations.
  1098. * @param feature The name of the feature requested (case-insensitive).
  1099. * @param version This is the version number of the feature to test. If
  1100. * the version is <code>null</code> or the empty string, supporting
  1101. * any version of the feature will cause the method to return an
  1102. * object that supports at least one version of the feature.
  1103. * @return Returns an object which implements the specialized APIs of
  1104. * the specified feature and version, if any, or <code>null</code> if
  1105. * there is no object which implements interfaces associated with that
  1106. * feature. If the <code>DOMObject</code> returned by this method
  1107. * implements the <code>Node</code> interface, it must delegate to the
  1108. * primary core <code>Node</code> and not return results inconsistent
  1109. * with the primary core <code>Node</code> such as attributes,
  1110. * childNodes, etc.
  1111. * @since DOM Level 3
  1112. */
  1113. public Object getFeature(String feature, String version) {
  1114. // we don't have any alternate node, either this node does the job
  1115. // or we don't have anything that does
  1116. return isSupported(feature, version) ? this : null;
  1117. }
  1118. /**
  1119. * Tests whether two nodes are equal.
  1120. * <br>This method tests for equality of nodes, not sameness (i.e.,
  1121. * whether the two nodes are references to the same object) which can be
  1122. * tested with <code>Node.isSameNode</code>. All nodes that are the same
  1123. * will also be equal, though the reverse may not be true.
  1124. * <br>Two nodes are equal if and only if the following conditions are
  1125. * satisfied: The two nodes are of the same type.The following string
  1126. * attributes are equal: <code>nodeName</code>, <code>localName</code>,
  1127. * <code>namespaceURI</code>, <code>prefix</code>, <code>nodeValue</code>
  1128. * , <code>baseURI</code>. This is: they are both <code>null</code>, or
  1129. * they have the same length and are character for character identical.
  1130. * The <code>attributes</code> <code>NamedNodeMaps</code> are equal.
  1131. * This is: they are both <code>null</code>, or they have the same
  1132. * length and for each node that exists in one map there is a node that
  1133. * exists in the other map and is equal, although not necessarily at the
  1134. * same index.The <code>childNodes</code> <code>NodeLists</code> are
  1135. * equal. This is: they are both <code>null</code>, or they have the
  1136. * same length and contain equal nodes at the same index. This is true
  1137. * for <code>Attr</code> nodes as for any other type of node. Note that
  1138. * normalization can affect equality; to avoid this, nodes should be
  1139. * normalized before being compared.
  1140. * <br>For two <code>DocumentType</code> nodes to be equal, the following
  1141. * conditions must also be satisfied: The following string attributes
  1142. * are equal: <code>publicId</code>, <code>systemId</code>,
  1143. * <code>internalSubset</code>.The <code>entities</code>
  1144. * <code>NamedNodeMaps</code> are equal.The <code>notations</code>
  1145. * <code>NamedNodeMaps</code> are equal.
  1146. * <br>On the other hand, the following do not affect equality: the
  1147. * <code>ownerDocument</code> attribute, the <code>specified</code>
  1148. * attribute for <code>Attr</code> nodes, the
  1149. * <code>isWhitespaceInElementContent</code> attribute for
  1150. * <code>Text</code> nodes, as well as any user data or event listeners
  1151. * registered on the nodes.
  1152. * @param arg The node to compare equality with.
  1153. * @param deep If <code>true</code>, recursively compare the subtrees; if
  1154. * <code>false</code>, compare only the nodes themselves (and its
  1155. * attributes, if it is an <code>Element</code>).
  1156. * @return If the nodes, and possibly subtrees are equal,
  1157. * <code>true</code> otherwise <code>false</code>.
  1158. * @since DOM Level 3
  1159. */
  1160. public boolean isEqualNode(Node arg) {
  1161. if (arg == this) {
  1162. return true;
  1163. }
  1164. if (arg.getNodeType() != getNodeType()) {
  1165. return false;
  1166. }
  1167. // in theory nodeName can't be null but better be careful
  1168. // who knows what other implementations may be doing?...
  1169. if (getNodeName() == null) {
  1170. if (arg.getNodeName() != null) {
  1171. return false;
  1172. }
  1173. }
  1174. else if (!getNodeName().equals(arg.getNodeName())) {
  1175. return false;
  1176. }
  1177. if (getLocalName() == null) {
  1178. if (arg.getLocalName() != null) {
  1179. return false;
  1180. }
  1181. }
  1182. else if (!getLocalName().equals(arg.getLocalName())) {
  1183. return false;
  1184. }
  1185. if (getNamespaceURI() == null) {
  1186. if (arg.getNamespaceURI() != null) {
  1187. return false;
  1188. }
  1189. }
  1190. else if (!getNamespaceURI().equals(arg.getNamespaceURI())) {
  1191. return false;
  1192. }
  1193. if (getPrefix() == null) {
  1194. if (arg.getPrefix() != null) {
  1195. return false;
  1196. }
  1197. }
  1198. else if (!getPrefix().equals(arg.getPrefix())) {
  1199. return false;
  1200. }
  1201. if (getNodeValue() == null) {
  1202. if (arg.getNodeValue() != null) {
  1203. return false;
  1204. }
  1205. }
  1206. else if (!getNodeValue().equals(arg.getNodeValue())) {
  1207. return false;
  1208. }
  1209. /*
  1210. if (getBaseURI() == null) {
  1211. if (((NodeImpl) arg).getBaseURI() != null) {
  1212. return false;
  1213. }
  1214. }
  1215. else if (!getBaseURI().equals(((NodeImpl) arg).getBaseURI())) {
  1216. return false;
  1217. }
  1218. */
  1219. return true;
  1220. }
  1221. /**
  1222. * DOM Level 3 - Experimental:
  1223. * Look up the namespace URI associated to the given prefix, starting from this node.
  1224. * Use lookupNamespaceURI(null) to lookup the default namespace
  1225. *
  1226. * @param namespaceURI
  1227. * @return th URI for the namespace
  1228. * @since DOM Level 3
  1229. */
  1230. public String lookupNamespaceURI(String specifiedPrefix) {
  1231. short type = this.getNodeType();
  1232. switch (type) {
  1233. case Node.ELEMENT_NODE : {
  1234. String namespace = this.getNamespaceURI();
  1235. String prefix = this.getPrefix();
  1236. if (namespace !=null) {
  1237. // REVISIT: is it possible that prefix is empty string?
  1238. if (specifiedPrefix== null && prefix==specifiedPrefix) {
  1239. // looking for default namespace
  1240. return namespace;
  1241. } else if (prefix != null && prefix.equals(specifiedPrefix)) {
  1242. // non default namespace
  1243. return namespace;
  1244. }
  1245. }
  1246. if (this.hasAttributes()) {
  1247. NamedNodeMap map = this.getAttributes();
  1248. int length = map.getLength();
  1249. for (int i=0;i<length;i++) {
  1250. Node attr = map.item(i);
  1251. String attrPrefix = attr.getPrefix();
  1252. String value = attr.getNodeValue();
  1253. namespace = attr.getNamespaceURI();
  1254. if (namespace !=null && namespace.equals("http://www.w3.org/2000/xmlns/")) {
  1255. // at this point we are dealing with DOM Level 2 nodes only
  1256. if (specifiedPrefix == null &&
  1257. attr.getNodeName().equals("xmlns")) {
  1258. // default namespace
  1259. return value;
  1260. } else if (attrPrefix !=null &&
  1261. attrPrefix.equals("xmlns") &&
  1262. attr.getLocalName().equals(specifiedPrefix)) {
  1263. // non default namespace
  1264. return value;
  1265. }
  1266. }
  1267. }
  1268. }
  1269. /*
  1270. NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
  1271. if (ancestor != null) {
  1272. return ancestor.lookupNamespaceURI(specifiedPrefix);
  1273. }
  1274. */
  1275. return null;
  1276. }
  1277. /*
  1278. case Node.DOCUMENT_NODE : {
  1279. return((NodeImpl)((Document)this).getDocumentElement()).lookupNamespaceURI(specifiedPrefix) ;
  1280. }
  1281. */
  1282. case Node.ENTITY_NODE :
  1283. case Node.NOTATION_NODE:
  1284. case Node.DOCUMENT_FRAGMENT_NODE:
  1285. case Node.DOCUMENT_TYPE_NODE:
  1286. // type is unknown
  1287. return null;
  1288. case Node.ATTRIBUTE_NODE:{
  1289. if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
  1290. return getOwnerElement().lookupNamespaceURI(specifiedPrefix);
  1291. }
  1292. return null;
  1293. }
  1294. default:{
  1295. /*
  1296. NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
  1297. if (ancestor != null) {
  1298. return ancestor.lookupNamespaceURI(specifiedPrefix);
  1299. }
  1300. */
  1301. return null;
  1302. }
  1303. }
  1304. }
  1305. /**
  1306. * DOM Level 3: Experimental
  1307. * This method checks if the specified <code>namespaceURI</code> is the
  1308. * default namespace or not.
  1309. * @param namespaceURI The namespace URI to look for.
  1310. * @return <code>true</code> if the specified <code>namespaceURI</code>
  1311. * is the default namespace, <code>false</code> otherwise.
  1312. * @since DOM Level 3
  1313. */
  1314. public boolean isDefaultNamespace(String namespaceURI){
  1315. /*
  1316. // REVISIT: remove casts when DOM L3 becomes REC.
  1317. short type = this.getNodeType();
  1318. switch (type) {
  1319. case Node.ELEMENT_NODE: {
  1320. String namespace = this.getNamespaceURI();
  1321. String prefix = this.getPrefix();
  1322. // REVISIT: is it possible that prefix is empty string?
  1323. if (prefix == null || prefix.length() == 0) {
  1324. if (namespaceURI == null) {
  1325. return (namespace == namespaceURI);
  1326. }
  1327. return namespaceURI.equals(namespace);
  1328. }
  1329. if (this.hasAttributes()) {
  1330. ElementImpl elem = (ElementImpl)this;
  1331. NodeImpl attr = (NodeImpl)elem.getAttributeNodeNS("http://www.w3.org/2000/xmlns/", "xmlns");
  1332. if (attr != null) {
  1333. String value = attr.getNodeValue();
  1334. if (namespaceURI == null) {
  1335. return (namespace == value);
  1336. }
  1337. return namespaceURI.equals(value);
  1338. }
  1339. }
  1340. NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
  1341. if (ancestor != null) {
  1342. return ancestor.isDefaultNamespace(namespaceURI);
  1343. }
  1344. return false;
  1345. }
  1346. case Node.DOCUMENT_NODE:{
  1347. return((NodeImpl)((Document)this).getDocumentElement()).isDefaultNamespace(namespaceURI);
  1348. }
  1349. case Node.ENTITY_NODE :
  1350. case Node.NOTATION_NODE:
  1351. case Node.DOCUMENT_FRAGMENT_NODE:
  1352. case Node.DOCUMENT_TYPE_NODE:
  1353. // type is unknown
  1354. return false;
  1355. case Node.ATTRIBUTE_NODE:{
  1356. if (this.ownerNode.getNodeType() == Node.ELEMENT_NODE) {
  1357. return ownerNode.isDefaultNamespace(namespaceURI);
  1358. }
  1359. return false;
  1360. }
  1361. default:{
  1362. NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
  1363. if (ancestor != null) {
  1364. return ancestor.isDefaultNamespace(namespaceURI);
  1365. }
  1366. return false;
  1367. }
  1368. }
  1369. */
  1370. return false;
  1371. }
  1372. /**
  1373. *
  1374. * DOM Level 3 - Experimental:
  1375. * Look up the prefix associated to the given namespace URI, starting from this node.
  1376. *
  1377. * @param namespaceURI
  1378. * @return the prefix for the namespace
  1379. */
  1380. public String lookupPrefix(String namespaceURI){
  1381. // REVISIT: When Namespaces 1.1 comes out this may not be true
  1382. // Prefix can't be bound to null namespace
  1383. if (namespaceURI == null) {
  1384. return null;
  1385. }
  1386. short type = this.getNodeType();
  1387. switch (type) {
  1388. /*
  1389. case Node.ELEMENT_NODE: {
  1390. String namespace = this.getNamespaceURI(); // to flip out children
  1391. return lookupNamespacePrefix(namespaceURI, (ElementImpl)this);
  1392. }
  1393. case Node.DOCUMENT_NODE:{
  1394. return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI);
  1395. }
  1396. */
  1397. case Node.ENTITY_NODE :
  1398. case Node.NOTATION_NODE:
  1399. case Node.DOCUMENT_FRAGMENT_NODE:
  1400. case Node.DOCUMENT_TYPE_NODE:
  1401. // type is unknown
  1402. return null;
  1403. case Node.ATTRIBUTE_NODE:{
  1404. if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
  1405. return getOwnerElement().lookupPrefix(namespaceURI);
  1406. }
  1407. return null;
  1408. }
  1409. default:{
  1410. /*
  1411. NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
  1412. if (ancestor != null) {
  1413. return ancestor.lookupPrefix(namespaceURI);
  1414. }
  1415. */
  1416. return null;
  1417. }
  1418. }
  1419. }
  1420. /**
  1421. * Returns whether this node is the same node as the given one.
  1422. * <br>This method provides a way to determine whether two
  1423. * <code>Node</code> references returned by the implementation reference
  1424. * the same object. When two <code>Node</code> references are references
  1425. * to the same object, even if through a proxy, the references may be
  1426. * used completely interchangably, such that all attributes have the
  1427. * same values and calling the same DOM method on either reference
  1428. * always has exactly the same effect.
  1429. * @param other The node to test against.
  1430. * @return Returns <code>true</code> if the nodes are the same,
  1431. * <code>false</code> otherwise.
  1432. * @since DOM Level 3
  1433. */
  1434. public boolean isSameNode(Node other) {
  1435. // we do not use any wrapper so the answer is obvious
  1436. return this == other;
  1437. }
  1438. /**
  1439. * This attribute returns the text content of this node and its
  1440. * descendants. When it is defined to be null, setting it has no effect.
  1441. * When set, any possible children this node may have are removed and
  1442. * replaced by a single <code>Text</code> node containing the string
  1443. * this attribute is set to. On getting, no serialization is performed,
  1444. * the returned string does not contain any markup. No whitespace
  1445. * normalization is performed, the returned string does not contain the
  1446. * element content whitespaces . Similarly, on setting, no parsing is
  1447. * performed either, the input string is taken as pure textual content.
  1448. * <br>The string returned is made of the text content of this node
  1449. * depending on its type, as defined below:
  1450. * <table border='1'>
  1451. * <tr>
  1452. * <th>Node type</th>
  1453. * <th>Content</th>
  1454. * </tr>
  1455. * <tr>
  1456. * <td valign='top' rowspan='1' colspan='1'>
  1457. * ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,
  1458. * DOCUMENT_FRAGMENT_NODE</td>
  1459. * <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code>
  1460. * attribute value of every child node, excluding COMMENT_NODE and
  1461. * PROCESSING_INSTRUCTION_NODE nodes</td>
  1462. * </tr>
  1463. * <tr>
  1464. * <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE,
  1465. * CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td>
  1466. * <td valign='top' rowspan='1' colspan='1'>
  1467. * <code>nodeValue</code></td>
  1468. * </tr>
  1469. * <tr>
  1470. * <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td>
  1471. * <td valign='top' rowspan='1' colspan='1'>
  1472. * null</td>
  1473. * </tr>
  1474. * </table>
  1475. * @exception DOMException
  1476. * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
  1477. * @exception DOMException
  1478. * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
  1479. * fit in a <code>DOMString</code> variable on the implementation
  1480. * platform.
  1481. * @since DOM Level 3
  1482. */
  1483. public void setTextContent(String textContent)
  1484. throws DOMException {
  1485. setNodeValue(textContent);
  1486. }
  1487. /**
  1488. * This attribute returns the text content of this node and its
  1489. * descendants. When it is defined to be null, setting it has no effect.
  1490. * When set, any possible children this node may have are removed and
  1491. * replaced by a single <code>Text</code> node containing the string
  1492. * this attribute is set to. On getting, no serialization is performed,
  1493. * the returned string does not contain any markup. No whitespace
  1494. * normalization is performed, the returned string does not contain the
  1495. * element content whitespaces . Similarly, on setting, no parsing is
  1496. * performed either, the input string is taken as pure textual content.
  1497. * <br>The string returned is made of the text content of this node
  1498. * depending on its type, as defined below:
  1499. * <table border='1'>
  1500. * <tr>
  1501. * <th>Node type</th>
  1502. * <th>Content</th>
  1503. * </tr>
  1504. * <tr>
  1505. * <td valign='top' rowspan='1' colspan='1'>
  1506. * ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,
  1507. * DOCUMENT_FRAGMENT_NODE</td>
  1508. * <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code>
  1509. * attribute value of every child node, excluding COMMENT_NODE and
  1510. * PROCESSING_INSTRUCTION_NODE nodes</td>
  1511. * </tr>
  1512. * <tr>
  1513. * <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE,
  1514. * CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td>
  1515. * <td valign='top' rowspan='1' colspan='1'>
  1516. * <code>nodeValue</code></td>
  1517. * </tr>
  1518. * <tr>
  1519. * <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td>
  1520. * <td valign='top' rowspan='1' colspan='1'>
  1521. * null</td>
  1522. * </tr>
  1523. * </table>
  1524. * @exception DOMException
  1525. * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
  1526. * @exception DOMException
  1527. * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
  1528. * fit in a <code>DOMString</code> variable on the implementation
  1529. * platform.
  1530. * @since DOM Level 3
  1531. */
  1532. public String getTextContent() throws DOMException {
  1533. return getNodeValue(); // overriden in some subclasses
  1534. }
  1535. /**
  1536. * Compares a node with this node with regard to their position in the
  1537. * document.
  1538. * @param other The node to compare against this node.
  1539. * @return Returns how the given node is positioned relatively to this
  1540. * node.
  1541. * @since DOM Level 3
  1542. */
  1543. public short compareDocumentPosition(Node other) throws DOMException {
  1544. return 0;
  1545. }
  1546. /**
  1547. * The absolute base URI of this node or <code>null</code> if undefined.
  1548. * This value is computed according to . However, when the
  1549. * <code>Document</code> supports the feature "HTML" , the base URI is
  1550. * computed using first the value of the href attribute of the HTML BASE
  1551. * element if any, and the value of the <code>documentURI</code>
  1552. * attribute from the <code>Document</code> interface otherwise.
  1553. * <br> When the node is an <code>Element</code>, a <code>Document</code>
  1554. * or a a <code>ProcessingInstruction</code>, this attribute represents
  1555. * the properties [base URI] defined in . When the node is a
  1556. * <code>Notation</code>, an <code>Entity</code>, or an
  1557. * <code>EntityReference</code>, this attribute represents the
  1558. * properties [declaration base URI] in the . How will this be affected
  1559. * by resolution of relative namespace URIs issue?It's not.Should this
  1560. * only be on Document, Element, ProcessingInstruction, Entity, and
  1561. * Notation nodes, according to the infoset? If not, what is it equal to
  1562. * on other nodes? Null? An empty string? I think it should be the
  1563. * parent's.No.Should this be read-only and computed or and actual
  1564. * read-write attribute?Read-only and computed (F2F 19 Jun 2000 and
  1565. * teleconference 30 May 2001).If the base HTML element is not yet
  1566. * attached to a document, does the insert change the Document.baseURI?
  1567. * Yes. (F2F 26 Sep 2001)
  1568. * @since DOM Level 3
  1569. */
  1570. public String getBaseURI() {
  1571. return null;
  1572. }
  1573. /**
  1574. * DOM Level 3 WD - Experimental.
  1575. * Renaming node
  1576. */
  1577. public Node renameNode(Node n,
  1578. String namespaceURI,
  1579. String name)
  1580. throws DOMException{
  1581. return n;
  1582. }
  1583. /**
  1584. * DOM Level 3 WD - Experimental
  1585. * Normalize document.
  1586. */
  1587. public void normalizeDocument(){
  1588. }
  1589. /**
  1590. * The configuration used when <code>Document.normalizeDocument</code> is
  1591. * invoked.
  1592. * @since DOM Level 3
  1593. */
  1594. public DOMConfiguration getDomConfig(){
  1595. return null;
  1596. }
  1597. /**Experimental DOM Level 3 feature: documentURI */
  1598. protected String fDocumentURI;
  1599. /**
  1600. * DOM Level 3 WD - Experimental.
  1601. */
  1602. public void setDocumentURI(String documentURI){
  1603. fDocumentURI= documentURI;
  1604. }
  1605. /**
  1606. * DOM Level 3 WD - Experimental.
  1607. * The location of the document or <code>null</code> if undefined.
  1608. * <br>Beware that when the <code>Document</code> supports the feature
  1609. * "HTML" , the href attribute of the HTML BASE element takes precedence
  1610. * over this attribute.
  1611. * @since DOM Level 3
  1612. */
  1613. public String getDocumentURI(){
  1614. return fDocumentURI;
  1615. }
  1616. /**Experimental DOM Level 3 feature: Document actualEncoding */
  1617. protected String actualEncoding;
  1618. /**
  1619. * DOM Level 3 WD - Experimental.
  1620. * An attribute specifying the actual encoding of this document. This is
  1621. * <code>null</code> otherwise.
  1622. * <br> This attribute represents the property [character encoding scheme]
  1623. * defined in .
  1624. * @since DOM Level 3
  1625. */
  1626. public String getActualEncoding() {
  1627. return actualEncoding;
  1628. }
  1629. /**
  1630. * DOM Level 3 WD - Experimental.
  1631. * An attribute specifying the actual encoding of this document. This is
  1632. * <code>null</code> otherwise.
  1633. * <br> This attribute represents the property [character encoding scheme]
  1634. * defined in .
  1635. * @since DOM Level 3
  1636. */
  1637. public void setActualEncoding(String value) {
  1638. actualEncoding = value;
  1639. }
  1640. /**
  1641. * DOM Level 3 WD - Experimental.
  1642. */
  1643. public Text replaceWholeText(String content)
  1644. throws DOMException{
  1645. /*
  1646. if (needsSyncData()) {
  1647. synchronizeData();
  1648. }
  1649. // make sure we can make the replacement
  1650. if (!canModify(nextSibling)) {
  1651. throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
  1652. DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null));
  1653. }
  1654. Node parent = this.getParentNode();
  1655. if (content == null || content.length() == 0) {
  1656. // remove current node
  1657. if (parent !=null) { // check if node in the tree
  1658. parent.removeChild(this);
  1659. return null;
  1660. }
  1661. }
  1662. Text currentNode = null;
  1663. if (isReadOnly()){
  1664. Text newNode = this.ownerDocument().createTextNode(content);
  1665. if (parent !=null) { // check if node in the tree
  1666. parent.insertBefore(newNode, this);
  1667. parent.removeChild(this);
  1668. currentNode = newNode;
  1669. } else {
  1670. return newNode;
  1671. }
  1672. } else {
  1673. this.setData(content);
  1674. currentNode = this;
  1675. }
  1676. Node sibling = currentNode.getNextSibling();
  1677. while ( sibling !=null) {
  1678. parent.removeChild(sibling);
  1679. sibling = currentNode.getNextSibling();
  1680. }
  1681. return currentNode;
  1682. */
  1683. return null; //Pending
  1684. }
  1685. /**
  1686. * DOM Level 3 WD - Experimental.
  1687. * Returns all text of <code>Text</code> nodes logically-adjacent text
  1688. * nodes to this node, concatenated in document order.
  1689. * @since DOM Level 3
  1690. */
  1691. public String getWholeText(){
  1692. /*
  1693. if (needsSyncData()) {
  1694. synchronizeData();
  1695. }
  1696. if (nextSibling == null) {
  1697. return data;
  1698. }
  1699. StringBuffer buffer = new StringBuffer();
  1700. if (data != null && data.length() != 0) {
  1701. buffer.append(data);
  1702. }
  1703. getWholeText(nextSibling, buffer);
  1704. return buffer.toString();
  1705. */
  1706. return null; // PENDING
  1707. }
  1708. /**
  1709. * DOM Level 3 WD - Experimental.
  1710. * Returns whether this text node contains whitespace in element content,
  1711. * often abusively called "ignorable whitespace".
  1712. */
  1713. public boolean isWhitespaceInElementContent(){
  1714. return false;
  1715. }
  1716. /**
  1717. * NON-DOM: set the type of this attribute to be ID type.
  1718. *
  1719. * @param id
  1720. */
  1721. public void setIdAttribute(boolean id){
  1722. //PENDING
  1723. }
  1724. /**
  1725. * DOM Level 3: register the given attribute node as an ID attribute
  1726. */
  1727. public void setIdAttribute(String name, boolean makeId) {
  1728. //PENDING
  1729. }
  1730. /**
  1731. * DOM Level 3: register the given attribute node as an ID attribute
  1732. */
  1733. public void setIdAttributeNode(Attr at, boolean makeId) {
  1734. //PENDING
  1735. }
  1736. /**
  1737. * DOM Level 3: register the given attribute node as an ID attribute
  1738. */
  1739. public void setIdAttributeNS(String namespaceURI, String localName,
  1740. boolean makeId) {
  1741. //PENDING
  1742. }
  1743. /**
  1744. * Method getSchemaTypeInfo.
  1745. * @return TypeInfo
  1746. */
  1747. public TypeInfo getSchemaTypeInfo(){
  1748. return null; //PENDING
  1749. }
  1750. public boolean isId() {
  1751. return false; //PENDING
  1752. }
  1753. private String xmlEncoding;
  1754. public String getXmlEncoding ( ) {
  1755. return xmlEncoding;
  1756. }
  1757. public void setXmlEncoding ( String xmlEncoding ) {
  1758. this.xmlEncoding = xmlEncoding;
  1759. }
  1760. private boolean xmlStandalone;
  1761. public boolean getXmlStandalone() {
  1762. return xmlStandalone;
  1763. }
  1764. public void setXmlStandalone(boolean xmlStandalone) throws DOMException {
  1765. this.xmlStandalone = xmlStandalone;
  1766. }
  1767. private String xmlVersion;
  1768. public String getXmlVersion() {
  1769. return xmlVersion;
  1770. }
  1771. public void setXmlVersion(String xmlVersion) throws DOMException {
  1772. this.xmlVersion = xmlVersion;
  1773. }
  1774. }