1 16 19 20 package org.apache.xalan.xsltc.dom; 21 22 import org.apache.xalan.xsltc.runtime.BasisLibrary; 23 import org.apache.xml.dtm.DTMAxisIterator; 24 import org.apache.xml.dtm.ref.DTMAxisIteratorBase; 25 26 40 public class StepIterator extends DTMAxisIteratorBase { 41 42 45 protected DTMAxisIterator _source; 46 47 50 protected DTMAxisIterator _iterator; 51 52 55 private int _pos = -1; 56 57 public StepIterator(DTMAxisIterator source, DTMAxisIterator iterator) { 58 _source = source; 59 _iterator = iterator; 60 } 63 64 65 public void setRestartable(boolean isRestartable) { 66 _isRestartable = isRestartable; 67 _source.setRestartable(isRestartable); 68 _iterator.setRestartable(true); } 70 71 public DTMAxisIterator cloneIterator() { 72 _isRestartable = false; 73 try { 74 final StepIterator clone = (StepIterator) super.clone(); 75 clone._source = _source.cloneIterator(); 76 clone._iterator = _iterator.cloneIterator(); 77 clone._iterator.setRestartable(true); clone._isRestartable = false; 79 return clone.reset(); 80 } 81 catch (CloneNotSupportedException e) { 82 BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR, 83 e.toString()); 84 return null; 85 } 86 } 87 88 public DTMAxisIterator setStartNode(int node) { 89 if (_isRestartable) { 90 _source.setStartNode(_startNode = node); 92 93 _iterator.setStartNode(_includeSelf ? _startNode : _source.next()); 96 return resetPosition(); 97 } 98 return this; 99 } 100 101 public DTMAxisIterator reset() { 102 _source.reset(); 103 _iterator.setStartNode(_includeSelf ? _startNode : _source.next()); 105 return resetPosition(); 106 } 107 108 public int next() { 109 for (int node;;) { 110 if ((node = _iterator.next()) != END) { 112 return returnNode(node); 113 } 114 else if ((node = _source.next()) == END) { 116 return END; 117 } 118 else { 120 _iterator.setStartNode(node); 121 } 122 } 123 } 124 125 public void setMark() { 126 _source.setMark(); 127 _iterator.setMark(); 128 } 130 131 public void gotoMark() { 132 _source.gotoMark(); 133 _iterator.gotoMark(); 134 } 136 } 137 | Popular Tags |