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: ChildIterator.java,v 1.2 2009/12/10 03:18:40 matthewoliver Exp $
21
package org.apache.xpath.axes;
23
import org.apache.xml.dtm.DTM;
24
import org.apache.xml.dtm.DTMFilter;
25
import org.apache.xpath.XPathContext;
26
import org.apache.xpath.compiler.Compiler;
29
* This class implements an optimized iterator for
30
* "node()" patterns, that is, any children of the
32
* @see org.apache.xpath.axes.LocPathIterator
35
public class ChildIterator extends LocPathIterator
37
static final long serialVersionUID = -6935428015142993583L;
40
* Create a ChildIterator object.
42
* @param compiler A reference to the Compiler that contains the op map.
43
* @param opPos The position within the op map, which contains the
44
* location path expression for this itterator.
45
* @param analysis Analysis bits of the entire pattern.
47
* @throws javax.xml.transform.TransformerException
49
ChildIterator(Compiler compiler, int opPos, int analysis)
50
throws javax.xml.transform.TransformerException
52
super(compiler, opPos, analysis, false);
54
// This iterator matches all kinds of nodes
55
initNodeTest(DTMFilter.SHOW_ALL);
59
* Return the first node out of the nodeset, if this expression is
60
* a nodeset expression. This is the default implementation for
62
* <p>WARNING: Do not mutate this class from this function!</p>
63
* @param xctxt The XPath runtime context.
64
* @return the first node out of the nodeset, or DTM.NULL.
66
public int asNode(XPathContext xctxt)
67
throws javax.xml.transform.TransformerException
69
int current = xctxt.getCurrentNode();
71
DTM dtm = xctxt.getDTM(current);
73
return dtm.getFirstChild(current);
77
* Returns the next node in the set and advances the position of the
78
* iterator in the set. After a NodeIterator is created, the first call
79
* to nextNode() returns the first node in the set.
81
* @return The next <code>Node</code> in the set being iterated over, or
82
* <code>null</code> if there are no more members in that set.
91
m_lastFetched = next = (DTM.NULL == m_lastFetched)
92
? m_cdtm.getFirstChild(m_context)
93
: m_cdtm.getNextSibling(m_lastFetched);
95
// m_lastFetched = next;
110
* Returns the axis being iterated, if it is known.
112
* @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple
117
return org.apache.xml.dtm.Axis.CHILD;