1 /* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5 /* 6 * Copyright 2001-2004 The Apache Software Foundation. 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * 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 /* 22 * $Id: ArrayNodeListIterator.java,v 1.0 2009-11-25 04:34:24 joehw Exp $ 23 */ 24 package com.sun.org.apache.xalan.internal.xsltc.dom; 25 26 import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator; 27 28 public class ArrayNodeListIterator implements DTMAxisIterator { 29 30 private int _pos = 0; 31 32 private int _mark = 0; 33 34 private int _nodes[]; 35 36 private static final int[] EMPTY = { }; 37 ArrayNodeListIterator(int[] nodes)38 public ArrayNodeListIterator(int[] nodes) { 39 _nodes = nodes; 40 } 41 next()42 public int next() { 43 return _pos < _nodes.length ? _nodes[_pos++] : END; 44 } 45 reset()46 public DTMAxisIterator reset() { 47 _pos = 0; 48 return this; 49 } 50 getLast()51 public int getLast() { 52 return _nodes.length; 53 } 54 getPosition()55 public int getPosition() { 56 return _pos; 57 } 58 setMark()59 public void setMark() { 60 _mark = _pos; 61 } 62 gotoMark()63 public void gotoMark() { 64 _pos = _mark; 65 } 66 setStartNode(int node)67 public DTMAxisIterator setStartNode(int node) { 68 if (node == END) _nodes = EMPTY; 69 return this; 70 } 71 getStartNode()72 public int getStartNode() { 73 return END; 74 } 75 isReverse()76 public boolean isReverse() { 77 return false; 78 } 79 cloneIterator()80 public DTMAxisIterator cloneIterator() { 81 return new ArrayNodeListIterator(_nodes); 82 } 83 setRestartable(boolean isRestartable)84 public void setRestartable(boolean isRestartable) { 85 } 86 getNodeByPosition(int position)87 public int getNodeByPosition(int position) { 88 return _nodes[position - 1]; 89 } 90 91 } 92