net.sf.saxon.tinytree
Class SiblingEnumeration

java.lang.Object
  extended by net.sf.saxon.om.AxisIteratorImpl
      extended by net.sf.saxon.tinytree.SiblingEnumeration
All Implemented Interfaces:
AxisIterator, LookaheadIterator, SequenceIterator, UnfailingIterator

final class SiblingEnumeration
extends AxisIteratorImpl
implements LookaheadIterator

This class supports both the child:: and following-sibling:: axes, which are identical except for the route to the first candidate node. It enumerates either the children or the following siblings of the specified node. In the case of children, the specified node must always be a node that has children: to ensure this, construct the enumeration using NodeInfo#getEnumeration()


Field Summary
 
Fields inherited from class net.sf.saxon.om.AxisIteratorImpl
current, position
 
Fields inherited from interface net.sf.saxon.om.SequenceIterator
GROUNDED, LAST_POSITION_FINDER, LOOKAHEAD
 
Constructor Summary
SiblingEnumeration(TinyTree tree, TinyNodeImpl node, NodeTest nodeTest, boolean getChildren)
          Return an enumeration over children or siblings of the context node
 
Method Summary
 Value atomize()
          Return the atomized value of the current node.
 Item current()
          Get the current node in the sequence.
 SequenceIterator getAnother()
          Get another enumeration of the same nodes
 int getProperties()
          Get properties of this iterator, as a bit-significant integer.
 java.lang.CharSequence getStringValue()
          Return the string value of the current node.
 boolean hasNext()
          Test whether there are any more nodes to come.
 boolean moveNext()
          Move to the next node, without returning it.
 Item next()
          Return the next node in the sequence
 
Methods inherited from class net.sf.saxon.om.AxisIteratorImpl
close, iterateAxis, position
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.saxon.om.SequenceIterator
close, position
 

Constructor Detail

SiblingEnumeration

SiblingEnumeration(TinyTree tree,
                   TinyNodeImpl node,
                   NodeTest nodeTest,
                   boolean getChildren)
Return an enumeration over children or siblings of the context node

Parameters:
tree - The TinyTree containing the context node
node - The context node, the start point for the iteration
nodeTest - Test that the selected nodes must satisfy, or null indicating that all nodes are selected
getChildren - True if children of the context node are to be returned, false if following siblings are required
Method Detail

moveNext

public boolean moveNext()
Description copied from class: AxisIteratorImpl
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.

Specified by:
moveNext in interface AxisIterator
Overrides:
moveNext in class AxisIteratorImpl

next

public Item next()
Return the next node in the sequence

Specified by:
next in interface SequenceIterator
Specified by:
next in interface UnfailingIterator
Returns:
the next node, or null if the end of the sequence is reached

current

public Item current()
Get the current node in the sequence.

Specified by:
current in interface SequenceIterator
Specified by:
current in interface UnfailingIterator
Overrides:
current in class AxisIteratorImpl
Returns:
the node returned by the most recent call on next(), or the one on which we have positioned using moveNext().

hasNext

public boolean hasNext()
Test whether there are any more nodes to come. This method is used only when testing whether the current item is the last in the sequence. It's not especially efficient, but is more efficient than the alternative strategy which involves counting how many nodes there are in the sequence.

Specified by:
hasNext in interface LookaheadIterator
Returns:
true if there are more items in the sequence

atomize

public Value atomize()
              throws XPathException
Return the atomized value of the current node. This is achieved in common cases without actually instantiating the NodeInfo object

Specified by:
atomize in interface AxisIterator
Overrides:
atomize in class AxisIteratorImpl
Returns:
the atomized value.
Throws:
java.lang.NullPointerException - if there is no current node
XPathException

getStringValue

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

Specified by:
getStringValue in interface AxisIterator
Overrides:
getStringValue in class AxisIteratorImpl
Returns:
the string value, as an instance of CharSequence.
Throws:
java.lang.NullPointerException - if there is no current node

getAnother

public SequenceIterator getAnother()
Get another enumeration of the same nodes

Specified by:
getAnother in interface SequenceIterator
Specified by:
getAnother in interface UnfailingIterator
Returns:
a SequenceIterator that iterates over the same items, positioned before the first item

getProperties

public int getProperties()
Description copied from class: AxisIteratorImpl
Get properties of this iterator, as a bit-significant integer.

Specified by:
getProperties in interface SequenceIterator
Overrides:
getProperties in class AxisIteratorImpl
Returns:
the properties of this iterator. This will be some combination of properties such as SequenceIterator.GROUNDED, SequenceIterator.LAST_POSITION_FINDER, and SequenceIterator.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.