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