org.eclipse.rdf4j.sail.federation.evaluation

## Class AlternativeCursor<E>

- java.lang.Object
- - org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration<E,X>
  - - org.eclipse.rdf4j.common.iteration.LookAheadIteration<E,QueryEvaluationException>
    - - org.eclipse.rdf4j.sail.federation.evaluation.AlternativeCursor<E>

- All Implemented Interfaces:
    AutoCloseable, CloseableIteration<E,QueryEvaluationException>, Iteration<E,QueryEvaluationException>

      public class AlternativeCursor<E>
      extends LookAheadIteration<E,QueryEvaluationException>

  If the primary cursor is empty, use the alternative cursor.
  Author:
    James Leigh

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AlternativeCursor(CloseableIteration<? extends E,QueryEvaluationException> primary, CloseableIteration<? extends E,QueryEvaluationException> alternative)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `E` | `getNextElement()` Gets the next element.
    `void` | `handleClose()` Called by `AbstractCloseableIteration.close()` when it is called for the first time.
    `String` | `toString()`

    - ### Methods inherited from class org.eclipse.rdf4j.common.iteration.LookAheadIteration

      `hasNext, next, remove`

    - ### Methods inherited from class org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration

      `close, isClosed`

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

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

    - ### Methods inherited from interface org.eclipse.rdf4j.common.iteration.Iteration

      `stream`

- - ### Constructor Detail

    - #### AlternativeCursor

          public AlternativeCursor(CloseableIteration<? extends E,QueryEvaluationException> primary,
                                   CloseableIteration<? extends E,QueryEvaluationException> alternative)

  - ### Method Detail

    - #### handleClose

          public void handleClose()
                           throws QueryEvaluationException

      Description copied from class: `AbstractCloseableIteration`
      Called by `AbstractCloseableIteration.close()` when it is called for the first time. This method is only called once on each iteration. By default, this method does nothing.
      Overrides:
        `handleClose` in class `LookAheadIteration<E,QueryEvaluationException>`
      Throws:
        `QueryEvaluationException`

    - #### getNextElement

          public E getNextElement()
                           throws QueryEvaluationException

      Description copied from class: `LookAheadIteration`
      Gets the next element. Subclasses should implement this method so that it returns the next element.
      Specified by:
        `getNextElement` in class `LookAheadIteration<E,QueryEvaluationException>`
      Returns:
        The next element, or `null` if no more elements are available.
      Throws:
        `QueryEvaluationException`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2015-2021 Eclipse Foundation. All Rights Reserved.