1 16 19 20 package com.sun.org.apache.xalan.internal.xsltc.dom; 21 22 import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator; 23 import com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase; 24 25 29 public class SingletonIterator extends DTMAxisIteratorBase { 30 private int _node; 31 private final boolean _isConstant; 32 33 public SingletonIterator() { 34 this(Integer.MIN_VALUE, false); 35 } 36 37 public SingletonIterator(int node) { 38 this(node, false); 39 } 40 41 public SingletonIterator(int node, boolean constant) { 42 _node = _startNode = node; 43 _isConstant = constant; 44 } 45 46 50 public DTMAxisIterator setStartNode(int node) { 51 if (_isConstant) { 52 _node = _startNode; 53 return resetPosition(); 54 } 55 else if (_isRestartable) { 56 if (_node <= 0) 57 _node = _startNode = node; 58 return resetPosition(); 59 } 60 return this; 61 } 62 63 public DTMAxisIterator reset() { 64 if (_isConstant) { 65 _node = _startNode; 66 return resetPosition(); 67 } 68 else { 69 final boolean temp = _isRestartable; 70 _isRestartable = true; 71 setStartNode(_startNode); 72 _isRestartable = temp; 73 } 74 return this; 75 } 76 77 public int next() { 78 final int result = _node; 79 _node = DTMAxisIterator.END; 80 return returnNode(result); 81 } 82 83 public void setMark() { 84 _markedNode = _node; 85 } 86 87 public void gotoMark() { 88 _node = _markedNode; 89 } 90 } 91 | Popular Tags |