1 16 19 package com.sun.org.apache.xml.internal.dtm.ref; 20 21 import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator; 22 23 27 public abstract class DTMAxisIteratorBase implements DTMAxisIterator 28 { 29 30 34 protected int _last = -1; 35 36 39 protected int _position = 0; 40 41 45 protected int _markedNode; 46 47 50 protected int _startNode = DTMAxisIterator.END; 51 52 55 protected boolean _includeSelf = false; 56 57 61 protected boolean _isRestartable = true; 62 63 69 public int getStartNode() 70 { 71 return _startNode; 72 } 73 74 78 public DTMAxisIterator reset() 79 { 80 81 final boolean temp = _isRestartable; 82 83 _isRestartable = true; 84 85 setStartNode(_startNode); 86 87 _isRestartable = temp; 88 89 return this; 90 } 91 92 101 public DTMAxisIterator includeSelf() 102 { 103 104 _includeSelf = true; 105 106 return this; 107 } 108 109 120 public int getLast() 121 { 122 123 if (_last == -1) { 125 132 final int temp = _position; setMark(); 134 135 reset(); do 137 { 138 _last++; 139 } 140 while (next() != END); 141 142 gotoMark(); _position = temp; 144 } 145 146 return _last; 147 } 148 149 153 public int getPosition() 154 { 155 return _position == 0 ? 1 : _position; 156 } 157 158 161 public boolean isReverse() 162 { 163 return false; 164 } 165 166 173 public DTMAxisIterator cloneIterator() 174 { 175 176 try 177 { 178 final DTMAxisIteratorBase clone = (DTMAxisIteratorBase) super.clone(); 179 180 clone._isRestartable = false; 181 182 return clone; 184 } 185 catch (CloneNotSupportedException e) 186 { 187 throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(e); 188 } 189 } 190 191 209 protected final int returnNode(final int node) 210 { 211 _position++; 212 213 return node; 214 } 215 216 224 protected final DTMAxisIterator resetPosition() 225 { 226 227 _position = 0; 228 229 return this; 230 } 231 232 238 public boolean isDocOrdered() 239 { 240 return true; 241 } 242 243 249 public int getAxis() 250 { 251 return -1; 252 } 253 254 public void setRestartable(boolean isRestartable) { 255 _isRestartable = isRestartable; 256 } 257 258 264 public int getNodeByPosition(int position) 265 { 266 if (position > 0) { 267 final int pos = isReverse() ? getLast() - position + 1 268 : position; 269 int node; 270 while ((node = next()) != DTMAxisIterator.END) { 271 if (pos == getPosition()) { 272 return node; 273 } 274 } 275 } 276 return END; 277 } 278 279 } 280 | Popular Tags |