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: SimpleResultTreeImpl.java,v 1.7 2004/02/16 22:54:59 minchau Exp $
  18. */
  19. package com.sun.org.apache.xalan.internal.xsltc.dom;
  20. import com.sun.org.apache.xalan.internal.xsltc.DOM;
  21. import com.sun.org.apache.xalan.internal.xsltc.TransletException;
  22. import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
  23. import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
  24. import com.sun.org.apache.xml.internal.dtm.DTM;
  25. import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
  26. import com.sun.org.apache.xml.internal.dtm.DTMAxisTraverser;
  27. import com.sun.org.apache.xml.internal.dtm.DTMManager;
  28. import com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase;
  29. import com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault;
  30. import com.sun.org.apache.xml.internal.serializer.EmptySerializer;
  31. import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
  32. import com.sun.org.apache.xml.internal.utils.XMLString;
  33. import com.sun.org.apache.xml.internal.utils.XMLStringDefault;
  34. import org.w3c.dom.Node;
  35. import org.w3c.dom.NodeList;
  36. import org.xml.sax.SAXException;
  37. import javax.xml.transform.SourceLocator;
  38. /**
  39. * This class represents a light-weight DOM model for simple result tree fragment(RTF).
  40. * A simple RTF is an RTF that has only one Text node. The Text node can be produced by a
  41. * combination of Text, xsl:value-of and xsl:number instructions. It can also be produced
  42. * by a control structure (xsl:if or xsl:choose) whose body is pure Text.
  43. * <p>
  44. * A SimpleResultTreeImpl has only two nodes, i.e. the ROOT node and its Text child. All DOM
  45. * interfaces are overridden with this in mind. For example, the getStringValue() interface
  46. * returns the value of the Text node. This class receives the character data from the
  47. * characters() interface.
  48. * <p>
  49. * This class implements DOM and SerializationHandler. It also implements the DTM interface
  50. * for support in MultiDOM. The nested iterators (SimpleIterator and SingletonIterator) are
  51. * used to support the nodeset() extension function.
  52. */
  53. public class SimpleResultTreeImpl extends EmptySerializer implements DOM, DTM
  54. {
  55. /**
  56. * The SimpleIterator is designed to support the nodeset() extension function. It has
  57. * a traversal direction parameter. The DOWN direction is used for child and descendant
  58. * axes, while the UP direction is used for parent and ancestor axes.
  59. *
  60. * This iterator only handles two nodes (RTF_ROOT and RTF_TEXT). If the type is set,
  61. * it will also match the node type with the given type.
  62. */
  63. public final class SimpleIterator extends DTMAxisIteratorBase
  64. {
  65. static final int DIRECTION_UP = 0;
  66. static final int DIRECTION_DOWN = 1;
  67. static final int NO_TYPE = -1;
  68. // The direction of traversal (default to DOWN).
  69. // DOWN is for child and descendant. UP is for parent and ancestor.
  70. int _direction = DIRECTION_DOWN;
  71. int _type = NO_TYPE;
  72. int _currentNode;
  73. public SimpleIterator()
  74. {
  75. }
  76. public SimpleIterator(int direction)
  77. {
  78. _direction = direction;
  79. }
  80. public SimpleIterator(int direction, int type)
  81. {
  82. _direction = direction;
  83. _type = type;
  84. }
  85. public int next()
  86. {
  87. // Increase the node ID for down traversal. Also match the node type
  88. // if the type is given.
  89. if (_direction == DIRECTION_DOWN) {
  90. while (_currentNode < NUMBER_OF_NODES) {
  91. if (_type != NO_TYPE) {
  92. if ((_currentNode == RTF_ROOT && _type == DTM.ROOT_NODE)
  93. || (_currentNode == RTF_TEXT && _type == DTM.TEXT_NODE))
  94. return returnNode(getNodeHandle(_currentNode++));
  95. else
  96. _currentNode++;
  97. }
  98. else
  99. return returnNode(getNodeHandle(_currentNode++));
  100. }
  101. return END;
  102. }
  103. // Decrease the node ID for up traversal.
  104. else {
  105. while (_currentNode >= 0) {
  106. if (_type != NO_TYPE) {
  107. if ((_currentNode == RTF_ROOT && _type == DTM.ROOT_NODE)
  108. || (_currentNode == RTF_TEXT && _type == DTM.TEXT_NODE))
  109. return returnNode(getNodeHandle(_currentNode--));
  110. else
  111. _currentNode--;
  112. }
  113. else
  114. return returnNode(getNodeHandle(_currentNode--));
  115. }
  116. return END;
  117. }
  118. }
  119. public DTMAxisIterator setStartNode(int nodeHandle)
  120. {
  121. int nodeID = getNodeIdent(nodeHandle);
  122. _startNode = nodeID;
  123. // Increase the node ID by 1 if self is not included.
  124. if (!_includeSelf && nodeID != DTM.NULL) {
  125. if (_direction == DIRECTION_DOWN)
  126. nodeID++;
  127. else if (_direction == DIRECTION_UP)
  128. nodeID--;
  129. }
  130. _currentNode = nodeID;
  131. return this;
  132. }
  133. public void setMark()
  134. {
  135. _markedNode = _currentNode;
  136. }
  137. public void gotoMark()
  138. {
  139. _currentNode = _markedNode;
  140. }
  141. } // END of SimpleIterator
  142. /**
  143. * The SingletonIterator is used for the self axis.
  144. */
  145. public final class SingletonIterator extends DTMAxisIteratorBase
  146. {
  147. static final int NO_TYPE = -1;
  148. int _type = NO_TYPE;
  149. int _currentNode;
  150. public SingletonIterator()
  151. {
  152. }
  153. public SingletonIterator(int type)
  154. {
  155. _type = type;
  156. }
  157. public void setMark()
  158. {
  159. _markedNode = _currentNode;
  160. }
  161. public void gotoMark()
  162. {
  163. _currentNode = _markedNode;
  164. }
  165. public DTMAxisIterator setStartNode(int nodeHandle)
  166. {
  167. _currentNode = _startNode = getNodeIdent(nodeHandle);
  168. return this;
  169. }
  170. public int next()
  171. {
  172. if (_currentNode == END)
  173. return END;
  174. _currentNode = END;
  175. if (_type != NO_TYPE) {
  176. if ((_currentNode == RTF_ROOT && _type == DTM.ROOT_NODE)
  177. || (_currentNode == RTF_TEXT && _type == DTM.TEXT_NODE))
  178. return getNodeHandle(_currentNode);
  179. }
  180. else
  181. return getNodeHandle(_currentNode);
  182. return END;
  183. }
  184. } // END of SingletonIterator
  185. // empty iterator to be returned when there are no children
  186. private final static DTMAxisIterator EMPTY_ITERATOR =
  187. new DTMAxisIteratorBase() {
  188. public DTMAxisIterator reset() { return this; }
  189. public DTMAxisIterator setStartNode(int node) { return this; }
  190. public int next() { return DTM.NULL; }
  191. public void setMark() {}
  192. public void gotoMark() {}
  193. public int getLast() { return 0; }
  194. public int getPosition() { return 0; }
  195. public DTMAxisIterator cloneIterator() { return this; }
  196. public void setRestartable(boolean isRestartable) { }
  197. };
  198. // The root node id of the simple RTF
  199. public static final int RTF_ROOT = 0;
  200. // The Text node id of the simple RTF (simple RTF has only one Text node).
  201. public static final int RTF_TEXT = 1;
  202. // The number of nodes.
  203. public static final int NUMBER_OF_NODES = 2;
  204. // Document URI index, which increases by 1 at each getDocumentURI() call.
  205. private static int _documentURIIndex = 0;
  206. // Constant for empty String
  207. private static final String EMPTY_STR = "";
  208. // The String value of the Text node.
  209. // This is set at the endDocument() call.
  210. private String _text;
  211. // The array of Text items, which is built by the characters() call.
  212. // The characters() interface can be called multiple times. Each character item
  213. // can have different escape settings.
  214. protected String[] _textArray;
  215. // The DTMManager
  216. protected XSLTCDTMManager _dtmManager;
  217. // Number of character items
  218. protected int _size = 0;
  219. // The document ID
  220. private int _documentID;
  221. // A BitArray, each bit holding the escape setting for a character item.
  222. private BitArray _dontEscape = null;
  223. // The current escape setting
  224. private boolean _escaping = true;
  225. // Create a SimpleResultTreeImpl from a DTMManager and a document ID.
  226. public SimpleResultTreeImpl(XSLTCDTMManager dtmManager, int documentID)
  227. {
  228. _dtmManager = dtmManager;
  229. _documentID = documentID;
  230. _textArray = new String[4];
  231. }
  232. public DTMManagerDefault getDTMManager()
  233. {
  234. return _dtmManager;
  235. }
  236. // Return the document ID
  237. public int getDocument()
  238. {
  239. return _documentID;
  240. }
  241. // Return the String value of the RTF
  242. public String getStringValue()
  243. {
  244. return _text;
  245. }
  246. public DTMAxisIterator getIterator()
  247. {
  248. return new SingletonIterator(getDocument());
  249. }
  250. public DTMAxisIterator getChildren(final int node)
  251. {
  252. return new SimpleIterator().setStartNode(node);
  253. }
  254. public DTMAxisIterator getTypedChildren(final int type)
  255. {
  256. return new SimpleIterator(SimpleIterator.DIRECTION_DOWN, type);
  257. }
  258. // Return the axis iterator for a given axis.
  259. // The SimpleIterator is used for the child, descendant, parent and ancestor axes.
  260. public DTMAxisIterator getAxisIterator(final int axis)
  261. {
  262. switch (axis)
  263. {
  264. case Axis.CHILD:
  265. case Axis.DESCENDANT:
  266. return new SimpleIterator(SimpleIterator.DIRECTION_DOWN);
  267. case Axis.PARENT:
  268. case Axis.ANCESTOR:
  269. return new SimpleIterator(SimpleIterator.DIRECTION_UP);
  270. case Axis.ANCESTORORSELF:
  271. return (new SimpleIterator(SimpleIterator.DIRECTION_UP)).includeSelf();
  272. case Axis.DESCENDANTORSELF:
  273. return (new SimpleIterator(SimpleIterator.DIRECTION_DOWN)).includeSelf();
  274. case Axis.SELF:
  275. return new SingletonIterator();
  276. default:
  277. return EMPTY_ITERATOR;
  278. }
  279. }
  280. public DTMAxisIterator getTypedAxisIterator(final int axis, final int type)
  281. {
  282. switch (axis)
  283. {
  284. case Axis.CHILD:
  285. case Axis.DESCENDANT:
  286. return new SimpleIterator(SimpleIterator.DIRECTION_DOWN, type);
  287. case Axis.PARENT:
  288. case Axis.ANCESTOR:
  289. return new SimpleIterator(SimpleIterator.DIRECTION_UP, type);
  290. case Axis.ANCESTORORSELF:
  291. return (new SimpleIterator(SimpleIterator.DIRECTION_UP, type)).includeSelf();
  292. case Axis.DESCENDANTORSELF:
  293. return (new SimpleIterator(SimpleIterator.DIRECTION_DOWN, type)).includeSelf();
  294. case Axis.SELF:
  295. return new SingletonIterator(type);
  296. default:
  297. return EMPTY_ITERATOR;
  298. }
  299. }
  300. // %REVISIT% Can this one ever get used?
  301. public DTMAxisIterator getNthDescendant(int node, int n, boolean includeself)
  302. {
  303. return null;
  304. }
  305. public DTMAxisIterator getNamespaceAxisIterator(final int axis, final int ns)
  306. {
  307. return null;
  308. }
  309. // %REVISIT% Can this one ever get used?
  310. public DTMAxisIterator getNodeValueIterator(DTMAxisIterator iter, int returnType,
  311. String value, boolean op)
  312. {
  313. return null;
  314. }
  315. public DTMAxisIterator orderNodes(DTMAxisIterator source, int node)
  316. {
  317. return source;
  318. }
  319. public String getNodeName(final int node)
  320. {
  321. if (getNodeIdent(node) == RTF_TEXT)
  322. return "#text";
  323. else
  324. return EMPTY_STR;
  325. }
  326. public String getNodeNameX(final int node)
  327. {
  328. return EMPTY_STR;
  329. }
  330. public String getNamespaceName(final int node)
  331. {
  332. return EMPTY_STR;
  333. }
  334. // Return the expanded type id of a given node
  335. public int getExpandedTypeID(final int nodeHandle)
  336. {
  337. int nodeID = getNodeIdent(nodeHandle);
  338. if (nodeID == RTF_TEXT)
  339. return DTM.TEXT_NODE;
  340. else if (nodeID == RTF_ROOT)
  341. return DTM.ROOT_NODE;
  342. else
  343. return DTM.NULL;
  344. }
  345. public int getNamespaceType(final int node)
  346. {
  347. return 0;
  348. }
  349. public int getParent(final int nodeHandle)
  350. {
  351. int nodeID = getNodeIdent(nodeHandle);
  352. return (nodeID == RTF_TEXT) ? getNodeHandle(RTF_ROOT) : DTM.NULL;
  353. }
  354. public int getAttributeNode(final int gType, final int element)
  355. {
  356. return DTM.NULL;
  357. }
  358. public String getStringValueX(final int nodeHandle)
  359. {
  360. int nodeID = getNodeIdent(nodeHandle);
  361. if (nodeID == RTF_ROOT || nodeID == RTF_TEXT)
  362. return _text;
  363. else
  364. return EMPTY_STR;
  365. }
  366. public void copy(final int node, SerializationHandler handler)
  367. throws TransletException
  368. {
  369. characters(node, handler);
  370. }
  371. public void copy(DTMAxisIterator nodes, SerializationHandler handler)
  372. throws TransletException
  373. {
  374. int node;
  375. while ((node = nodes.next()) != DTM.NULL)
  376. {
  377. copy(node, handler);
  378. }
  379. }
  380. public String shallowCopy(final int node, SerializationHandler handler)
  381. throws TransletException
  382. {
  383. characters(node, handler);
  384. return null;
  385. }
  386. public boolean lessThan(final int node1, final int node2)
  387. {
  388. if (node1 == DTM.NULL) {
  389. return false;
  390. }
  391. else if (node2 == DTM.NULL) {
  392. return true;
  393. }
  394. else
  395. return (node1 < node2);
  396. }
  397. /**
  398. * Dispatch the character content of a node to an output handler.
  399. *
  400. * The escape setting should be taken care of when outputting to
  401. * a handler.
  402. */
  403. public void characters(final int node, SerializationHandler handler)
  404. throws TransletException
  405. {
  406. int nodeID = getNodeIdent(node);
  407. if (nodeID == RTF_ROOT || nodeID == RTF_TEXT) {
  408. boolean escapeBit = false;
  409. boolean oldEscapeSetting = false;
  410. try {
  411. for (int i = 0; i < _size; i++) {
  412. if (_dontEscape != null) {
  413. escapeBit = _dontEscape.getBit(i);
  414. if (escapeBit) {
  415. oldEscapeSetting = handler.setEscaping(false);
  416. }
  417. }
  418. handler.characters(_textArray[i]);
  419. if (escapeBit) {
  420. handler.setEscaping(oldEscapeSetting);
  421. }
  422. }
  423. } catch (SAXException e) {
  424. throw new TransletException(e);
  425. }
  426. }
  427. }
  428. // %REVISIT% Can the makeNode() and makeNodeList() interfaces ever get used?
  429. public Node makeNode(int index)
  430. {
  431. return null;
  432. }
  433. public Node makeNode(DTMAxisIterator iter)
  434. {
  435. return null;
  436. }
  437. public NodeList makeNodeList(int index)
  438. {
  439. return null;
  440. }
  441. public NodeList makeNodeList(DTMAxisIterator iter)
  442. {
  443. return null;
  444. }
  445. public String getLanguage(int node)
  446. {
  447. return null;
  448. }
  449. public int getSize()
  450. {
  451. return 2;
  452. }
  453. public String getDocumentURI(int node)
  454. {
  455. return "simple_rtf" + _documentURIIndex++;
  456. }
  457. public void setFilter(StripFilter filter)
  458. {
  459. }
  460. public void setupMapping(String[] names, String[] uris, int[] types, String[] namespaces)
  461. {
  462. }
  463. public boolean isElement(final int node)
  464. {
  465. return false;
  466. }
  467. public boolean isAttribute(final int node)
  468. {
  469. return false;
  470. }
  471. public String lookupNamespace(int node, String prefix)
  472. throws TransletException
  473. {
  474. return null;
  475. }
  476. /**
  477. * Return the node identity from a node handle.
  478. */
  479. public int getNodeIdent(final int nodehandle)
  480. {
  481. return (nodehandle != DTM.NULL) ? (nodehandle - _documentID) : DTM.NULL;
  482. }
  483. /**
  484. * Return the node handle from a node identity.
  485. */
  486. public int getNodeHandle(final int nodeId)
  487. {
  488. return (nodeId != DTM.NULL) ? (nodeId + _documentID) : DTM.NULL;
  489. }
  490. public DOM getResultTreeFrag(int initialSize, int rtfType)
  491. {
  492. return null;
  493. }
  494. public DOM getResultTreeFrag(int initialSize, int rtfType, boolean addToManager)
  495. {
  496. return null;
  497. }
  498. public SerializationHandler getOutputDomBuilder()
  499. {
  500. return this;
  501. }
  502. public int getNSType(int node)
  503. {
  504. return 0;
  505. }
  506. public String getUnparsedEntityURI(String name)
  507. {
  508. return null;
  509. }
  510. public Hashtable getElementsWithIDs()
  511. {
  512. return null;
  513. }
  514. /** Implementation of the SerializationHandler interfaces **/
  515. /**
  516. * We only need to override the endDocument, characters, and
  517. * setEscaping interfaces. A simple RTF does not have element
  518. * nodes. We do not need to touch startElement and endElement.
  519. */
  520. public void startDocument() throws SAXException
  521. {
  522. }
  523. public void endDocument() throws SAXException
  524. {
  525. // Set the String value when the document is built.
  526. if (_size == 1)
  527. _text = _textArray[0];
  528. else {
  529. StringBuffer buffer = new StringBuffer();
  530. for (int i = 0; i < _size; i++) {
  531. buffer.append(_textArray[i]);
  532. }
  533. _text = buffer.toString();
  534. }
  535. }
  536. public void characters(String str) throws SAXException
  537. {
  538. // Resize the text array if necessary
  539. if (_size >= _textArray.length) {
  540. String[] newTextArray = new String[_textArray.length * 2];
  541. System.arraycopy(_textArray, 0, newTextArray, 0, _textArray.length);
  542. _textArray = newTextArray;
  543. }
  544. // If the escape setting is false, set the corresponding bit in
  545. // the _dontEscape BitArray.
  546. if (!_escaping) {
  547. // The _dontEscape array is only created when needed.
  548. if (_dontEscape == null) {
  549. _dontEscape = new BitArray(8);
  550. }
  551. // Resize the _dontEscape array if necessary
  552. if (_size >= _dontEscape.size())
  553. _dontEscape.resize(_dontEscape.size() * 2);
  554. _dontEscape.setBit(_size);
  555. }
  556. _textArray[_size++] = str;
  557. }
  558. public void characters(char[] ch, int offset, int length)
  559. throws SAXException
  560. {
  561. if (_size >= _textArray.length) {
  562. String[] newTextArray = new String[_textArray.length * 2];
  563. System.arraycopy(_textArray, 0, newTextArray, 0, _textArray.length);
  564. _textArray = newTextArray;
  565. }
  566. if (!_escaping) {
  567. if (_dontEscape == null) {
  568. _dontEscape = new BitArray(8);
  569. }
  570. if (_size >= _dontEscape.size())
  571. _dontEscape.resize(_dontEscape.size() * 2);
  572. _dontEscape.setBit(_size);
  573. }
  574. _textArray[_size++] = new String(ch, offset, length);
  575. }
  576. public boolean setEscaping(boolean escape) throws SAXException
  577. {
  578. final boolean temp = _escaping;
  579. _escaping = escape;
  580. return temp;
  581. }
  582. /** Implementation of the DTM interfaces **/
  583. /**
  584. * The DTM interfaces are not used in this class. Implementing the DTM
  585. * interface is a requirement from MultiDOM. If we have a better way
  586. * of handling multiple documents, we can get rid of the DTM dependency.
  587. *
  588. * The following interfaces are just placeholders. The implementation
  589. * does not have an impact because they will not be used.
  590. */
  591. public void setFeature(String featureId, boolean state)
  592. {
  593. }
  594. public void setProperty(String property, Object value)
  595. {
  596. }
  597. public DTMAxisTraverser getAxisTraverser(final int axis)
  598. {
  599. return null;
  600. }
  601. public boolean hasChildNodes(int nodeHandle)
  602. {
  603. return (getNodeIdent(nodeHandle) == RTF_ROOT);
  604. }
  605. public int getFirstChild(int nodeHandle)
  606. {
  607. int nodeID = getNodeIdent(nodeHandle);
  608. if (nodeID == RTF_ROOT)
  609. return getNodeHandle(RTF_TEXT);
  610. else
  611. return DTM.NULL;
  612. }
  613. public int getLastChild(int nodeHandle)
  614. {
  615. return getFirstChild(nodeHandle);
  616. }
  617. public int getAttributeNode(int elementHandle, String namespaceURI, String name)
  618. {
  619. return DTM.NULL;
  620. }
  621. public int getFirstAttribute(int nodeHandle)
  622. {
  623. return DTM.NULL;
  624. }
  625. public int getFirstNamespaceNode(int nodeHandle, boolean inScope)
  626. {
  627. return DTM.NULL;
  628. }
  629. public int getNextSibling(int nodeHandle)
  630. {
  631. return DTM.NULL;
  632. }
  633. public int getPreviousSibling(int nodeHandle)
  634. {
  635. return DTM.NULL;
  636. }
  637. public int getNextAttribute(int nodeHandle)
  638. {
  639. return DTM.NULL;
  640. }
  641. public int getNextNamespaceNode(int baseHandle, int namespaceHandle,
  642. boolean inScope)
  643. {
  644. return DTM.NULL;
  645. }
  646. public int getOwnerDocument(int nodeHandle)
  647. {
  648. return getDocument();
  649. }
  650. public int getDocumentRoot(int nodeHandle)
  651. {
  652. return getDocument();
  653. }
  654. public XMLString getStringValue(int nodeHandle)
  655. {
  656. return new XMLStringDefault(getStringValueX(nodeHandle));
  657. }
  658. public int getStringValueChunkCount(int nodeHandle)
  659. {
  660. return 0;
  661. }
  662. public char[] getStringValueChunk(int nodeHandle, int chunkIndex,
  663. int[] startAndLen)
  664. {
  665. return null;
  666. }
  667. public int getExpandedTypeID(String namespace, String localName, int type)
  668. {
  669. return DTM.NULL;
  670. }
  671. public String getLocalNameFromExpandedNameID(int ExpandedNameID)
  672. {
  673. return EMPTY_STR;
  674. }
  675. public String getNamespaceFromExpandedNameID(int ExpandedNameID)
  676. {
  677. return EMPTY_STR;
  678. }
  679. public String getLocalName(int nodeHandle)
  680. {
  681. return EMPTY_STR;
  682. }
  683. public String getPrefix(int nodeHandle)
  684. {
  685. return null;
  686. }
  687. public String getNamespaceURI(int nodeHandle)
  688. {
  689. return EMPTY_STR;
  690. }
  691. public String getNodeValue(int nodeHandle)
  692. {
  693. return (getNodeIdent(nodeHandle) == RTF_TEXT) ? _text : null;
  694. }
  695. public short getNodeType(int nodeHandle)
  696. {
  697. int nodeID = getNodeIdent(nodeHandle);
  698. if (nodeID == RTF_TEXT)
  699. return DTM.TEXT_NODE;
  700. else if (nodeID == RTF_ROOT)
  701. return DTM.ROOT_NODE;
  702. else
  703. return DTM.NULL;
  704. }
  705. public short getLevel(int nodeHandle)
  706. {
  707. int nodeID = getNodeIdent(nodeHandle);
  708. if (nodeID == RTF_TEXT)
  709. return 2;
  710. else if (nodeID == RTF_ROOT)
  711. return 1;
  712. else
  713. return DTM.NULL;
  714. }
  715. public boolean isSupported(String feature, String version)
  716. {
  717. return false;
  718. }
  719. public String getDocumentBaseURI()
  720. {
  721. return EMPTY_STR;
  722. }
  723. public void setDocumentBaseURI(String baseURI)
  724. {
  725. }
  726. public String getDocumentSystemIdentifier(int nodeHandle)
  727. {
  728. return null;
  729. }
  730. public String getDocumentEncoding(int nodeHandle)
  731. {
  732. return null;
  733. }
  734. public String getDocumentStandalone(int nodeHandle)
  735. {
  736. return null;
  737. }
  738. public String getDocumentVersion(int documentHandle)
  739. {
  740. return null;
  741. }
  742. public boolean getDocumentAllDeclarationsProcessed()
  743. {
  744. return false;
  745. }
  746. public String getDocumentTypeDeclarationSystemIdentifier()
  747. {
  748. return null;
  749. }
  750. public String getDocumentTypeDeclarationPublicIdentifier()
  751. {
  752. return null;
  753. }
  754. public int getElementById(String elementId)
  755. {
  756. return DTM.NULL;
  757. }
  758. public boolean supportsPreStripping()
  759. {
  760. return false;
  761. }
  762. public boolean isNodeAfter(int firstNodeHandle, int secondNodeHandle)
  763. {
  764. return lessThan(firstNodeHandle, secondNodeHandle);
  765. }
  766. public boolean isCharacterElementContentWhitespace(int nodeHandle)
  767. {
  768. return false;
  769. }
  770. public boolean isDocumentAllDeclarationsProcessed(int documentHandle)
  771. {
  772. return false;
  773. }
  774. public boolean isAttributeSpecified(int attributeHandle)
  775. {
  776. return false;
  777. }
  778. public void dispatchCharactersEvents(
  779. int nodeHandle,
  780. org.xml.sax.ContentHandler ch,
  781. boolean normalize)
  782. throws org.xml.sax.SAXException
  783. {
  784. }
  785. public void dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch)
  786. throws org.xml.sax.SAXException
  787. {
  788. }
  789. public org.w3c.dom.Node getNode(int nodeHandle)
  790. {
  791. return makeNode(nodeHandle);
  792. }
  793. public boolean needsTwoThreads()
  794. {
  795. return false;
  796. }
  797. public org.xml.sax.ContentHandler getContentHandler()
  798. {
  799. return null;
  800. }
  801. public org.xml.sax.ext.LexicalHandler getLexicalHandler()
  802. {
  803. return null;
  804. }
  805. public org.xml.sax.EntityResolver getEntityResolver()
  806. {
  807. return null;
  808. }
  809. public org.xml.sax.DTDHandler getDTDHandler()
  810. {
  811. return null;
  812. }
  813. public org.xml.sax.ErrorHandler getErrorHandler()
  814. {
  815. return null;
  816. }
  817. public org.xml.sax.ext.DeclHandler getDeclHandler()
  818. {
  819. return null;
  820. }
  821. public void appendChild(int newChild, boolean clone, boolean cloneDepth)
  822. {
  823. }
  824. public void appendTextChild(String str)
  825. {
  826. }
  827. public SourceLocator getSourceLocatorFor(int node)
  828. {
  829. return null;
  830. }
  831. public void documentRegistration()
  832. {
  833. }
  834. public void documentRelease()
  835. {
  836. }
  837. public void migrateTo(DTMManager manager)
  838. {
  839. }
  840. }