sboag 00/12/08 19:49:39
Modified: java/src/org/apache/xpath/axes AncestorOrSelfWalker.java
AncestorWalker.java
Log:
Rather than popping the stack each time, use an index, so that cloned walkers
will work correctly.
Revision Changes Path
1.3 +1 -0
xml-xalan/java/src/org/apache/xpath/axes/AncestorOrSelfWalker.java
Index: AncestorOrSelfWalker.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/AncestorOrSelfWalker.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AncestorOrSelfWalker.java 2000/10/30 18:58:41 1.2
+++ AncestorOrSelfWalker.java 2000/12/09 03:49:38 1.3
@@ -102,6 +102,7 @@
}
m_nextLevelAmount = m_ancestors.isEmpty() ? 0 : 1;
+ m_ancestorsPos = m_ancestors.size() - 1;
}
/**
1.3 +23 -3
xml-xalan/java/src/org/apache/xpath/axes/AncestorWalker.java
Index: AncestorWalker.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/AncestorWalker.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AncestorWalker.java 2000/10/30 18:58:42 1.2
+++ AncestorWalker.java 2000/12/09 03:49:38 1.3
@@ -81,11 +81,27 @@
{
super(locPathIterator);
}
+
+ /**
+ * Get a cloned AncestorWalker.
+ *
+ * @return A new AncestorWalker that can be used without mutating this one.
+ *
+ * @throws CloneNotSupportedException
+ */
+ public Object clone() throws CloneNotSupportedException
+ {
+
+ AncestorWalker clone = (AncestorWalker) super.clone();
+ // if(null != clone.m_ancestors)
+ // clone.m_ancestorsPos = clone.m_ancestors.size() - 1;
+ return clone;
+ }
/**
* Push the ancestor nodes.
*
- * NEEDSDOC @param n
+ * @param n
*/
protected void pushAncestors(Node n)
{
@@ -100,6 +116,7 @@
}
m_nextLevelAmount = m_ancestors.isEmpty() ? 0 : 1;
+ m_ancestorsPos = m_ancestors.size() - 1;
}
/**
@@ -124,15 +141,18 @@
public Node firstChild()
{
- Node next = m_ancestors.isEmpty() ? null : (Node) m_ancestors.pop();
+ Node next = (m_ancestorsPos < 0) ? null : (Node)
m_ancestors.elementAt(m_ancestorsPos--);
- m_nextLevelAmount = m_ancestors.isEmpty() ? 0 : 1;
+ m_nextLevelAmount = (m_ancestorsPos < 0) ? 0 : 1;
return setCurrentIfNotNull(next);
}
/** NEEDSDOC Field m_ancestors */
protected Stack m_ancestors;
+
+ /** The position within the stack */
+ protected int m_ancestorsPos;
/**
* Tell what's the maximum level this axes can descend to.