Package org.htmlunit.xpath.xml.dtm.ref
Class DTMDefaultBaseTraversers.DescendantTraverser
- java.lang.Object
-
- org.htmlunit.xpath.xml.dtm.DTMAxisTraverser
-
- org.htmlunit.xpath.xml.dtm.ref.DTMDefaultBaseTraversers.IndexedDTMAxisTraverser
-
- org.htmlunit.xpath.xml.dtm.ref.DTMDefaultBaseTraversers.DescendantTraverser
-
- Direct Known Subclasses:
DTMDefaultBaseTraversers.DescendantFromRootTraverser
,DTMDefaultBaseTraversers.DescendantOrSelfFromRootTraverser
,DTMDefaultBaseTraversers.DescendantOrSelfTraverser
,DTMDefaultBaseTraversers.FollowingTraverser
- Enclosing class:
- DTMDefaultBaseTraversers
private class DTMDefaultBaseTraversers.DescendantTraverser extends DTMDefaultBaseTraversers.IndexedDTMAxisTraverser
Implements traversal of the Ancestor access, in reverse document order.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
DescendantTraverser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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, 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.protected int
getSubtreeRoot(int handle)
Get the subtree root identity from the handle that was passed in by the caller.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.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 extended type ID.-
Methods inherited from class org.htmlunit.xpath.xml.dtm.ref.DTMDefaultBaseTraversers.IndexedDTMAxisTraverser
getNextIndexed, isIndexed
-
Methods inherited from class org.htmlunit.xpath.xml.dtm.DTMAxisTraverser
first
-
-
-
-
Method Detail
-
getFirstPotential
protected int getFirstPotential(int identity)
Get the first potential identity that can be returned. This should be overridded by classes that need to return the self node.- Parameters:
identity
- The node identity of the root context of the traversal.- Returns:
- The first potential node that can be 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. This method must be implemented be a derived class.- Specified by:
axisHasBeenProcessed
in classDTMDefaultBaseTraversers.IndexedDTMAxisTraverser
- Parameters:
axisRoot
- The root identity of the axis.- Returns:
- true if the axis has been fully processed.
-
getSubtreeRoot
protected int getSubtreeRoot(int handle)
Get the subtree root identity from the handle that was passed in by the caller. Derived classes may override this to change the root context of the traversal.- Parameters:
handle
- handle to the root context.- Returns:
- identity of the root of the subtree.
-
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 classDTMDefaultBaseTraversers.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.
-
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.
- Overrides:
first
in classDTMAxisTraverser
- 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 extended type ID that must match.- Returns:
- the first node in the traversal.
-
next
public int next(int context, int current)
Traverse to the next node after the current node.- Specified by:
next
in classDTMAxisTraverser
- Parameters:
context
- The context node of this traversal. This is the point of origin for the traversal -- its "root node" or starting point.current
- The current node of the traversal. This is the last known location in the traversal, typically the node-handle returned by the previous traversal step. For the first traversal step, context should be set equal to current. Note that in order to test whether context is in the set, you must use the first() method instead.- 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 extended type ID.- Specified by:
next
in classDTMAxisTraverser
- Parameters:
context
- The context node of this traversal. This is the point of origin for the traversal -- its "root node" or starting point.current
- The current node of the traversal. This is the last known location in the traversal, typically the node-handle returned by the previous traversal step. For the first traversal step, context should be set equal to current. Note that in order to test whether context is in the set, you must use the first() method instead.expandedTypeID
- The extended type ID that must match.- Returns:
- the next node in the iteration, or DTM.NULL.
- See Also:
DTMAxisTraverser.first(int,int)
-
-