org.apache.xml.dtm.ref
Class DTMDefaultBaseTraversers.DescendantOrSelfFromRootTraverser

java.lang.Object
  extended byorg.apache.xml.dtm.DTMAxisTraverser
      extended byorg.apache.xml.dtm.ref.DTMDefaultBaseTraversers.IndexedDTMAxisTraverser
          extended byorg.apache.xml.dtm.ref.DTMDefaultBaseTraversers.DescendantTraverser
              extended byorg.apache.xml.dtm.ref.DTMDefaultBaseTraversers.DescendantOrSelfFromRootTraverser
Enclosing class:
DTMDefaultBaseTraversers

private class DTMDefaultBaseTraversers.DescendantOrSelfFromRootTraverser
extends DTMDefaultBaseTraversers.DescendantTraverser

A non-xpath axis, returns all nodes that aren't namespaces or attributes, from and including the root.


Constructor Summary
private DTMDefaultBaseTraversers.DescendantOrSelfFromRootTraverser()
           
 
Method Summary
protected  boolean axisHasBeenProcessed(int axisRoot)
          Tell if the axis has been fully processed to tell if a the wait for an arriving node should terminate.
 int first(int context)
          Return the root.
 int first(int context, int expandedTypeID)
          By the nature of the stateless traversal, the context node can not be returned or the iteration will go into an infinate loop.
protected  int getFirstPotential(int identity)
          Get the first potential identity that can be returned, which is the axis root context in this case.
protected  int getNextIndexed(int axisRoot, int nextPotential, int expandedTypeID)
          Get the next indexed node that matches the expanded type ID.
protected  int getSubtreeRoot(int handle)
          Get the first potential identity that can be returned.
protected  boolean isAfterAxis(int axisRoot, int identity)
          Tell if a node is outside the axis being traversed.
protected  boolean isDescendant(int subtreeRootIdentity, int identity)
          Tell if this node identity is a descendant.
protected  boolean isIndexed(int expandedTypeID)
          Tell if the indexing is on and the given expanded type ID matches what is in the indexes.
 int next(int context, int current)
          Traverse to the next node after the current node.
 int next(int context, int current, int expandedTypeID)
          Traverse to the next node after the current node that is matched by the expanded type ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DTMDefaultBaseTraversers.DescendantOrSelfFromRootTraverser

private DTMDefaultBaseTraversers.DescendantOrSelfFromRootTraverser()
Method Detail

getFirstPotential

protected int getFirstPotential(int identity)
Get the first potential identity that can be returned, which is the axis root context in this case.

Overrides:
getFirstPotential in class DTMDefaultBaseTraversers.DescendantTraverser
Parameters:
identity - The node identity of the root context of the traversal.
Returns:
The identity argument.

getSubtreeRoot

protected int getSubtreeRoot(int handle)
Get the first potential identity that can be returned.

Overrides:
getSubtreeRoot in class DTMDefaultBaseTraversers.DescendantTraverser
Parameters:
handle - handle to the root context.
Returns:
identity of the root of the subtree.

first

public int first(int context)
Return the root.

Overrides:
first in class DTMAxisTraverser
Parameters:
context - The context node of this traversal.
Returns:
the first node in the traversal.

first

public int first(int context,
                 int expandedTypeID)
By the nature of the stateless traversal, the context node can not be returned or the iteration will go into an infinate loop. So to traverse an axis, the first function must be used to get the first node.

This method needs to be overloaded only by those axis that process the self node. <\p>

Overrides:
first in class DTMDefaultBaseTraversers.DescendantTraverser
Parameters:
context - The context node of this traversal. This is the point of origin for the traversal -- its "root node" or starting point.
expandedTypeID - The expanded type ID that must match.
Returns:
the first node in the traversal.

axisHasBeenProcessed

protected boolean axisHasBeenProcessed(int axisRoot)
Tell if the axis has been fully processed to tell if a the wait for an arriving node should terminate.

Specified by:
axisHasBeenProcessed in class DTMDefaultBaseTraversers.IndexedDTMAxisTraverser
Parameters:
axisRoot - The root identity of the axis.
Returns:
true if the axis has been fully processed.

isDescendant

protected boolean isDescendant(int subtreeRootIdentity,
                               int identity)
Tell if this node identity is a descendant. Assumes that the node info for the element has already been obtained. %REVIEW% This is really parentFollowsRootInDocumentOrder ... which fails if the parent starts after the root ends. May be sufficient for this class's logic, but misleadingly named!

Parameters:
subtreeRootIdentity - The root context of the subtree in question.
identity - The index number of the node in question.
Returns:
true if the index is a descendant of _startNode.

isAfterAxis

protected boolean isAfterAxis(int axisRoot,
                              int identity)
Tell if a node is outside the axis being traversed. This method must be implemented by derived classes, and must be robust enough to handle any node that occurs after the axis root.

Specified by:
isAfterAxis in class DTMDefaultBaseTraversers.IndexedDTMAxisTraverser
Parameters:
axisRoot - The root identity of the axis.
identity - The node in question.
Returns:
true if the given node falls outside the axis being traversed.

next

public int next(int context,
                int current)
Traverse to the next node after the current node.

Specified by:
next in class DTMAxisTraverser
Parameters:
context - The context node of this iteration.
current - The current node of the iteration.
Returns:
the next node in the iteration, or DTM.NULL.
See Also:
DTMAxisTraverser.first(int)

next

public int next(int context,
                int current,
                int expandedTypeID)
Traverse to the next node after the current node that is matched by the expanded type ID.

Specified by:
next in class DTMAxisTraverser
Parameters:
context - The context node of this iteration.
current - The current node of the iteration.
expandedTypeID - The expanded type ID that must match.
Returns:
the next node in the iteration, or DTM.NULL.
See Also:
DTMAxisTraverser.first(int,int)

isIndexed

protected final boolean isIndexed(int expandedTypeID)
Tell if the indexing is on and the given expanded type ID matches what is in the indexes. Derived classes should call this before calling getNextIndexed method.

Parameters:
expandedTypeID - The expanded type ID being requested.
Returns:
true if it is OK to call the getNextIndexed method.

getNextIndexed

protected int getNextIndexed(int axisRoot,
                             int nextPotential,
                             int expandedTypeID)
Get the next indexed node that matches the expanded type ID. Before calling this function, one should first call isIndexed to make sure that the index can contain nodes that match the given expanded type ID.

Parameters:
axisRoot - The root identity of the axis.
nextPotential - The node found must match or occur after this node.
expandedTypeID - The expanded type ID for the request.
Returns:
The node ID or NULL if not found.