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: ClonedNodeListIterator.java 468651 2006-10-28 07:04:25Z minchau $
020 */
021
022 package org.apache.xalan.xsltc.dom;
023
024 import org.apache.xml.dtm.DTMAxisIterator;
025 import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
026
027 /**
028 * A ClonedNodeListIterator is returned by the cloneIterator() method
029 * of a CachedNodeListIterator. Its next() method retrieves the nodes from
030 * the cache of the CachedNodeListIterator.
031 */
032 public final class ClonedNodeListIterator extends DTMAxisIteratorBase {
033
034 /**
035 * Source for this iterator.
036 */
037 private CachedNodeListIterator _source;
038 private int _index = 0;
039
040 public ClonedNodeListIterator(CachedNodeListIterator source) {
041 _source = source;
042 }
043
044 public void setRestartable(boolean isRestartable) {
045 //_isRestartable = isRestartable;
046 //_source.setRestartable(isRestartable);
047 }
048
049 public DTMAxisIterator setStartNode(int node) {
050 return this;
051 }
052
053 public int next() {
054 return _source.getNode(_index++);
055 }
056
057 public int getPosition() {
058 return _index == 0 ? 1 : _index;
059 }
060
061 public int getNodeByPosition(int pos) {
062 return _source.getNode(pos);
063 }
064
065 public DTMAxisIterator cloneIterator() {
066 return _source.cloneIterator();
067 }
068
069 public DTMAxisIterator reset() {
070 _index = 0;
071 return this;
072 }
073
074 public void setMark() {
075 _source.setMark();
076 }
077
078 public void gotoMark() {
079 _source.gotoMark();
080 }
081 }