public class MappingIterator<T> extends Object implements Iterator<T>, Closeable
ObjectMapper
when binding sequence of
objects. Extension is done to allow more convenient exposing of
IOException
(which basic Iterator
does not expose)Modifier and Type | Field and Description |
---|---|
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
Context for deserialization, needed to pass through to deserializer
|
protected JsonDeserializer<T> |
_deserializer
Deserializer for individual element values.
|
protected JsonParser |
_parser
Underlying parser used for reading content to bind.
|
protected JsonStreamContext |
_seqContext
Context to resynchronize to, in case an exception is encountered
but caller wants to try to read more elements.
|
protected int |
_state
State of the iterator
|
protected JavaType |
_type
Type to bind individual elements to.
|
protected T |
_updatedValue
If not null, "value to update" instead of creating a new instance
for each call.
|
protected static MappingIterator<?> |
EMPTY_ITERATOR |
protected static int |
STATE_CLOSED
State in which iterator is closed
|
protected static int |
STATE_HAS_VALUE
State in which "hasNextValue()" has been succesfully called
and deserializer can be called to fetch value
|
protected static int |
STATE_MAY_HAVE_VALUE
State in which no recovery is needed, but "hasNextValue()" needs
to be called first
|
protected static int |
STATE_NEED_RESYNC
State in which value read failed
|
Modifier | Constructor and Description |
---|---|
protected |
MappingIterator(JavaType type,
JsonParser p,
DeserializationContext ctxt,
JsonDeserializer<?> deser,
boolean managedParser,
Object valueToUpdate) |
Modifier and Type | Method and Description |
---|---|
protected <R> R |
_handleIOException(IOException e) |
protected <R> R |
_handleMappingException(JsonMappingException e) |
protected void |
_resync() |
protected <R> R |
_throwNoSuchElement() |
void |
close() |
protected static <T> MappingIterator<T> |
emptyIterator() |
JsonLocation |
getCurrentLocation()
Convenience method, functionally equivalent to:
iterator.getParser().getCurrentLocation()
|
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; resulting container will be a
ArrayList . |
<C extends Collection<? super T>> |
readAll(C results)
Convenience method for reading all entries accessible via
this iterator
|
<L extends List<? super T>> |
readAll(L resultList)
Convenience method for reading all entries accessible via
this iterator
|
void |
remove() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
protected static final MappingIterator<?> EMPTY_ITERATOR
protected static final int STATE_CLOSED
protected static final int STATE_NEED_RESYNC
protected static final int STATE_MAY_HAVE_VALUE
protected static final int STATE_HAS_VALUE
protected final JavaType _type
protected final DeserializationContext _context
protected final JsonDeserializer<T> _deserializer
protected final JsonParser _parser
null
but set as null
when
iterator is closed, to denote closing.protected final JsonStreamContext _seqContext
protected final T _updatedValue
protected final boolean _closeParser
JsonParser
should be closed
when we are done or not; generally only called when caller did not
pass JsonParser.protected int _state
protected MappingIterator(JavaType type, JsonParser p, DeserializationContext ctxt, JsonDeserializer<?> deser, boolean managedParser, Object valueToUpdate)
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.protected static <T> MappingIterator<T> emptyIterator()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public boolean hasNextValue() throws IOException
next()
but one that may throw checked
exceptions from Jackson due to invalid input.IOException
public T nextValue() throws IOException
IOException
public List<T> readAll() throws IOException
ArrayList
.IOException
public <L extends List<? super T>> L readAll(L resultList) throws IOException
IOException
public <C extends Collection<? super T>> C readAll(C results) throws IOException
IOException
public JsonParser getParser()
public FormatSchema getParserSchema()
FormatSchema
that the underlying parser
(as per getParser()
) is using, if any; only parser of schema-aware
formats use schemas.public JsonLocation getCurrentLocation()
iterator.getParser().getCurrentLocation()
protected void _resync() throws IOException
IOException
protected <R> R _throwNoSuchElement()
protected <R> R _handleMappingException(JsonMappingException e)
protected <R> R _handleIOException(IOException e)
Copyright © 2008–2019 FasterXML. All rights reserved.