net.sf.saxon.tree

Class TreeEnumeration

abstract class TreeEnumeration extends Object implements AxisIterator, LookaheadIterator

Field Summary
protected NodeImplcurrent
protected NodeImplnext
protected NodeTestnodeTest
protected intposition
protected NodeImplstart
Constructor Summary
TreeEnumeration(NodeImpl origin, NodeTest nodeTest)
Create an axis enumeration for a given type and name of node, from a given origin node
Method Summary
protected voidadvance()
Advance along the axis until a node is found that matches the required criteria
Valueatomize()
Return the atomized value of the current node.
voidclose()
protected booleanconforms(NodeImpl node)
Test whether a node conforms to the node type and name constraints.
Itemcurrent()
Return the current Item
intgetProperties()
Get properties of this iterator, as a bit-significant integer.
CharSequencegetStringValue()
Return the string value of the current node.
booleanhasNext()
Determine whether there are more items to come.
AxisIteratoriterateAxis(byte axis, NodeTest test)
Return an iterator over an axis, starting at the current node.
booleanmoveNext()
Move to the next node, without returning it.
Itemnext()
Return the next node in the enumeration
intposition()
Return the current position
protected abstract voidstep()
Advance one step along the axis: the resulting node might not meet the required criteria for inclusion

Field Detail

current

protected NodeImpl current

protected NodeImpl next

nodeTest

protected NodeTest nodeTest

position

protected int position

start

protected NodeImpl start

Constructor Detail

TreeEnumeration

public TreeEnumeration(NodeImpl origin, NodeTest nodeTest)
Create an axis enumeration for a given type and name of node, from a given origin node

Parameters: origin the node from which the axis originates nodeTest test to be satisfied by the returned nodes, or null if all nodes are to be returned.

Method Detail

advance

protected final void advance()
Advance along the axis until a node is found that matches the required criteria

atomize

public Value atomize()
Return the atomized value of the current node.

Returns: the atomized value.

Throws: NullPointerException if there is no current node

close

public void close()

conforms

protected boolean conforms(NodeImpl node)
Test whether a node conforms to the node type and name constraints. Note that this returns true if the supplied node is null, this is a way of terminating a loop.

current

public final Item current()
Return the current Item

getProperties

public int getProperties()
Get properties of this iterator, as a bit-significant integer.

Returns: the properties of this iterator. This will be some combination of properties such as GROUNDED, LAST_POSITION_FINDER, and LOOKAHEAD. It is always acceptable to return the value zero, indicating that there are no known special properties. It is acceptable for the properties of the iterator to change depending on its state.

getStringValue

public CharSequence getStringValue()
Return the string value of the current node.

Returns: the string value, as an instance of CharSequence.

Throws: NullPointerException if there is no current node

hasNext

public boolean hasNext()
Determine whether there are more items to come. Note that this operation is stateless and it is not necessary (or usual) to call it before calling next(). It is used only when there is an explicit need to tell if we are at the last element.

Returns: true if there are more items in the sequence

iterateAxis

public AxisIterator iterateAxis(byte axis, NodeTest test)
Return an iterator over an axis, starting at the current node.

Parameters: axis the axis to iterate over, using a constant such as CHILD test a predicate to apply to the nodes before returning them.

Throws: NullPointerException if there is no current node

moveNext

public boolean moveNext()
Move to the next node, without returning it. Returns true if there is a next node, false if the end of the sequence has been reached. After calling this method, the current node may be retrieved using the current() function.

next

public final Item next()
Return the next node in the enumeration

position

public final int position()
Return the current position

step

protected abstract void step()
Advance one step along the axis: the resulting node might not meet the required criteria for inclusion