2
* Licensed to the Apache Software Foundation (ASF) under one
3
* or more contributor license agreements. See the NOTICE file
4
* distributed with this work for additional information
5
* regarding copyright ownership. The ASF licenses this file
6
* to you under the Apache License, Version 2.0 (the "License");
7
* you may not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
10
* http://www.apache.org/licenses/LICENSE-2.0
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
19
* $Id: UnionIterator.java,v 1.2 2009/12/10 03:18:34 matthewoliver Exp $
22
package org.apache.xalan.xsltc.dom;
24
import org.apache.xalan.xsltc.DOM;
25
import org.apache.xalan.xsltc.runtime.BasisLibrary;
26
import org.apache.xml.dtm.DTMAxisIterator;
27
import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
30
* UnionIterator takes a set of NodeIterators and produces
31
* a merged NodeSet in document order with duplicates removed
32
* The individual iterators are supposed to generate nodes
34
* @author Jacek Ambroziak
35
* @author Santiago Pericas-Geertsen
37
public final class UnionIterator extends MultiValuedNodeHeapIterator {
38
/** wrapper for NodeIterators to support iterator
39
comparison on the value of their next() method
41
final private DOM _dom;
43
private final class LookAheadIterator
44
extends MultiValuedNodeHeapIterator.HeapNode
46
public DTMAxisIterator iterator;
48
public LookAheadIterator(DTMAxisIterator iterator) {
50
this.iterator = iterator;
54
_node = iterator.next();
58
public HeapNode cloneHeapNode() {
59
LookAheadIterator clone = (LookAheadIterator) super.cloneHeapNode();
60
clone.iterator = iterator.cloneIterator();
64
public void setMark() {
69
public void gotoMark() {
74
public boolean isLessThan(HeapNode heapNode) {
75
LookAheadIterator comparand = (LookAheadIterator) heapNode;
76
return _dom.lessThan(_node, heapNode._node);
79
public HeapNode setStartNode(int node) {
80
iterator.setStartNode(node);
84
public HeapNode reset() {
88
} // end of LookAheadIterator
90
public UnionIterator(DOM dom) {
94
public UnionIterator addIterator(DTMAxisIterator iterator) {
95
addHeapNode(new LookAheadIterator(iterator));