KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xpath > axes > SelfIteratorNoPredicate


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 /*
17  * $Id: SelfIteratorNoPredicate.java,v 1.12 2004/02/17 04:32:08 minchau Exp $
18  */

19 package org.apache.xpath.axes;
20
21 import org.apache.xml.dtm.DTM;
22 import org.apache.xpath.XPathContext;
23 import org.apache.xpath.compiler.Compiler;
24
25 /**
26  * This class implements an optimized iterator for
27  * "." patterns, that is, the self axes without any predicates.
28  * @see org.apache.xpath.axes.LocPathIterator
29  * @xsl.usage advanced
30  */

31 public class SelfIteratorNoPredicate extends LocPathIterator
32 {
33
34   /**
35    * Create a SelfIteratorNoPredicate object.
36    *
37    * @param compiler A reference to the Compiler that contains the op map.
38    * @param opPos The position within the op map, which contains the
39    * location path expression for this itterator.
40    * @param analysis Analysis bits.
41    *
42    * @throws javax.xml.transform.TransformerException
43    */

44   SelfIteratorNoPredicate(Compiler JavaDoc compiler, int opPos, int analysis)
45           throws javax.xml.transform.TransformerException JavaDoc
46   {
47     super(compiler, opPos, analysis, false);
48   }
49   
50   /**
51    * Create a SelfIteratorNoPredicate object.
52    *
53    * @param compiler A reference to the Compiler that contains the op map.
54    * @param opPos The position within the op map, which contains the
55    * location path expression for this itterator.
56    * @param analysis Analysis bits.
57    *
58    * @throws javax.xml.transform.TransformerException
59    */

60   public SelfIteratorNoPredicate()
61           throws javax.xml.transform.TransformerException JavaDoc
62   {
63     super(null);
64   }
65
66
67   /**
68    * Returns the next node in the set and advances the position of the
69    * iterator in the set. After a NodeIterator is created, the first call
70    * to nextNode() returns the first node in the set.
71    *
72    * @return The next <code>Node</code> in the set being iterated over, or
73    * <code>null</code> if there are no more members in that set.
74    */

75   public int nextNode()
76   {
77     if (m_foundLast)
78       return DTM.NULL;
79       
80     int next;
81     DTM dtm = m_cdtm;
82
83     m_lastFetched = next = (DTM.NULL == m_lastFetched)
84                            ? m_context
85                            : DTM.NULL;
86
87     // m_lastFetched = next;
88
if (DTM.NULL != next)
89     {
90       m_pos++;
91
92       return next;
93     }
94     else
95     {
96       m_foundLast = true;
97
98       return DTM.NULL;
99     }
100   }
101   
102   /**
103    * Return the first node out of the nodeset, if this expression is
104    * a nodeset expression. This is the default implementation for
105    * nodesets. Derived classes should try and override this and return a
106    * value without having to do a clone operation.
107    * @param xctxt The XPath runtime context.
108    * @return the first node out of the nodeset, or DTM.NULL.
109    */

110   public int asNode(XPathContext xctxt)
111     throws javax.xml.transform.TransformerException JavaDoc
112   {
113     return xctxt.getCurrentNode();
114   }
115   
116   /**
117    * Get the index of the last node that can be itterated to.
118    * This probably will need to be overridded by derived classes.
119    *
120    * @param xctxt XPath runtime context.
121    *
122    * @return the index of the last node that can be itterated to.
123    */

124   public int getLastPos(XPathContext xctxt)
125   {
126     return 1;
127   }
128
129
130 }
131
Popular Tags