net.sf.saxon.sort
Class GroupByIterator
java.lang.Object
net.sf.saxon.sort.GroupByIterator
- GroupIterator, LastPositionFinder, LookaheadIterator, SequenceIterator
public class GroupByIterator
extends java.lang.Object
A GroupByIterator iterates over a sequence of groups defined by
xsl:for-each-group group-by="x". The groups are returned in
order of first appearance. Note that an item can appear in several groups;
indeed, an item may be the leading item of more than one group, which means
that knowing the leading item is not enough to know the current group.
The GroupByIterator acts as a SequenceIterator, where successive calls of
next() return the leading item of each group in turn. The current item of
the iterator is therefore the leading item of the current group. To get access
to all the members of the current group, the method iterateCurrentGroup() is used;
this underpins the current-group() function in XSLT. The grouping key for the
current group is available via the getCurrentGroupingKey() method.
GroupByIterator
public GroupByIterator(SequenceIterator population,
Expression keyExpression,
XPathContext keyContext,
StringCollator collator)
throws XPathException
Create a GroupByIterator
population
- iterator over the population to be groupedkeyExpression
- the expression used to calculate the grouping keykeyContext
- dynamic context for calculating the grouping keycollator
- Collation to be used for comparing grouping keys
getCurrentGroup
public List getCurrentGroup()
Get the contents of the current group as a java List
- the contents of the current group
getProperties
public int getProperties()
Get properties of this iterator, as a bit-significant integer.
- getProperties in interface SequenceIterator
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.
This method must not be called unless the result of getProperties() on the iterator
includes the bit setting
SequenceIterator.LOOKAHEAD
- hasNext in interface LookaheadIterator
- true if there are more items in the sequence