1 16 19 20 package com.sun.org.apache.xalan.internal.xsltc.dom; 21 22 import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary; 23 import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator; 24 import com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase; 25 26 46 public final class MatchingIterator extends DTMAxisIteratorBase { 47 48 51 private DTMAxisIterator _source; 52 53 56 private final int _match; 57 58 public MatchingIterator(int match, DTMAxisIterator source) { 59 _source = source; 60 _match = match; 61 } 62 63 64 public void setRestartable(boolean isRestartable) { 65 _isRestartable = isRestartable; 66 _source.setRestartable(isRestartable); 67 } 68 69 public DTMAxisIterator cloneIterator() { 70 71 try { 72 final MatchingIterator clone = (MatchingIterator) super.clone(); 73 clone._source = _source.cloneIterator(); 74 clone._isRestartable = false; 75 return clone.reset(); 76 } 77 catch (CloneNotSupportedException e) { 78 BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR, 79 e.toString()); 80 return null; 81 } 82 } 83 84 public DTMAxisIterator setStartNode(int node) { 85 if (_isRestartable) { 86 _source.setStartNode(node); 88 89 _position = 1; 91 while ((node = _source.next()) != END && node != _match) { 92 _position++; 93 } 94 } 95 return this; 96 } 97 98 public DTMAxisIterator reset() { 99 _source.reset(); 100 return resetPosition(); 101 } 102 103 public int next() { 104 return _source.next(); 105 } 106 107 public int getLast() { 108 if (_last == -1) { 109 _last = _source.getLast(); 110 } 111 return _last; 112 } 113 114 public int getPosition() { 115 return _position; 116 } 117 118 public void setMark() { 119 _source.setMark(); 120 } 121 122 public void gotoMark() { 123 _source.gotoMark(); 124 } 125 } 126 | Popular Tags |