Methods Summary |
---|
public java.lang.Object | clone()Get a cloned iterator.
// Do not access the location path itterator during this operation!
OneStepIterator clone = (OneStepIterator) super.clone();
if(m_iterator != null)
{
clone.m_iterator = m_iterator.cloneIterator();
}
return clone;
|
public com.sun.org.apache.xml.internal.dtm.DTMIterator | cloneWithReset()Get a cloned Iterator that is reset to the beginning
of the query.
OneStepIterator clone = (OneStepIterator) super.cloneWithReset();
clone.m_iterator = m_iterator;
return clone;
|
protected void | countProximityPosition(int i)Count backwards one proximity position.
if(!isReverseAxes())
super.countProximityPosition(i);
else if (i < m_proximityPositions.length)
m_proximityPositions[i]--;
|
public boolean | deepEquals(com.sun.org.apache.xpath.internal.Expression expr)
if(!super.deepEquals(expr))
return false;
if(m_axis != ((OneStepIterator)expr).m_axis)
return false;
return true;
|
public void | detach()Detaches the iterator from the set which it iterated over, releasing
any computational resources and placing the iterator in the INVALID
state. Afterdetach has been invoked, calls to
nextNode orpreviousNode will raise the
exception INVALID_STATE_ERR.
if(m_allowDetach)
{
if(m_axis > -1)
m_iterator = null;
// Always call the superclass detach last!
super.detach();
}
|
public int | getAxis()Returns the axis being iterated, if it is known.
return m_axis;
|
public int | getLength()The number of nodes in the list. The range of valid child node indices
is 0 to length-1 inclusive.
if(!isReverseAxes())
return super.getLength();
// Tell if this is being called from within a predicate.
boolean isPredicateTest = (this == m_execContext.getSubContextList());
// And get how many total predicates are part of this step.
int predCount = getPredicateCount();
// If we have already calculated the length, and the current predicate
// is the first predicate, then return the length. We don't cache
// the anything but the length of the list to the first predicate.
if (-1 != m_length && isPredicateTest && m_predicateIndex < 1)
return m_length;
int count = 0;
XPathContext xctxt = getXPathContext();
try
{
OneStepIterator clone = (OneStepIterator) this.cloneWithReset();
int root = getRoot();
xctxt.pushCurrentNode(root);
clone.setRoot(root, xctxt);
clone.m_predCount = m_predicateIndex;
int next;
while (DTM.NULL != (next = clone.nextNode()))
{
count++;
}
}
catch (CloneNotSupportedException cnse)
{
// can't happen
}
finally
{
xctxt.popCurrentNode();
}
if (isPredicateTest && m_predicateIndex < 1)
m_length = count;
return count;
|
protected int | getNextNode()Get the next node via getFirstAttribute && getNextAttribute.
return m_lastFetched = m_iterator.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.
if(!isReverseAxes())
return super.getProximityPosition(predicateIndex);
// A negative predicate index seems to occur with
// (preceding-sibling::*|following-sibling::*)/ancestor::*[position()]/*[position()]
// -sb
if(predicateIndex < 0)
return -1;
if (m_proximityPositions[predicateIndex] <= 0)
{
XPathContext xctxt = getXPathContext();
try
{
OneStepIterator clone = (OneStepIterator) this.clone();
int root = getRoot();
xctxt.pushCurrentNode(root);
clone.setRoot(root, xctxt);
// clone.setPredicateCount(predicateIndex);
clone.m_predCount = predicateIndex;
// Count 'em all
int count = 1;
int next;
while (DTM.NULL != (next = clone.nextNode()))
{
count++;
}
m_proximityPositions[predicateIndex] += count;
}
catch (CloneNotSupportedException cnse)
{
// can't happen
}
finally
{
xctxt.popCurrentNode();
}
}
return m_proximityPositions[predicateIndex];
|
public boolean | isReverseAxes()Tells if this is a reverse axes. Overrides AxesWalker#isReverseAxes.
return m_iterator.isReverse();
|
public void | reset()Reset the iterator.
super.reset();
if(null != m_iterator)
m_iterator.reset();
|
public void | setRoot(int context, java.lang.Object environment)Initialize the context values for this expression
after it is cloned.
super.setRoot(context, environment);
if(m_axis > -1)
m_iterator = m_cdtm.getAxisIterator(m_axis);
m_iterator.setStartNode(m_context);
|