net.sf.saxon.expr.sort

## Class SortedGroupIterator

- java.lang.Object
- - net.sf.saxon.expr.sort.SortedIterator
  - - net.sf.saxon.expr.sort.SortedGroupIterator

- All Implemented Interfaces:
    LastPositionFinder, GroupIterator, Sortable, SequenceIterator, LookaheadIterator

      public class SortedGroupIterator
      extends SortedIterator
      implements GroupIterator

  A SortedGroupIterator is a modified SortedIterator. It sorts a sequence of groups, and is itself a GroupIterator. The modifications retain extra information about the items being sorted. The items are each the leading item of a group, and as well as the item itself, the iterator preserves information about the group: specifically, an iterator over the items in the group, and the value of the grouping key (if any).

- - ### Field Summary

    - ### Fields inherited from class net.sf.saxon.expr.sort.SortedIterator

      `base, comparators, context, count, position, sortKeyEvaluator, values`

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

      `GROUNDED, LAST_POSITION_FINDER, LOOKAHEAD`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SortedGroupIterator(XPathContext context, GroupIterator base, SortKeyEvaluator sortKeyEvaluator, AtomicComparer[] comparators)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `buildArray()` Override the method that builds the array of values and sort keys.
    `AtomicSequence` | `getCurrentGroupingKey()` Get the grouping key of the current group
    `ManualGroupIterator` | `getSnapShot(XPathContext context)` Get a sequence which is a snapshot of this sequence at the current position
    `boolean` | `hasCurrentGroup()` Ask whether this iterator has a current group
    `boolean` | `hasCurrentGroupingKey()` Ask whether this iterator has a current grouping key
    `SequenceIterator` | `iterateCurrentGroup()` Get an iterator over the members of the current group, in population order.
    `Item` | `next()` Get the next item, in sorted order
    `void` | `setGroupSlot(int groupSlot)` Set a local variable slot to hold the value of the current group
    `void` | `setKeySlot(int keySlot)` Set a local variable slot to hold the value of the current grouping key

    - ### Methods inherited from class net.sf.saxon.expr.sort.SortedIterator

      `close, compare, current, getAnother, getLength, getProperties, hasNext, position, setHostLanguage, swap`

    - ### 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, current, getAnother, getProperties, position`

- - ### Constructor Detail

    - #### SortedGroupIterator

          public SortedGroupIterator(XPathContext context,
                             GroupIterator base,
                             SortKeyEvaluator sortKeyEvaluator,
                             AtomicComparer[] comparators)

  - ### Method Detail

    - #### setGroupSlot

          public void setGroupSlot(int groupSlot)

      Description copied from interface: `GroupIterator`
      Set a local variable slot to hold the value of the current group
      Specified by:
        `setGroupSlot` in interface `GroupIterator`
      Parameters:
        `groupSlot` - the stack frame position of the variable holding the current group

    - #### setKeySlot

          public void setKeySlot(int keySlot)

      Description copied from interface: `GroupIterator`
      Set a local variable slot to hold the value of the current grouping key
      Specified by:
        `setKeySlot` in interface `GroupIterator`
      Parameters:
        `keySlot` - the stack frame position of the variable holding the current grouping key

    - #### buildArray

          protected void buildArray()
                             throws XPathException

      Override the method that builds the array of values and sort keys.
      Overrides:
        `buildArray` in class `SortedIterator`
      Throws:
        `XPathException`

    - #### next

          public Item next()
                    throws XPathException

      Description copied from class: `SortedIterator`
      Get the next item, in sorted order
      Specified by:
        `next` in interface `SequenceIterator`
      Overrides:
        `next` in class `SortedIterator`
      Returns:
        the next item, or null if there are no more items. Once a call on next() has returned null, no further calls should be made. The preferred action for an iterator if subsequent calls on next() are made is to return null again, and all implementations within Saxon follow this rule.
      Throws:
        `XPathException` - if an error occurs retrieving the next item

    - #### getCurrentGroupingKey

          public AtomicSequence getCurrentGroupingKey()

      Description copied from interface: `GroupIterator`
      Get the grouping key of the current group
      Specified by:
        `getCurrentGroupingKey` in interface `GroupIterator`
      Returns:
        the current grouping key in the case of group-by or group-adjacent, or null in the case of group-starting-with and group-ending-with

    - #### iterateCurrentGroup

          public SequenceIterator iterateCurrentGroup()
                                               throws XPathException

      Description copied from interface: `GroupIterator`
      Get an iterator over the members of the current group, in population order. This must always be a clean iterator, that is, an iterator that starts at the first item of the group.
      Specified by:
        `iterateCurrentGroup` in interface `GroupIterator`
      Returns:
        an iterator over all the members of the current group, in population order.
      Throws:
        `XPathException` - if a dynamic error occurs

    - #### hasCurrentGroup

          public boolean hasCurrentGroup()

      Description copied from interface: `GroupIterator`
      Ask whether this iterator has a current group
      Specified by:
        `hasCurrentGroup` in interface `GroupIterator`
      Returns:
        false if the controlling xsl:for-each-group element binds a group variable, true if it delivers results using the current-group() function

    - #### hasCurrentGroupingKey

          public boolean hasCurrentGroupingKey()

      Description copied from interface: `GroupIterator`
      Ask whether this iterator has a current grouping key
      Specified by:
        `hasCurrentGroupingKey` in interface `GroupIterator`
      Returns:
        false if the controlling xsl:for-each-group element binds a grouping-key variable, true if it delivers results using the current-grouping-key() function

    - #### getSnapShot

          public ManualGroupIterator getSnapShot(XPathContext context)
                                          throws XPathException

      Description copied from interface: `GroupIterator`
      Get a sequence which is a snapshot of this sequence at the current position
      Specified by:
        `getSnapShot` in interface `GroupIterator`
      Throws:
        `XPathException`

Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.