com.icl.saxon.expr

## Class LookaheadEnumerator

- java.lang.Object
- - com.icl.saxon.expr.LookaheadEnumerator

- All Implemented Interfaces:
    LastPositionFinder, NodeEnumeration

      public class LookaheadEnumerator
      extends java.lang.Object
      implements NodeEnumeration, LastPositionFinder

  A LookaheadEnumerator passes the nodes from a base enumerator throgh unchanged. The complication is that on request, it must determine the value of the last() position, which requires a lookahead. A LookaheadEnumerator should only be used to wrap a NodeEnumeration that cannot determine the last() position for itself, i.e. one that is not a LastPositionFinder.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `LookaheadEnumerator(NodeEnumeration base)` Constructor

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getLastPosition()` Do lookahead to find the last position, if required
    `boolean` | `hasMoreElements()` Determine whether there are any more nodes to hand to the client
    `boolean` | `isPeer()` Determine whether the nodes are guaranteed to be peers
    `boolean` | `isReverseSorted()` Determine whether the nodes returned by this enumeration are known to be in reverse document order.
    `boolean` | `isSorted()` Determine whether the nodes are guaranteed to be in document order
    `NodeInfo` | `nextElement()` Hand the next node to the client

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### LookaheadEnumerator

          public LookaheadEnumerator(NodeEnumeration base)

      Constructor
      Parameters:
        `base` - An NodeEnumerator that delivers the nodes, but that cannot determine the last position count.

  - ### Method Detail

    - #### hasMoreElements

          public boolean hasMoreElements()

      Determine whether there are any more nodes to hand to the client
      Specified by:
        `hasMoreElements` in interface `NodeEnumeration`
      Returns:
        true if there are more nodes

    - #### nextElement

          public NodeInfo nextElement()
                               throws XPathException

      Hand the next node to the client
      Specified by:
        `nextElement` in interface `NodeEnumeration`
      Returns:
        the next NodeInfo
      Throws:
        `XPathException`

    - #### getLastPosition

          public int getLastPosition()
                              throws XPathException

      Do lookahead to find the last position, if required
      Specified by:
        `getLastPosition` in interface `LastPositionFinder`
      Throws:
        `XPathException`

    - #### isSorted

          public boolean isSorted()

      Determine whether the nodes are guaranteed to be in document order
      Specified by:
        `isSorted` in interface `NodeEnumeration`
      Returns:
        true if the nodes are guaranteed to be in document order.

    - #### isReverseSorted

          public boolean isReverseSorted()

      Description copied from interface: `NodeEnumeration`
      Determine whether the nodes returned by this enumeration are known to be in reverse document order.
      Specified by:
        `isReverseSorted` in interface `NodeEnumeration`
      Returns:
        true if the nodes are guaranteed to be in document order.

    - #### isPeer

          public boolean isPeer()

      Determine whether the nodes are guaranteed to be peers
      Specified by:
        `isPeer` in interface `NodeEnumeration`