net.sf.saxon.sort
public class GroupByIterator extends Object implements GroupIterator, LastPositionFinder, LookaheadIterator
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.
Field Summary | |
---|---|
protected AtomicComparer | comparer |
protected List<AtomicValue> | groupKeys |
protected List<List<Item>> | groups |
protected Expression | keyExpression |
Constructor Summary | |
---|---|
GroupByIterator(SequenceIterator population, Expression keyExpression, XPathContext keyContext, StringCollator collator)
Create a GroupByIterator |
Method Summary | |
---|---|
void | close() |
Item | current() |
SequenceIterator | getAnother() |
List | getCurrentGroup()
Get the contents of the current group as a java List |
AtomicValue | getCurrentGroupingKey()
Get the value of the grouping key for the current group |
int | getLastPosition()
Get the last position (that is, the number of groups) |
int | getProperties()
Get properties of this iterator, as a bit-significant integer.
|
boolean | hasNext() |
SequenceIterator | iterateCurrentGroup()
Get an iterator over the items in the current group |
Item | next() |
int | position() |
protected void | processItem(HashMap<ComparisonKey,List<Item>> index, Item item, XPathContext c2)
Process one item in the population |
Parameters: population iterator over the population to be grouped keyExpression the expression used to calculate the grouping key keyContext dynamic context for calculating the grouping key collator Collation to be used for comparing grouping keys
Throws: XPathException
Returns: the contents of the current group
Returns: the grouping key, or null if the grouping key is an empty sequence
Returns: the properties of this iterator. This will be some combination of properties such as GroupByIterator, GroupByIterator, and GroupByIterator. 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.
Returns: the iterator
Parameters: index the index of items item the item from the population to be processed c2 the XPath evaluation context
Throws: XPathException