author | joehw |
Wed, 18 Oct 2017 13:25:49 -0700 | |
changeset 47359 | e1a6c0168741 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
6 | 1 |
/* |
2 |
* reserved comment block |
|
3 |
* DO NOT REMOVE OR ALTER! |
|
4 |
*/ |
|
5 |
/* |
|
44797
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
6 |
* Licensed to the Apache Software Foundation (ASF) under one or more |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
7 |
* contributor license agreements. See the NOTICE file distributed with |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
8 |
* this work for additional information regarding copyright ownership. |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
9 |
* The ASF licenses this file to You under the Apache License, Version 2.0 |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
10 |
* (the "License"); you may not use this file except in compliance with |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
11 |
* the License. You may obtain a copy of the License at |
6 | 12 |
* |
44797
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
13 |
* http://www.apache.org/licenses/LICENSE-2.0 |
6 | 14 |
* |
15 |
* Unless required by applicable law or agreed to in writing, software |
|
16 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
17 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
18 |
* See the License for the specific language governing permissions and |
|
19 |
* limitations under the License. |
|
20 |
*/ |
|
44797
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
21 |
|
6 | 22 |
package com.sun.org.apache.xpath.internal.axes; |
23 |
||
24 |
import com.sun.org.apache.xml.internal.dtm.DTM; |
|
25 |
import com.sun.org.apache.xml.internal.dtm.DTMFilter; |
|
26 |
import com.sun.org.apache.xpath.internal.XPathContext; |
|
27 |
import com.sun.org.apache.xpath.internal.compiler.Compiler; |
|
28 |
||
29 |
/** |
|
30 |
* This class implements an optimized iterator for |
|
31 |
* "node()" patterns, that is, any children of the |
|
32 |
* context node. |
|
33 |
* @see com.sun.org.apache.xpath.internal.axes.LocPathIterator |
|
34 |
* @xsl.usage advanced |
|
35 |
*/ |
|
36 |
public class ChildIterator extends LocPathIterator |
|
37 |
{ |
|
38 |
static final long serialVersionUID = -6935428015142993583L; |
|
39 |
||
40 |
/** |
|
41 |
* Create a ChildIterator object. |
|
42 |
* |
|
43 |
* @param compiler A reference to the Compiler that contains the op map. |
|
44 |
* @param opPos The position within the op map, which contains the |
|
45 |
* location path expression for this itterator. |
|
46 |
* @param analysis Analysis bits of the entire pattern. |
|
47 |
* |
|
48 |
* @throws javax.xml.transform.TransformerException |
|
49 |
*/ |
|
50 |
ChildIterator(Compiler compiler, int opPos, int analysis) |
|
51 |
throws javax.xml.transform.TransformerException |
|
52 |
{ |
|
53 |
super(compiler, opPos, analysis, false); |
|
54 |
||
55 |
// This iterator matches all kinds of nodes |
|
56 |
initNodeTest(DTMFilter.SHOW_ALL); |
|
57 |
} |
|
58 |
||
59 |
/** |
|
60 |
* Return the first node out of the nodeset, if this expression is |
|
61 |
* a nodeset expression. This is the default implementation for |
|
62 |
* nodesets. |
|
63 |
* <p>WARNING: Do not mutate this class from this function!</p> |
|
64 |
* @param xctxt The XPath runtime context. |
|
65 |
* @return the first node out of the nodeset, or DTM.NULL. |
|
66 |
*/ |
|
67 |
public int asNode(XPathContext xctxt) |
|
68 |
throws javax.xml.transform.TransformerException |
|
69 |
{ |
|
70 |
int current = xctxt.getCurrentNode(); |
|
71 |
||
72 |
DTM dtm = xctxt.getDTM(current); |
|
73 |
||
74 |
return dtm.getFirstChild(current); |
|
75 |
} |
|
76 |
||
77 |
/** |
|
78 |
* Returns the next node in the set and advances the position of the |
|
79 |
* iterator in the set. After a NodeIterator is created, the first call |
|
80 |
* to nextNode() returns the first node in the set. |
|
81 |
* |
|
82 |
* @return The next <code>Node</code> in the set being iterated over, or |
|
83 |
* <code>null</code> if there are no more members in that set. |
|
84 |
*/ |
|
85 |
public int nextNode() |
|
86 |
{ |
|
87 |
if(m_foundLast) |
|
88 |
return DTM.NULL; |
|
89 |
||
90 |
int next; |
|
91 |
||
92 |
m_lastFetched = next = (DTM.NULL == m_lastFetched) |
|
93 |
? m_cdtm.getFirstChild(m_context) |
|
94 |
: m_cdtm.getNextSibling(m_lastFetched); |
|
95 |
||
96 |
// m_lastFetched = next; |
|
97 |
if (DTM.NULL != next) |
|
98 |
{ |
|
99 |
m_pos++; |
|
100 |
return next; |
|
101 |
} |
|
102 |
else |
|
103 |
{ |
|
104 |
m_foundLast = true; |
|
105 |
||
106 |
return DTM.NULL; |
|
107 |
} |
|
108 |
} |
|
109 |
||
110 |
/** |
|
111 |
* Returns the axis being iterated, if it is known. |
|
112 |
* |
|
113 |
* @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple |
|
114 |
* types. |
|
115 |
*/ |
|
116 |
public int getAxis() |
|
117 |
{ |
|
118 |
return com.sun.org.apache.xml.internal.dtm.Axis.CHILD; |
|
119 |
} |
|
120 |
||
121 |
||
122 |
} |