org.apache.calcite.avatica.util

## Class IteratorCursor<E>

- java.lang.Object
- - org.apache.calcite.avatica.util.AbstractCursor
  - - org.apache.calcite.avatica.util.PositionedCursor<E>
    - - org.apache.calcite.avatica.util.IteratorCursor<E>

Type Parameters:
  `E` - Element type

All Implemented Interfaces:
  AutoCloseable, Cursor

Direct Known Subclasses:
  ArrayIteratorCursor, ListIteratorCursor, MapIteratorCursor, RecordIteratorCursor

    public abstract class IteratorCursor<E>
    extends PositionedCursor<E>

Implementation of `Cursor` on top of an `Iterator` that returns a record for each row. The returned record is cached to avoid multiple computations of current row.

### Nested Class Summary

Nested Classes
`private static class` `IteratorCursor.Position` Are we positioned on a valid row?

### Nested classes/interfaces inherited from class org.apache.calcite.avatica.util.PositionedCursor

`PositionedCursor.ArrayGetter, PositionedCursor.FieldGetter, PositionedCursor.ListGetter, PositionedCursor.MapGetter<K>, PositionedCursor.ObjectGetter`

### Nested classes/interfaces inherited from class org.apache.calcite.avatica.util.AbstractCursor

`AbstractCursor.AbstractGetter, AbstractCursor.AccessorImpl, AbstractCursor.ArrayAccessor, AbstractCursor.Getter, AbstractCursor.NumberAccessor, AbstractCursor.SlotGetter, AbstractCursor.StructGetter`

### Nested classes/interfaces inherited from interface org.apache.calcite.avatica.util.Cursor

`Cursor.Accessor`

### Field Summary

Fields
`private E` `current`
`private Iterator<E>` `iterator`
`private IteratorCursor.Position` `position`

### Fields inherited from class org.apache.calcite.avatica.util.AbstractCursor

`wasNull`

### Constructor Summary

Constructors
`protected` `IteratorCursor(Iterator<E> iterator)` Creates an `IteratorCursor`.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `close()` Closes this cursor and releases resources.
`protected E` `current()` Returns the current row.
`boolean` `next()` Moves to the next row.

### Methods inherited from class org.apache.calcite.avatica.util.AbstractCursor

`createAccessor, createAccessor, createAccessors, createGetter, intToTime, longToTimestamp, wasNull`

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

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

### Field Detail

#### position

    private IteratorCursor.Position position

#### iterator

    private final Iterator<E> iterator

#### current

    private E current

### Constructor Detail

#### IteratorCursor

    protected IteratorCursor(Iterator<E> iterator)

Creates an `IteratorCursor`.

Parameters:
  `iterator` - input iterator

### Method Detail

#### next

    public boolean next()

Description copied from interface: `Cursor`
Moves to the next row.

Specified by:
  `next` in interface `Cursor`
Specified by:
  `next` in class `AbstractCursor`
Returns:
  Whether moved

#### close

    public void close()

Description copied from interface: `Cursor`
Closes this cursor and releases resources.

#### current

    protected E current()

Description copied from class: `PositionedCursor`
Returns the current row.

Specified by:
  `current` in class `PositionedCursor<E>`
Returns:
  current row