001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 /*
019 * $Id: ArrayNodeListIterator.java 1225426 2011-12-29 04:13:08Z mrglavas $
020 */
021
022 package org.apache.xalan.xsltc.dom;
023
024 import org.apache.xml.dtm.DTMAxisIterator;
025
026 public class ArrayNodeListIterator implements DTMAxisIterator {
027
028 private int _pos = 0;
029
030 private int _mark = 0;
031
032 private int _nodes[];
033
034 private static final int[] EMPTY = { };
035
036 public ArrayNodeListIterator(int[] nodes) {
037 _nodes = nodes;
038 }
039
040 public int next() {
041 return _pos < _nodes.length ? _nodes[_pos++] : END;
042 }
043
044 public DTMAxisIterator reset() {
045 _pos = 0;
046 return this;
047 }
048
049 public int getLast() {
050 return _nodes.length;
051 }
052
053 public int getPosition() {
054 return _pos;
055 }
056
057 public void setMark() {
058 _mark = _pos;
059 }
060
061 public void gotoMark() {
062 _pos = _mark;
063 }
064
065 public DTMAxisIterator setStartNode(int node) {
066 if (node == END) _nodes = EMPTY;
067 return this;
068 }
069
070 public int getStartNode() {
071 return END;
072 }
073
074 public boolean isReverse() {
075 return false;
076 }
077
078 public DTMAxisIterator cloneIterator() {
079 return new ArrayNodeListIterator(_nodes);
080 }
081
082 public void setRestartable(boolean isRestartable) {
083 }
084
085 public int getNodeByPosition(int position) {
086 return _nodes[position - 1];
087 }
088
089 }