com.fasterxml.jackson.databind

## Class MappingIterator<T>

- java.lang.Object
- - com.fasterxml.jackson.databind.MappingIterator<T>

All Implemented Interfaces:
  Closeable, AutoCloseable, Iterator<T>

    public class MappingIterator<T>
    extends Object
    implements Iterator<T>, Closeable

Iterator exposed by `ObjectMapper` when binding sequence of objects. Extension is done to allow more convenient exposing of `IOException` (which basic `Iterator` does not expose)

### Field Summary

Fields
`protected boolean` `_closeParser` Flag that indicates whether input `JsonParser` should be closed when we are done or not; generally only called when caller did not pass JsonParser.
`protected DeserializationContext` `_context`
`protected JsonDeserializer<T>` `_deserializer`
`protected boolean` `_hasNextChecked` Flag that is set when we have determined what `hasNextValue()` should value; reset when `nextValue()` is called
`protected JsonParser` `_parser`
`protected JavaType` `_type`
`protected T` `_updatedValue` If not null, "value to update" instead of creating a new instance for each call.
`protected static MappingIterator<?>` `EMPTY_ITERATOR`

### Constructor Summary

Constructors
`protected` `MappingIterator(JavaType type, JsonParser jp, DeserializationContext ctxt, JsonDeserializer<?> deser)` Deprecated. Since 2.1, to be removed
`protected` `MappingIterator(JavaType type, JsonParser jp, DeserializationContext ctxt, JsonDeserializer<?> deser, boolean managedParser, Object valueToUpdate)`

### Method Summary

Methods
`void` `close()`
`protected static <T> MappingIterator<T>` `emptyIterator()`
`JsonParser` `getParser()` Accessor for getting underlying parser this iterator uses.
`FormatSchema` `getParserSchema()` Accessor for accessing `FormatSchema` that the underlying parser (as per `getParser()`) is using, if any; only parser of schema-aware formats use schemas.
`boolean` `hasNext()`
`boolean` `hasNextValue()` Equivalent of `next()` but one that may throw checked exceptions from Jackson due to invalid input.
`T` `next()`
`T` `nextValue()`
`List<T>` `readAll()` Convenience method for reading all entries accessible via this iterator
`List<T>` `readAll(List<T> resultList)` Convenience method for reading all entries accessible via this iterator
`void` `remove()`

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

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

### Field Detail

#### EMPTY_ITERATOR

    protected static final MappingIterator<?> EMPTY_ITERATOR

#### _type

    protected final JavaType _type

#### _context

    protected final DeserializationContext _context

#### _deserializer

    protected final JsonDeserializer<T> _deserializer

#### _parser

    protected JsonParser _parser

#### _closeParser

    protected final boolean _closeParser

Flag that indicates whether input `JsonParser` should be closed when we are done or not; generally only called when caller did not pass JsonParser.

#### _hasNextChecked

    protected boolean _hasNextChecked

Flag that is set when we have determined what `hasNextValue()` should value; reset when `nextValue()` is called

#### _updatedValue

    protected final T _updatedValue

If not null, "value to update" instead of creating a new instance for each call.

### Constructor Detail

#### MappingIterator

    @Deprecated
    protected MappingIterator(JavaType type,
                              JsonParser jp,
                              DeserializationContext ctxt,
                              JsonDeserializer<?> deser)

Deprecated. Since 2.1, to be removed

#### MappingIterator

    protected MappingIterator(JavaType type,
                   JsonParser jp,
                   DeserializationContext ctxt,
                   JsonDeserializer<?> deser,
                   boolean managedParser,
                   Object valueToUpdate)

Parameters:
  `managedParser` - Whether we "own" the `JsonParser` passed or not: if true, it was created by `ObjectReader` and code here needs to close it; if false, it was passed by calling code and should not be closed by iterator.

### Method Detail

#### emptyIterator

    protected static <T> MappingIterator<T> emptyIterator()

#### hasNext

    public boolean hasNext()

Specified by:
  `hasNext` in interface `Iterator<T>`

#### next

    public T next()

Specified by:
  `next` in interface `Iterator<T>`

#### remove

    public void remove()

Specified by:
  `remove` in interface `Iterator<T>`

#### close

    public void close()
               throws IOException

Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `AutoCloseable`
Throws:
  `IOException`

#### hasNextValue

    public boolean hasNextValue()
                         throws IOException

Equivalent of `next()` but one that may throw checked exceptions from Jackson due to invalid input.

Throws:
  `IOException`

#### nextValue

    public T nextValue()
                throws IOException

Throws:
  `IOException`

#### readAll

    public List<T> readAll()
                    throws IOException

Convenience method for reading all entries accessible via this iterator

Returns:
  List of entries read
Throws:
  `IOException`
Since:
  2.2

#### readAll

    public List<T> readAll(List<T> resultList)
                    throws IOException

Convenience method for reading all entries accessible via this iterator

Returns:
  List of entries read (same as passed-in argument)
Throws:
  `IOException`
Since:
  2.2

#### getParser

    public JsonParser getParser()

Accessor for getting underlying parser this iterator uses.

Since:
  2.2

#### getParserSchema

    public FormatSchema getParserSchema()

Accessor for accessing `FormatSchema` that the underlying parser (as per `getParser()`) is using, if any; only parser of schema-aware formats use schemas.

Since:
  2.2