net.sf.saxon.expr

Class FilterIterator

Implemented Interfaces:
SequenceIterator
Known Direct Subclasses:
FilterIterator.Leading, FilterIterator.NonNumeric

public class FilterIterator
extends java.lang.Object
implements SequenceIterator

A FilterIterator filters an input sequence using a filter expression. Note that a FilterIterator is not used where the filter is a constant number (PositionFilter is used for this purpose instead), so this class does no optimizations for numeric predicates.

Nested Class Summary

static class
FilterIterator.Leading
Subclass to support the extension function saxon:leading, which terminates the iteration at the first item whose predicate is false
static class
FilterIterator.NonNumeric
Subclass to handle the common special case where it is statically known that the filter cannot return a numeric value

Field Summary

protected SequenceIterator
base
protected Expression
filter
protected XPathContext
filterContext

Fields inherited from interface net.sf.saxon.om.SequenceIterator

GROUNDED, LAST_POSITION_FINDER, LOOKAHEAD

Constructor Summary

FilterIterator(SequenceIterator base, Expression filter, XPathContext context)
Constructor

Method Summary

Item
current()
SequenceIterator
getAnother()
Get another iterator to return the same nodes
protected Item
getNextMatchingItem()
Get the next item in the base sequence that matches the filter predicate if there is such an item, or null if not.
int
getProperties()
Get properties of this iterator, as a bit-significant integer.
protected boolean
matches()
Determine whether the context item matches the filter predicate
Item
next()
Get the next item if there is one
int
position()

Field Details

base

protected SequenceIterator base

filter

protected Expression filter

filterContext

protected XPathContext filterContext

Constructor Details

FilterIterator

public FilterIterator(SequenceIterator base,
                      Expression filter,
                      XPathContext context)
Constructor
Parameters:
base - An iteration of the items to be filtered
filter - The expression defining the filter predicate
context - The context in which the expression is being evaluated

Method Details

current

public Item current()
Specified by:
current in interface SequenceIterator

getAnother

public SequenceIterator getAnother()
            throws XPathException
Get another iterator to return the same nodes
Specified by:
getAnother in interface SequenceIterator

getNextMatchingItem

protected Item getNextMatchingItem()
            throws XPathException
Get the next item in the base sequence that matches the filter predicate if there is such an item, or null if not.
Returns:
the next item that matches the predicate

getProperties

public int getProperties()
Get properties of this iterator, as a bit-significant integer.
Specified by:
getProperties in interface SequenceIterator
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.

matches

protected boolean matches()
            throws XPathException
Determine whether the context item matches the filter predicate
Returns:
true if the context item matches

next

public Item next()
            throws XPathException
Get the next item if there is one
Specified by:
next in interface SequenceIterator

position

public int position()
Specified by:
position in interface SequenceIterator