Methods Summary |
---|
protected void | countProximityPosition(int i)Count backwards one proximity position.
if (i < m_proximityPositions.length)
m_proximityPositions[i]--;
|
public void | detach()Detaches the walker from the set which it iterated over, releasing
any computational resources and placing the iterator in the INVALID
state.
m_iterator = null;
super.detach();
|
public int | getLastPos(com.sun.org.apache.xpath.internal.XPathContext xctxt)Get the number of nodes in this node list. The function is probably ill
named?
int count = 0;
AxesWalker savedWalker = wi().getLastUsedWalker();
try
{
ReverseAxesWalker clone = (ReverseAxesWalker) this.clone();
clone.setRoot(this.getRoot());
clone.setPredicateCount(this.getPredicateCount() - 1);
clone.setPrevWalker(null);
clone.setNextWalker(null);
wi().setLastUsedWalker(clone);
// Count 'em all
// count = 1;
int next;
while (DTM.NULL != (next = clone.nextNode()))
{
count++;
}
}
catch (CloneNotSupportedException cnse)
{
// can't happen
}
finally
{
wi().setLastUsedWalker(savedWalker);
}
return count;
|
protected int | getNextNode()Get the next node in document order on the axes.
if (m_foundLast)
return DTM.NULL;
int next = m_iterator.next();
if (m_isFresh)
m_isFresh = false;
if (DTM.NULL == next)
this.m_foundLast = true;
return next;
|
protected int | getProximityPosition(int predicateIndex)Get the current sub-context position. In order to do the
reverse axes count, for the moment this re-searches the axes
up to the predicate. An optimization on this is to cache
the nodes searched, but, for the moment, this case is probably
rare enough that the added complexity isn't worth it.
// A negative predicate index seems to occur with
// (preceding-sibling::*|following-sibling::*)/ancestor::*[position()]/*[position()]
// -sb
if(predicateIndex < 0)
return -1;
int count = m_proximityPositions[predicateIndex];
if (count <= 0)
{
AxesWalker savedWalker = wi().getLastUsedWalker();
try
{
ReverseAxesWalker clone = (ReverseAxesWalker) this.clone();
clone.setRoot(this.getRoot());
clone.setPredicateCount(predicateIndex);
clone.setPrevWalker(null);
clone.setNextWalker(null);
wi().setLastUsedWalker(clone);
// Count 'em all
count++;
int next;
while (DTM.NULL != (next = clone.nextNode()))
{
count++;
}
m_proximityPositions[predicateIndex] = count;
}
catch (CloneNotSupportedException cnse)
{
// can't happen
}
finally
{
wi().setLastUsedWalker(savedWalker);
}
}
return count;
|
public boolean | isDocOrdered()Returns true if all the nodes in the iteration well be returned in document
order.
Warning: This can only be called after setRoot has been called!
return false; // I think.
|
public boolean | isReverseAxes()Tells if this is a reverse axes. Overrides AxesWalker#isReverseAxes.
return true;
|
public void | setRoot(int root)Set the root node of the TreeWalker.
(Not part of the DOM2 TreeWalker interface).
super.setRoot(root);
m_iterator = getDTM(root).getAxisIterator(m_axis);
m_iterator.setStartNode(root);
|